Repository navigation
feat(code-splitting): forward external star re-exports through extracted namespaces - #10559
Closed
IWANABETHATGUY wants to merge 1 commit into
Closed
IWANABETHATGUY wants to merge 1 commit into
IWANABETHATGUY wants to merge 1 commit into
Conversation
This was referenced Jul 31, 2026
…ted namespaces
The namespace-extraction fallback refused any dynamic entry with
`has_dynamic_exports`, keeping graphs with an entry-level
`export * from <external>` one chunk larger than Rollup emits.
Accept the merge when the entry's dynamic exports come entirely from its
own direct external star records, and make the extracted namespace carry
them the way Rollup's `_mergeNamespaces` does:
`find_entry_level_external_module` skips the entry-level flatten for
extraction-registered entries, so the materialized namespace keeps those
records as runtime `__reExport` merges and names only known at runtime
survive. Suppressing the chunk-level `export *` also keeps the chunk
namespace non-thenable, so an external-supplied callable `then` lands on
the extracted namespace and assimilates exactly where the unbundled
module would — after the `.then(n => n.<alias>)` callback returns it.
The namespace statement's own declared symbols (an external star
record's namespace binding, consumed by its `__reExport` merge) now
survive the getter narrowing.
Other dynamic-export sources — a CJS `export *` or a star chain that
only reaches an external transitively — keep the refusal, pinned by
`already_loaded_cjs_star_keeps_split`. New fixtures
`already_loaded_external_star{,_then}_extraction` pin the forwarding,
including the runtime-`then` assimilation.
ref #10263
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
IWANABETHATGUY
force-pushed
the
feat/already-loaded-external-star-ns-merge
branch
from
July 31, 2026 05:38
0c02c62 to
628aded
Compare
Member
Author
|
Closing for now — we're merging #10526 first. This layer's external-star runtime |
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?
Part of #10263 (stacked on #10560). Final Rollup-parity gap for the already-loaded inlining: a dynamic entry with an entry-level
export * from <external>still refused namespace extraction (has_dynamic_exports), keeping one more chunk than Rollup for such graphs.Rollup handles this with a runtime merge (verified against Rollup 4.62.3 on these exact graphs): the extracted namespace is built by
_mergeNamespaces({...static}, [externalNs]), so names only known at runtime — including a callablethensupplied by the external — survive, and the chunk itself carries noexport * from <external>, keeping the chunk namespace non-thenable.How
Two small changes express the same design with existing machinery:
dynamic_entry_namespace_extraction_allowedaccepts an entry whose dynamic exports are explained entirely by its own direct external star records (dynamic_exports_explained_by_direct_external_stars). A CJSexport *or a star chain that only reaches an external transitively keeps the refusal.find_entry_level_external_moduleskips the entry-level flatten for extraction-registered entries. That one skip does double duty: the materialized namespace keeps the star records as runtime__reExportmerges (Rolldown's_mergeNamespacesequivalent), and the suppressed chunk-levelexport *keeps the chunk namespace non-thenable, so an external-suppliedthenassimilates exactly where the unbundled module would — after the.then(n => n.<alias>)callback returns the merged namespace.The namespace statement's self-declared symbols (an external star record's namespace binding, consumed by its own
__reExportcall) now survive the getter narrowing.Emitted shape:
Tests
already_loaded_external_star_extraction—node:path'ssep(runtime-only name) observable through the extracted namespace; 3 chunksalready_loaded_external_star_then_extraction— the external's callablethenhijacks assimilation with{hijacked: true}, matching the unbundled module and Rollup; 3 chunksBoth execute the emitted output. Full Rust suite passes.
Stack: #10532 ← #10560 ← #10559 (this)