fix(core): avoid chunk filename conflicts in multi-compiler builds - #1777
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df40b7b04f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR updates @rslib/core’s Rspack output naming logic to prevent JS chunk filename collisions in multi-compiler builds by switching from index prefixing to index suffixing (e.g. shared~1.js), and adjusts runtime chunk extraction rules for ESM to preserve the single-entry single-file expectation.
Changes:
- Update chunk naming for multi-compiler builds to suffix non-entry and async chunks from later compilers with
~<index>. - Adjust ESM
runtimeChunkdefaults to extract the runtime only for bundleless or multi-entry builds. - Update unit/integration tests and snapshots to match the new naming behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/shims/index.test.ts | Updates expected CJS shim chunk filename pattern for the new ~<index> suffix scheme. |
| tests/integration/resolve/index.test.ts | Stabilizes assertions by querying known entry outputs instead of relying on Object.values ordering. |
| tests/integration/output/index.test.ts | Reworks output naming expectations to validate suffixing behavior and runtime chunk extraction behavior. |
| tests/integration/output/chunkFileName-multi/src/runtime2.js | Adds fixture entry that triggers runtime/shared chunk behavior in multi-compiler scenarios. |
| tests/integration/output/chunkFileName-multi/src/runtime1.js | Adds fixture entry that triggers runtime/shared chunk behavior in multi-compiler scenarios. |
| tests/integration/output/chunkFileName-multi/src/runtime-dep.cjs | Adds a small CJS dependency fixture used by the runtime entry fixtures. |
| tests/integration/output/chunkFileName-multi/rslib4.config.ts | Adds a 4-lib multi-compiler fixture config to validate runtime/initial chunk suffixing behavior. |
| tests/integration/externals/index.test.ts | Updates snapshots and content assertions for renamed runtime/dependency chunk outputs. |
| tests/integration/asset/index.test.ts | Updates expected runtime import path to the suffixed runtime chunk output. |
| packages/core/tests/config.test.ts | Adds/updates unit tests for chunkFilename inference/suffixing and removes runtimeChunk helper tests. |
| packages/core/tests/snapshots/config.test.ts.snap | Updates snapshots for new chunkFilename and runtimeChunk defaults across formats/compilers. |
| packages/core/src/config.ts | Implements suffix-based chunk naming (including default initial chunk handling) and revises ESM runtimeChunk defaulting logic. |
Comments suppressed due to low confidence (1)
packages/core/src/config.ts:984
- In multi-compiler builds with a user-provided string
output.filename, this branch only suffixeschunkFilenamebut leavesoutput.filenameuntouched. Since Rspack can emit runtime/other initial (non-entry) chunks viaoutput.filename, later compilers can still collide on files likerslib-runtime.jswhenruntimeChunkis enabled (bundleless or multi-entry). Consider applying the same non-entry initial chunk suffixing tooutput.filenameformultiCompilerIndex > 0(while keeping entry chunks unchanged), even whenoutput.filenameis a string template.
const finalConfig: RsbuildConfig = userJsFilename
? chunkFilename
: mergeRsbuildConfig(chunkFilename, {
output: {
filename: {
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 38d2646551
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Multi-compiler builds can emit runtime and other initial chunks through
output.filename, while async chunks useoutput.chunkFilename. Without a compiler-specific namespace, non-entry chunks can collide with chunks or entries emitted by another library config into the same directory.~<index>, starting from~0.output.filename.jstemplates. Filename functions remain user-owned, and explicittools.rspack.output.filename/chunkFilenameoverrides remain authoritative.output.filename.jsi)~i~ichunkFilenameRelated Links
Checklist