Sort manual chunks by module execution order#6240
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#fix/6233Notice: Ensure you have installed the latest nightly Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust. or load it into the REPL: |
Performance report
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #6233 by sorting manual chunks by execution order (execIndex) rather than alphabetically by alias name. This ensures that shared dependencies are bundled into the chunk that executes first, helping to avoid circular chunk dependencies.
Changes:
- Modified chunk assignment logic to sort manual chunks by module execution order instead of alphabetically
- Simplified the manual chunk assignment flow in Bundle.ts by removing intermediate sorting step
- Added comprehensive test coverage for the new sorting behavior
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Bundle.ts | Removed alphabetical sorting of manual chunks and simplified logic by directly populating the map instead of using an intermediate array |
| src/utils/chunkAssignment.ts | Added sorting by execIndex (execution order) when processing manual chunks to ensure shared dependencies go into earlier chunks |
| test/function/samples/manual-chunks-order/*.js | New test case validating that manual chunks are sorted by entry execution index |
| test/function/samples/circular-namespace-reexport-manual-chunks/_config.js | Updated expected circular chunk warning to reflect new execution-order-based sorting (formatters.js now sorted before types.js) |
| test/chunking-form/samples/manual-chunks-function/_expected//.js | Updated expected output across multiple formats (amd, cjs, es, system) to reflect that dep2 is now bundled into chunk-c (executed first) instead of chunk-b |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6240 +/- ##
==========================================
- Coverage 98.81% 98.81% -0.01%
==========================================
Files 272 272
Lines 10720 10717 -3
Branches 2870 2869 -1
==========================================
- Hits 10593 10590 -3
Misses 85 85
Partials 42 42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This PR has been released as part of rollup@4.55.2. You can test it via |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
resolves #6233
Description
This PR sorts manual chunks before the chunk-generation pass, allowing Rollup to bundle shared dependencies into the earlier manual chunk in the execution order, which helps avoid circular chunk cycles in certain scenarios.