feat: split big chunks based on modules path similarities #8775
+8,847
−22
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.
Summary
Webpack has an heuristic algorithm that splits big chunks into small ones based on their path similarities. For example, if user's project structure is like:
let's say there is one chunk that contains all modules in /aaa and /bbb folders, and it's too big, we set maxSize to split it into smaller pieces, webpack will split them based on path similarities, I assume it's based on one assumption: users modify files that are closed to each other, for example you usually make some changes in some specific sub folders, and don't affect other folders, so other chunks should not change.
we can split them by their paths like, 'aaa.js' and
bbb.js
, oraaa_1.js
aaa_2.js
bbb_1.js
bbb_2.js
, instead of random splittingChecklist