-
-
Notifications
You must be signed in to change notification settings - Fork 916
Closed
Labels
Description
Clear and concise description of the problem
The vite plugin of unocss modifies chunk.modules
in renderChunk
hook for global
mode and dist-chunk
mode.
chunk.modules[fakeCssId] = { |
chunk.modules[fakeCssId] = { |
This does not work with rolldown-vite because rolldown manages the data on the rust side and chunk.modules
is readonly.
If you want to try it out, you can apply this patch by git am -3 ./unocss.patch
to this repository and add overrides to point vite
to https://pkg.pr.new/rolldown/vite@5cdceeb
. pnpm test
would fail.
Suggested solution
Need to find a solution 🙂
Alternative
No response
Additional context
Some ideas:
- add an API to Vite so that this
ids
can be populated - add an API to rolldown so that
chunk.modules
can be modified- this feels wrong to add that to rolldown, because what we want here is "to tell Vite to include an additional CSS content to a corresponding chunk", rather than "telling rollup/rolldown to add a JS module to that chunk".
- For global mode, it can probably solved by appending an import to a virtual module from every file and delaying the
load
hook of that virtual module until all the other modules are found.- Appending imports is probably not efficient
- This probably does not work for Chunk mode. Chunk mode requires which module is included in which chunk and that information is only generated after all the
transform
hooks are called.
Validations
- Read the Contributing Guidelines.
- Read the
README.md
of using the package. - Already used the Interactive Docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
antfu and userquin