-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Add AutomaticCommonsChunksPlugin and config options and defaults #6281
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
Conversation
36f2832 to
e4950bc
Compare
Shouldn't it also accept a function with 'module' as argument? |
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
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
|
The minimum test ratio has been reached. Thanks! |
|
can you add a proper doc on the webpack page ? |
|
@Ayc0 We will once we release webpack-4 rc |
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