fix(wasm-split): deduplicate shared residual symbols - #5738
Open
sarendipitee wants to merge 1 commit into
Open
Conversation
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.
Fix duplicated symbols across shared
wasm-splitchunksSummary
Fix shared-symbol ownership across lazy WASM split points.
The splitter now:
makeLoadawaits and instantiates dependencies before dependents.Problem
Previously, symbols reachable from multiple lazy split points could remain defined in multiple residual chunks. The resulting artifacts duplicated shared function/data bodies and did not reliably establish ownership or dependency edges.
The generated loader also needed to await residual-to-residual dependencies. Without that edge, a dependent chunk could instantiate before the chunk that provides its imported function or data state.
Implementation
Ownership and emission
packages/wasm-split/wasm-split-cli/src/lib.rsresidual_chunk_symbols()to classify retained symbols, foreign imports, and owner dependencies.Node::FunctionandNode::DataSymbolseparately.Generated loader dependencies
packages/wasm-split/wasm-split-cli/src/main.rsResidual chunk loaders now emit dependencies in the form:
The callback defers lookup until load time, allowing forward references to later
constdeclarations while still invoking the dependency loader whenmakeLoadexecutesdep().Runtime loading
packages/wasm-split/wasm-split-cli/src/__wasm_split.jsfusedImports.Tests and verification
Rust
Coverage includes:
Browser
The wasm-split Playwright regression passes with all 3 tests green. It covers initial rendering, local/global WASM behavior, lazy module loading, route navigation, gzip/brotli modules, and shared-chunk requests.
Static checks
Files changed
packages/wasm-split/wasm-split-cli/src/lib.rspackages/wasm-split/wasm-split-cli/src/main.rspackages/wasm-split/wasm-split-cli/src/__wasm_split.jspackages/playwright-tests/wasm-split-harness/src/main.rspackages/playwright-tests/wasm-split.spec.jspackages/playwright-tests/playwright.config.jsWASM_SPLIT_SHARED_CHUNK_DUPLICATION.md