Visitar URL original
feat(code-splitting): route independent ESM re-exports per consumer by hyfdev · Pull Request #11177 · rolldown/rolldown · GitHub
Skip to content

feat(code-splitting): route independent ESM re-exports per consumer - #11177

Merged
hyfdev merged 4 commits into
hyfdev/issue11091-init-20261009from
hyfdev/wrapped-reexport-opt-20261009
Oct 14, 2026
Merged

hyfdev merged 4 commits into
hyfdev/issue11091-init-20261009from
hyfdev/wrapped-reexport-opt-20261009

Conversation

@hyfdev

@hyfdev hyfdev commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Wrapped ESM re-export barrels can make an eager consumer load exports used only by a dynamic consumer. This feature routes independently initialized branches per consumer.

For #11091 with tree shaking and strictExecutionOrder: true, including on-demand wrapping:

Before (rendered modules in the initial static import closure):

entry.js, req.js, barrel.js, bar.js, foo.js

After:

entry.js, req.js, bar.js

Eligibility requires a proof that the entire static dependency graph initializes independently of outside state. It accepts inert allocations and reads of already initialized local bindings. Side-effect freedom alone is insufficient: export const snapshot = importedValue can change if initialization moves past a mutation.

Consumers share memoized module initializers, preserving live bindings and object identity. Opaque namespace consumers initialize all retained members; unproven graphs and direct require() of a barrel keep their existing initialization path.

Stacked on #11167. Part of #11091.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://hyfdev-wrapped-reexport-opt-20261009-rolldown-rs.voidzero-docs.workers.dev (commit 38e1803)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://650818b7-rolldown-rs.voidzero-docs.workers.dev 38e1803 2026-10-14T03:12:13.629Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ab208fdf-rolldown-rs.voidzero-docs.workers.dev 22a2959 2026-10-14T02:39:29.322Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://caa15dff-rolldown-rs.voidzero-docs.workers.dev 1456a1a 2026-10-13T14:33:03.374Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d922f446-rolldown-rs.voidzero-docs.workers.dev 9ce04dc 2026-10-13T03:00:12.123Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://4a01766e-rolldown-rs.voidzero-docs.workers.dev 75444c3 2026-10-13T02:55:57.289Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f3ed6bcc-rolldown-rs.voidzero-docs.workers.dev ed3223d 2026-10-13T02:05:54.890Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://54e547ff-rolldown-rs.voidzero-docs.workers.dev a8e77d1 2026-10-11T14:51:22.642Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://2e1c7b1b-rolldown-rs.voidzero-docs.workers.dev 1bd7d26 2026-10-10T02:11:42.124Z Visit the dashboard ↗

@hyfdev
hyfdev added this pull request to stack #11178 October 10, 2026 02:11
@netlify

netlify Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 38e1803
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6acef27efdef3f7284e4ac25

@hyfdev
hyfdev marked this pull request as ready for review October 11, 2026 02:49
Copilot AI balanced review requested due to automatic review settings October 11, 2026 02:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codspeed

codspeed Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 4 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing hyfdev/wrapped-reexport-opt-20261009 (38e1803) with hyfdev/issue11091-init-20261009 (fb63dcb)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@IWANABETHATGUY
IWANABETHATGUY force-pushed the hyfdev/wrapped-reexport-opt-20261009 branch from 1bd7d26 to a8e77d1 Compare October 11, 2026 14:48
@hyfdev
hyfdev force-pushed the hyfdev/wrapped-reexport-opt-20261009 branch 2 times, most recently from ed3223d to 75444c3 Compare October 13, 2026 02:53
@hyfdev
hyfdev force-pushed the hyfdev/wrapped-reexport-opt-20261009 branch from 75444c3 to 9ce04dc Compare October 13, 2026 02:58
@IWANABETHATGUY

This comment has been minimized.

@IWANABETHATGUY

This comment has been minimized.

@IWANABETHATGUY

This comment has been minimized.

@hyfdev

hyfdev commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

All three repros pass at 1456a1aed with the assertions from your comments:

  • codeSplitting: false keeps re-export initialization on the shared path (510883db5).
  • CJS export * skips shared initializer emission for re-exports whose consumers handle initialization (f847ed5ac).
  • onDemandWrapping with manual chunks retains cross-chunk initialization dependencies for namespace consumers without their own wrapper (510883db5).

@hyfdev
hyfdev force-pushed the hyfdev/wrapped-reexport-opt-20261009 branch from 1456a1a to 22a2959 Compare October 14, 2026 02:37
@hyfdev
hyfdev force-pushed the hyfdev/wrapped-reexport-opt-20261009 branch from 22a2959 to 38e1803 Compare October 14, 2026 03:09
@hyfdev
hyfdev merged commit e148823 into main Oct 14, 2026
37 checks passed
@hyfdev
hyfdev deleted the hyfdev/wrapped-reexport-opt-20261009 branch October 14, 2026 03:19
@rolldown-guard rolldown-guard Bot mentioned this pull request Oct 14, 2026
shulaoda added a commit that referenced this pull request Oct 14, 2026
## [1.2.14] - 2026-10-14

### 🚀 Features

- add `output.charset` option (#11194) by @sapphi-red
- code-splitting: route independent ESM re-exports per consumer (#11177) by @hyfdev

### 🐛 Bug Fixes

- handle `output.charset: 'ascii'` + `output.minify: false` (#11207) by @sapphi-red
- tree-shaking: preserve initialization of wrapped ESM re-exports (#11167) by @hyfdev
- sourcemap: preserve boundaries when tracing has no mapping (#11170) by @sapphi-red
- strict-execution-order: account for init imports during code splitting (#11162) by @hyfdev
- strict-execution-order: avoid eager loading through mixed re-exports (#11151) by @hyfdev
- tree-shake expression statements that coerce known constants (#10825) by @IWANABETHATGUY
- shim-missing-exports: shim deep namespace reads through default imports (#11184) by @IWANABETHATGUY
- shim-missing-exports: shim missing static namespace members (#11179) by @hyfdev
- preserve-entry-signatures: keep internal bindings out of entry exports (#11094) by @hyfdev
- report ASSIGN_TO_IMPORT for writes to re-exported namespace members (#11148) by @IWANABETHATGUY
- dev: keep files loaded by the HMR stage watched when the same task rebuilds (#11154) by @Brooooooklyn
- dev: watch lazily compiled files even when a build starts first (#11152) by @Brooooooklyn
- cjs: print a CommonJS module's top-level `this` as a wrapper parameter rolldown names (#11135) by @IWANABETHATGUY
- renamer: keep fixed names off the bindings that would capture them (#11134) by @IWANABETHATGUY
- renamer: keep an external `require()` local in a CJS module off the top-level names (#11133) by @IWANABETHATGUY
- rolldown: make a repeated `close()` a no-op (#11142) by @Brooooooklyn
- avoid renaming entry top-level bindings onto their nested bindings (#11122) by @IWANABETHATGUY
- renamer: keep generated top-level names off inner bindings (#11121) by @IWANABETHATGUY

### 🚜 Refactor

- renamer: treat a CJS-wrapped module's root scope as an inner scope (#11130) by @IWANABETHATGUY

### 📚 Documentation

- add renaming design and implementation docs (#11131) by @IWANABETHATGUY

### ⚡ Performance

- ci: overlap independent setup, checks, and artifacts (#11169) by @hyfdev

### 🧪 Testing

- dev: use dunce::canonicalize so dev engine tests pass on Windows (#11192) by @shulaoda
- preserve-entry-signatures: cover nested dynamic imports (#11164) by @hyfdev

### ⚙️ Miscellaneous Tasks

- deps: upgrade oxc to 0.154.0 (#11209) by @shulaoda
- make Security Analysis pass again (security-action v1.0.10, serde_yaml -> saphyr) (#11197) by @Brooooooklyn
- deps: update rollup submodule for tests to v4.64.5 (#11190) by @rolldown-guard[bot]
- deps: update test262 submodule for tests (#11191) by @rolldown-guard[bot]
- deps: update crate-ci/typos action to v1.51.1 (#11174) by @renovate[bot]
- vite-tests: link the workspace rolldown into the Vite clone again (#11147) by @Brooooooklyn

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants