fix(splitChunks): splitChunks maxSize not work as expected if size of some type is small#9285
Merged
fix(splitChunks): splitChunks maxSize not work as expected if size of some type is small#9285
Conversation
✅ Deploy Preview for rspack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
CodSpeed Performance ReportMerging #9285 will not alter performanceComparing 🎉 Hooray!
|
|
LGTM~ nice job! |
4c0e559 to
418d386
Compare
418d386 to
f28a4a7
Compare
chenjiahan
approved these changes
Feb 19, 2025
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.
Summary
Align: https://github.com/webpack/webpack/blob/3919c844eca394d73ca930e4fc5506fb86e2b094/lib/util/deterministicGrouping.js#L326.
there is a chunk contains following modules (use 0 represents module)
User set maxSize, and total size of these modules is greater than maxSize, so we need to split it
From left, we find a position which can just fulfill the minSize
From right, we also find a position which can just fulfill the minSize
Case 1:
Perfact splitting
[0 0 0 0 0 0 0] [0 0 0] left^ [0 0 0 0] ^rightSplit it into 2 chunks, left and right are all greater than minSize
Case 2:
[0 0 0 0 0 0 0] [0 0 0] left^ [0 0] ^rightSplit it based on some special algorithm, still, the 2 chunks are all greater than minSize, so it's fine
Case 3:
[0 0 0 0 0 0 0] [0 0 0 0 0] left^ [0 0 0] ^rightLeft and Right has overlaps, if split left, right part doesn't satisfy minSize, for current version before this pr, we just ignore this, and do not split this chunk at all.
But when size is smaller than minSize, there is a possibility that not all module type's size is smaller than minSize,
eg. the right 3 modules has only 1 module that contains css, the total css size is smaller than minSize but the total js size is larger than minSize.
In this case move the module that contains that css into a existing result chunk, and re-check the maxSize
Align this logic in this pr
Checklist