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
Improve chunking algorithm for dynamic imports #3354
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…e dynamic module instead because the dynamic chunk now contains the contents of 'main-static.js'
…t is not shared by the dynamic import
…modules if there are now more loaded modules than before there's no point processing, given not painting the loaded modules would have no effect given they were already painted in the previous run
lukastaegert
force-pushed
the
improve-chunking-dynamic-imports
branch
from
January 27, 2020 06:51
d69d214
to
20813c0
Compare
Codecov Report
@@ Coverage Diff @@
## master #3354 +/- ##
==========================================
+ Coverage 93.18% 93.26% +0.07%
==========================================
Files 172 172
Lines 6059 6071 +12
Branches 1804 1808 +4
==========================================
+ Hits 5646 5662 +16
+ Misses 220 218 -2
+ Partials 193 191 -2
Continue to review full report at Codecov.
|
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #3124
Description
This implements the algorithm outlined in #3124 to no longer split chunks if a dynamic import shares code with all its importing chunks. Instead in such a situation, it will import the relevant bindings from the existing chunks. This can noticeably reduce the number of created chunks for setups with many dynamic imports.
It will also fix issues with polyfills like this one: Here, even though the polyfill will load first before bundling, it will no longer load first after bundling because it is inlined into the main chunk while there is a separate chunk of code shared with the dynamic import that is loaded first.
After this fix is applied, this can no longer happen and in order to make sure a polyfill is loaded first, it is then sufficient to place it as first import in all static entry points (which is a necessary requirement anyway as the idea of static entry points is that they can be run in any order).