-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Feature Use Case
Sapper has a CSS-handling plugin, which has recently been significantly cleaned up and is about ready to graduate into a separate Rollup plugin for wider community use:
It finds CSS that a dynamically imported chunk tree includes and then rewrites the dynamic imports with an extra bit of code. That code makes it so that in parallel to the original dynamic import we also write link tags pointing to the CSS.
So as not to duplicate code across chunks, this plugin emits a new inject_styles chunk. It then adds an import to that chunk where it's used. The problem here is that this import does not show up in the chunk.imports for the plugins that follow it.
Feature Proposal
Things I've tried:
- I've tried doing
chunk.imports.push(newImport)when adding the import ingenerateBundle. This does not persist for the next plugin - I've tried rewriting the code in
transform. This does not work because I don't have access to the dependency graph. When I callthis.getModuleInfoit returns empty arrays for theimportedIdsanddynamicallyImportedIds - I've tried rewriting the code in
renderChunk. However, I don't know the file name to add. If I simply doimport __inject_styles from 'inject_styles.js'then that doesn't get properly rewritten to include the hash in the filename.
It would be nice if at least one of these worked or there was another solution to this problem