Sort entry modules to make chunk hash names deterministic#6391
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/sort-entry-modulesNotice: 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: |
There was a problem hiding this comment.
Pull request overview
This PR aims to make Rollup’s chunk naming/hashing deterministic by sorting entry modules (and chunk name candidates) rather than relying on emission order, reducing nondeterminism when parallel operations change resolution timing.
Changes:
- Sort loaded entry modules by resolved module ID to stabilize chunk naming/hashing across runs.
- Adjust chunk name candidate ordering and remove export-name sorting logic previously used for determinism.
- Update and add tests/fixtures to reflect the new deterministic ordering.
Reviewed changes
Copilot reviewed 63 out of 63 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/misc/misc.js | Updates determinism tests; adds a new scenario for shared dependency chunk name stability. |
| test/misc/bundle-information.js | Updates assertions to reflect new deterministic output ordering. |
| test/cli/samples/code-splitting-named-inputs/_config.js | Updates expected output order for deterministic entry ordering. |
| test/cli/samples/code-splitting-named-default-inputs/_config.js | Updates expected output order for deterministic entry ordering. |
| test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk2.js | Updates expected SystemJS output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/system/nested/chunk.js | Updates expected SystemJS output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/system/main.js | Updates expected SystemJS output URLs/import targets based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk2.js | Updates expected ES output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/es/nested/chunk.js | Updates expected ES output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/es/main.js | Updates expected ES output URLs/import targets based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk2.js | Updates expected CJS output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/cjs/nested/chunk.js | Updates expected CJS output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/cjs/main.js | Updates expected CJS output URLs/import targets based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk2.js | Updates expected AMD output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/amd/nested/chunk.js | Updates expected AMD output based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/resolve-file-url/_expected/amd/main.js | Updates expected AMD output URLs/import targets based on new deterministic chunk assignment/order. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-not-specified.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-main.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-false.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic4.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic3.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic2.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-dynamic.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/system/generated-allow-extension.js | Updates expected SystemJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-not-specified.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-main.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-false.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-dynamic4.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-dynamic3.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-dynamic2.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-dynamic.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/es/generated-allow-extension.js | Updates expected ES fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-not-specified.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-main.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-false.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-dynamic4.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-dynamic3.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-dynamic2.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-dynamic.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/cjs/generated-allow-extension.js | Updates expected CJS fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-not-specified.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-main.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-false.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic4.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic3.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic2.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-dynamic.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/preserve-entry-signatures/override-via-plugin/_expected/amd/generated-allow-extension.js | Updates expected AMD fixture due to deterministic chunk ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/system/main2.js | Updates expected SystemJS fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/system/main1.js | Updates expected SystemJS fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/system/main1-alias.js | Updates expected SystemJS fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/es/main2.js | Updates expected ES fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/es/main1.js | Updates expected ES fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/es/main1-alias.js | Updates expected ES fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/cjs/main2.js | Updates expected CJS fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/cjs/main1.js | Updates expected CJS fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/cjs/main1-alias.js | Updates expected CJS fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/amd/main2.js | Updates expected AMD fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/amd/main1.js | Updates expected AMD fixture due to deterministic entry ordering changes. |
| test/chunking-form/samples/entry-aliases/_expected/amd/main1-alias.js | Updates expected AMD fixture due to deterministic entry ordering changes. |
| src/utils/exportNames.ts | Removes export sorting in mangled export assignment. |
| src/ModuleLoader.ts | Switches to sorting entry modules by resolved ID; changes chunk-name candidate ordering logic. |
| src/Module.ts | Removes priority field from chunkNames metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Performance report
|
a6b03b3 to
6f17209
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6391 +/- ##
==========================================
- Coverage 98.78% 98.78% -0.01%
==========================================
Files 274 274
Lines 10795 10785 -10
Branches 2883 2882 -1
==========================================
- Hits 10664 10654 -10
Misses 89 89
Partials 42 42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6f17209 to
814e87b
Compare
814e87b to
4cbfe98
Compare
4cbfe98 to
917713e
Compare
lukastaegert
left a comment
There was a problem hiding this comment.
Nice one, looks good to me!
|
This PR has been released as part of rollup@4.61.0. You can test it via |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This PR makes the order of entry modules deterministic by sorting loaded entry modules by their resolved module IDs instead of preserving the order in which they were emitted. As a result, hash names for manual chunks that are dependencies of those entry modules also become deterministic in specific scenarios. This PR also sorts chunk name candidates by name. Since this PR also fixes #5902, we can remove the logic for sorting export names introduced in PR #6362.