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
Extend manualChunks API #3542
Extend manualChunks API #3542
Conversation
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via
or load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## master #3542 +/- ##
==========================================
+ Coverage 96.25% 96.29% +0.04%
==========================================
Files 176 176
Lines 6027 6040 +13
Branches 1778 1781 +3
==========================================
+ Hits 5801 5816 +15
Misses 112 112
+ Partials 114 112 -2
Continue to review full report at Codecov.
|
bbe994c
to
8f66e6e
Compare
This PR is now fully documented and ready to be released |
@lukastaegert in the example code snippet you mention It comes up undefined for every module when I try it out. |
True, that is wrong. Instead you should check if there are |
No problem, I'll check if I can make it work using |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #3520
Description
This will extend the
manualChunks
function so that it gets a second parameter of the formwhere
getModuleInfo
is the same function as on the plugin context.this.moduleIds
on the plugin context in favour of an explicitthis.getModuleIds()
.Additionally, the object returned by
getModuleInfo
is extended byimporters: string[]
anddynamicImporters: string[]
which allow traversing the graph backwards in order to find out e.g. which entries import a module.For instance consider a scenario where you have a set of components, each of which dynamically imports a set of translated strings, i.e.
If many components are used together, this will result in a lot of dynamic imports of very small chunks even though it is known that all language files of the same language that are imported by the same chunk will always be used together.
The following code will merge all files of the same language that are only used by a single entry point, and put all files that are used by multiple entry points into "shared" chunks: