New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A method of adding an import based on dependency graph #3790
Comments
I've been running into an issue that is kinda similar. Did you have any success? |
Sorry for not getting back to you when this issue was created. A lot has happened since then, especially the introduction of the |
Sapper has been replaced by SvelteKit, which is built on top of Vite, so I no longer have a direct need for this. I see a few folks from the Vite team copied on #4358. As far as I'm concerned, I'm happy with any solution they're happy with, so feel free to link this issue to that PR so that it will be closed by it |
#4543 now allows you (even encourages you) to update the |
This issue has been resolved via #4543 as part of rollup@3.0.0-7. Note that this is a pre-release, so to test it, you need to install Rollup via |
This issue has been resolved via #4543 as part of rollup@3.0.0-8. Note that this is a pre-release, so to test it, you need to install Rollup via |
This issue has been resolved via #4543 as part of rollup@3.0.0. You can test it via |
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:
https://github.com/sveltejs/sapper/blob/ead10eebb7416971a390a0190f1df7c1f3327791/src/core/create_compilers/RollupCompiler.ts#L156
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 thisimport
does not show up in thechunk.imports
for the plugins that follow it.Feature Proposal
Things I've tried:
chunk.imports.push(newImport)
when adding the import ingenerateBundle
. This does not persist for the next plugintransform
. This does not work because I don't have access to the dependency graph. When I callthis.getModuleInfo
it returns empty arrays for theimportedIds
anddynamicallyImportedIds
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
Related Requests
#3519
The text was updated successfully, but these errors were encountered: