plugin-webpack: fixes / improvements to default splitChunks config #1616
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.
Changes
/web_modules
rather than/node_modules
for large third-party JS modules.compact: true
setting in our babel-loader config compressed files a bit before getting to splitChunks, and allowed some pretty large libraries (like Moment) to get under the 150KB threshold.numEntries
value to getSplitChunksConfigcommons
chunk entirely when there is only one entry point.Testing
Manually tested against a small project that has one entrypoint and imports Moment (a large JS dependency). Before, all modules were pulled into a commons chunk and Moment wasn't pulled out into its own chunk; after this patch, the
commons
chunk is gone andlib-moment.HASH.js
is emitted.I also tested adding a second entry point to the project, and it introduces a commons chunk as expected:
Docs
None; bug fixes only.