fix(esm-library): name split runtime chunk to avoid cross-lib filename collision#14508
Draft
stormslowly wants to merge 2 commits into
Draft
fix(esm-library): name split runtime chunk to avoid cross-lib filename collision#14508stormslowly wants to merge 2 commits into
stormslowly wants to merge 2 commits into
Conversation
Contributor
📦 Binary Size-limit
🙈 Size remains the same at 67.93MB |
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
5ad4380 to
fca9550
Compare
fca9550 to
bbaf95a
Compare
bbaf95a to
baf2b89
Compare
…e collision When the esm-library splits the runtime into a separate chunk (optimize_runtime_chunks), it only added an id name hint and left the chunk unnamed, so its filename fell back to the numeric chunk id (e.g. 612.js). Two compilations that share one output directory - e.g. multiple rslib libs built into the same dist/ - can each independently produce a runtime chunk with the same id and the same filename. Because the libs build concurrently the writes race, so the entry that imports './612.js' may get the other lib's runtime, which lacks its __webpack_require__.add registration helper and crashes with 'TypeError: __webpack_require__.add is not a function'. Name the runtime chunk after its entrypoint (mirroring webpack's optimization.runtimeChunk 'runtime~<entry>' convention) so it is unique per entry and cannot collide across libraries. A configCase reproduces the collision: two modern-module libs (runtimeChunk disabled so the esm-library splits the runtime itself) sharing one output dir previously both emitted '612.js'; now they emit 'a_runtime.js' and 'b_runtime.js'.
baf2b89 to
db15c29
Compare
Deploying rspack with
|
| Latest commit: |
aa445cb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5de25aef.rspack-v2.pages.dev |
| Branch Preview URL: | https://worktree-linux-flaky-24.rspack-v2.pages.dev |
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.
Why
CI flakily fails on Linux with nearly every test crashing on the self-built
@rspack/core:rslib builds
@rspack/coreas several libraries into one shareddist/. The esm-library (optimize_runtime_chunks) splits each lib's runtime into a separate chunk but leaves it unnamed, so its filename falls back to the numeric chunk id. Theindexlib and theworkerlib both producedist/612.js— with different content (onlyindex's defines__webpack_require__.add). The libs build concurrently, so the two writes todist/612.jsrace; whenworker's wins,index.jsimports a runtime without.addand everything importing@rspack/corecrashes.webpack names its runtime chunk
runtime~<entry>(unique per entry); the esm-library's split just forgot to name it.Example failing job: https://github.com/web-infra-dev/rspack/actions/runs/27828246494/job/82359330267
What
Name the split runtime chunk after its entrypoint so it can't collide across libs sharing a directory.
dist/612.js612.js← collideindex_runtime.jsworker_runtime.jsTest:
configCases/library/modern-module-runtime-chunk-naming— two libs sharing a dir both emitted612.jsbefore, now emita_runtime.js/b_runtime.js(red without the fix, green with it).