Add AutomaticCommonsChunksPlugin and config options and defaults#6281
Merged
Add AutomaticCommonsChunksPlugin and config options and defaults#6281
Conversation
36f2832 to
e4950bc
Compare
Shouldn't it also accept a function with 'module' as argument? |
Member
Author
Yep, it does that too. |
e4950bc to
f25c9b5
Compare
enable it by default for async chunks add options for initial chunks
fix bugs
with defaults
split keeps runtime chunk in entrypoint default runtime chunk back to first chunk to keep CCP working
f25c9b5 to
acdabb1
Compare
Contributor
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
Contributor
|
The minimum test ratio has been reached. Thanks! |
This was referenced Jan 14, 2018
|
can you add a proper doc on the webpack page ? |
Member
|
@Ayc0 We will once we release webpack-4 rc |
This file contains hidden or 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
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.
What kind of change does this PR introduce?
feature
Did you add tests for your changes?
yes
If relevant, link to documentation update:
TODO
Summary
This adds a new Plugin which automatically creates commons chunks and vendor chunks with minimal configuration.
By default it creates async commons chunks for everything on-demand loaded. It starts creating commons chunks when they reach a minimum size of 30kb. It ensures that at a split point only issues a maximum of 4 requests and uses the 4 biggest commons chunks that this location. These numbers are open for discussion and configurable. ->
optimization.asyncCommonsChunksWhen
optimization.initialCommonsChunksis truthy it does the same for initial chunks. It's disabled by default because with this switched on you need some infrastructure to generate the HTML from the stats (i. e. HtmlPlugin).When
optimization.initialVendorsChunk: trueall node_modules are extracted into a separate initial chunk (namedvendors). You can give it a custom name withoptimization.initialVendorsChunk: "libs".When
optimization.initialVendorsChunkis an object you can create multiple vendors chunks based on regular expressions or string prefix:Vendors chunks are only used for an entrypoint when the selected modules are really used. So defining unused vendors doesn't hurt.
The webpack runtime is always kept in the original app chunk, to keep the commons/vendors chunks cachable.
This makes the
CommonsChunkPluginobsolete, it's too complex to use anyway. The commons chunks generated by the new plugin are more efficient and automatic.Does this PR introduce a breaking change?
yes, because it's enabled by default
Other information