Repository navigation
fix(code-splitting): excessive splitting of static+dynamic shared deps - #10532
Closed
IWANABETHATGUY wants to merge 1 commit into
Closed
IWANABETHATGUY wants to merge 1 commit into
IWANABETHATGUY wants to merge 1 commit into
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
The dynamic already-loaded pass rejected merging a shared dependency
into the single dynamic-entry chunk whenever the atom carried exports
outside that entry's signature, keeping `import()` namespaces clean but
splitting graphs like main -> import('./app.js') with app/lazy both
statically importing vendor into four chunks instead of three.
Accept the merge when the extra exports are provably unobservable: the
chunk is a pure dynamic entry, every `import()` of it records a known
partial usage set (`DynamicImportExportsUsage::Partial`), and each used
name resolves to one of the entry's non-ambiguous exports. Dynamic-entry
export retention keeps exactly those names exported, and generated
export names deconflict against them, so no recorded read can reach a
merged binding. Opaque namespace uses and reads of unexported names
still keep the split.
close #10263
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
IWANABETHATGUY
force-pushed
the
fix/already-loaded-partial-usage-inlining
branch
from
July 31, 2026 05:38
268f343 to
cc6f710
Compare
Member
Author
|
Closing in favour of #10526, which has since implemented the same partial-usage lean path — its |
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.
What is this PR solving?
Fixes #10263 — a module imported both statically and dynamically splits into its own chunk even when it is guaranteed to be already loaded.
For the issue's graph (
main.js→import('./app.js');app.jsandlazy.jsboth statically importvendor.js;lazy.jsis only dynamically imported fromapp.js), Rolldown emitted 4 chunks where Rollup emits 3. The already-loaded pass (dynamic_already_loaded.rs) correctly reducesvendor's bits to{app}, but the namespace guard then rejected the merge becausevendor's exports are not part ofapp's signature — the extra chunk export would leak onto theimport('./app.js')namespace.How
Add one acceptance condition to that guard: the extra exports are provably unobservable. For a pure dynamic entry, when every
import()of it reads a statically known name set (DynamicImportExportsUsage::Partial) and each used name resolves to one of the entry's non-ambiguous exports, no recorded read can reach a merged binding:ConflictResolver, which processes the entry module first viadeconflict_order_key).Reads of names the entry does not export (source semantics
undefined) keep the guard, since a generated name could otherwise shadow them. Opaque namespace uses (Object.keys, passing the namespace around) areCompleteand keep the old behavior — the stacked PRs above this one handle those.Output for the issue's repro (3 chunks, and leaner than Rollup's — no namespace object, no runtime helper, no extra promise hop):
Alternatives explored
Rollup accepts the reduction unconditionally and repairs the namespace at render time (
generateFacades+.then(n => n.a)rewrites). That machinery is layered on top of this PR as #10560 / #10559; this PR keeps the cases that need no repair at all maximally lean.Tests
crates/rolldown/tests/rolldown/issues/10263/reproduces the issue graph and asserts 3 chunks plus runtime behavior (_test.mjsexecutes the output). Full Rust suite passes with no other snapshot changes.Stack: #10532 (this) ← #10560 ← #10559