Skip to content

fix(code-splitting): route CJS barrel initialization per consumer - #10488

Merged
graphite-app[bot] merged 1 commit into
mainfrom
fix/strict-order-consumer-local-barrel-init
Jul 29, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
fix/strict-order-consumer-local-barrel-init

Conversation

@hyfdev

@hyfdev hyfdev commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

With strictExecutionOrder, importing one binding from an otherwise re-export-only barrel could initialize unrelated CommonJS re-exports and pull lazy-route code into the initial load. This PR makes each consumer initialize only the exports it can statically reach while preserving complete namespace and cycle semantics.

// barrel.js
export { cn } from './cn.js';
export { default as cloneDeep } from './clone.cjs';

// main.js
import { cn } from './barrel.js';
export const loadRoute = () => import('./route.js');

// route.js
import { cloneDeep } from './barrel.js';

// Before: loading main.js also initialized clone.cjs.
// After: clone.cjs waits until loadRoute() loads route.js.

Problem

The regression occurs in strict-order builds when tree shaking retains different exports from the same re-export-only barrel for eager and lazy consumers, especially when one re-export needs generated CommonJS interop. Both wrap-all and on-demand strict modes could put the lazy leaf in the eager entry's static closure.

Generated CommonJS interop previously gave the barrel one shared initialization body. Every consumer therefore initialized that body as a unit, and pre-chunk reachability followed the barrel's bundle-wide dependency union instead of the leaves selected by that consumer.

Non-strict builds are unaffected. The narrower routing is limited to tree-shaken source modules made entirely of direct re-exports; shapes whose evaluation cannot be safely split retain the existing behavior.

Fix

Keep eligible re-export-only barrels as routing points and make generated CommonJS interop independently callable for each re-export record.

Each CommonJS re-export now has a memoized carrier beside its importee. Named imports and statically resolved namespace members select only their leaf and, when needed, its carrier; opaque namespace uses expand that consumer's complete statically known leaf/carrier list without disabling routing for other consumers. Effectful carriers become unconditional only when every forwarding hop retains their side effects, and selected leaves and carriers remain in source order.

The same importer-local resolution drives pre-chunk placement, on-demand cycle projection, cross-chunk registration, and final emission. Non-routing wrappers that materialize a consumer-local namespace initialize its complete ordered target list inside their existing module guard and at the original re-export position. A consumer-local entry instead invokes that list from its entry prologue, or from the rewritten import() call site when its dynamic-entry facade is collapsed, so namespace getters cannot observe uninitialized leaves or carriers.

The conservative monolithic path remains for tree-shaking-disabled builds, modules with local executable bodies, synchronous import/require SCCs, direct opaque CommonJS require() targets, top-level await, dynamic exports, CJS export *, missing-export shims, and concatenated wrappers. Keeping synchronous SCCs monolithic preserves one evaluating guard across dependency traversal and the module body.

Validation

The directed fixtures cover the behavior at observable boundaries:

  • cjs_reexport_barrel_consumer_local and cjs_reexport_barrel_namespace_routing are red on main and green here for named imports, static namespace members, opaque namespace expansion, and lazy-route isolation.
  • cjs_reexport_barrel_per_record_chunks and cjs_reexport_barrel_shared_importee pin per-record carrier identity and placement, including multiple records that reach the same CommonJS module.
  • cjs_reexport_barrel_effectful_carrier and cjs_reexport_barrel_side_effect_boundary pin source ordering and nested moduleSideEffects boundaries.
  • cjs_reexport_barrel_monolithic_require_namespace, cjs_reexport_barrel_monolithic_esm_namespace, and cjs_reexport_barrel_nested_namespace were red in the initial implementation and are green in the final revision for complete namespaces above consumer-local routes and nested waypoint reachability.
  • cjs_reexport_barrel_cycle_fallback, cjs_reexport_barrel_require_cycle_fallback, and cjs_reexport_barrel_require_fallback lock the conservative path. The require fallback now observes the unrelated CommonJS leaf before the eager entry body and confirms that the later lazy route does not initialize it twice.

On the recorded vue-vben-admin reproduction, initial-load gzip changes from 615,917 B before the fix to 81,271 B in wrap-all and 80,692 B in on-demand; strict mode off is 61,780 B.

Checks run on the final rebased commit:

  • strict-execution-order fixtures: 95/95 passed
  • strict-execution-order invariant fixtures: 5/5 passed
  • strict-execution-order Rust invariant tests: 12/12 passed
  • cargo test -p rolldown --lib: 104/104 passed
  • cargo clippy -p rolldown --all-targets -- --deny warnings
  • cargo fmt --all -- --check
  • just lint-repo

The order fuzzer also found no new divergence for seeds 1000-1099 across wrap-all/on-demand and mixed/pure-ESM inputs; all four cells retained the known 97/3 baseline. Full Node, WASI, and Vite suites were not run locally and remain covered by CI.

Part of #10294.

@netlify

netlify Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 9fef009
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a69978fd937d80008853299

@hyfdev
hyfdev force-pushed the fix/strict-order-consumer-local-barrel-init branch from 6ab487c to 91ed0fb Compare July 28, 2026 03:41
@hyfdev

This comment was marked as resolved.

@hyfdev
hyfdev force-pushed the fix/strict-order-consumer-local-barrel-init branch 3 times, most recently from 4498d57 to 7bb4187 Compare July 28, 2026 06:26
@hyfdev

This comment was marked as resolved.

@hyfdev
hyfdev force-pushed the fix/strict-order-consumer-local-barrel-init branch from 7bb4187 to 957ea3c Compare July 28, 2026 07:49
@hyfdev
hyfdev marked this pull request as ready for review July 28, 2026 08:07
Copilot AI review requested due to automatic review settings July 28, 2026 08:07

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.

@hyfdev

This comment was marked as resolved.

@codspeed

codspeed Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/strict-order-consumer-local-barrel-init (be29220) with main (f1970f8)

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. ↩

@hyfdev
hyfdev force-pushed the fix/strict-order-consumer-local-barrel-init branch from 957ea3c to 3bd2839 Compare July 28, 2026 08:27
@hyfdev

hyfdev commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Should be the last p1 fix.

@hyfdev
hyfdev force-pushed the fix/strict-order-consumer-local-barrel-init branch 2 times, most recently from ffe389c to 1bd09b1 Compare July 29, 2026 02:32
@IWANABETHATGUY

This comment was marked as resolved.

@hyfdev
hyfdev force-pushed the fix/strict-order-consumer-local-barrel-init branch 2 times, most recently from bd46c50 to be29220 Compare July 29, 2026 04:04
@hyfdev

hyfdev commented Jul 29, 2026 •

Copy link
Copy Markdown
Member Author

@IWANABETHATGUY Thanks for the deep pass — especially for pressuring the carrier interaction from the registration side; the earlier rounds had only covered that invariant from the emission side.

Everything is now either fixed on the head or explicitly deferred. The fixes went in as part of the squashed force-push, so the reviewable delta is git diff 1bd09b10c..be292203 — 7 files, +51/−31, nothing else on the branch changed.

Fixed in be29220:

  • Item 1 (registration doesn't know about carriers): add_depended_symbol_with_wrapped_esm_init now consults order_cjs_carrier_key_for_namespace first and registers that exact per-record carrier as an additional init companion, through the same add_wrapped_esm_init_target_depended_symbol path so live-chunk filtering still applies (compute_cross_chunk_links.rs:725-735). Defense-in-depth as you suggested: the emission-side invariant still holds, but a consumer shape that ever escapes it now gets a registered carrier import instead of a silently dropped init. The stale wrapper_is_reachable_in_chunk justification comment is rewritten to state the actual rule (every live referenced binding is paired with its init companion; a carrier namespace additionally registers its carrier wrapper).
  • Item 3 (per-record loop cost in every build): exactly your prescribed mechanical fix. The whole per-statement loop is skipped when the state has no consumer-local routes (code_splitting.rs:1151,1226), so non-strict builds pay one is_empty() per entry and zero per-record work; within strict builds the cheap is_consumer_local_reexport_route(importee) lookup now runs before import_record_has_live_binding_consumer (code_splitting.rs:1239).
  • Item 2: the consumer-local prologue path now pins debug_assert!(!target.tla_tainted) at the emission site (render_chunk_exports.rs:66), matching the single-target path and the collapsed-rewrite twin.
  • Item 6: retained_star_renamed_cycle/_test.mjs now asserts pageANamespace.common === 'common'.
  • Item 9: dropped — the dead guard and the order_state parameter are removed from ensure_lazy_module_initialization_order; your corpus experiment settled that the future-proofing wasn't buying anything.
  • Item 10 (partial): the exhaustion-rule comment now names both dedup sets.

Deferred as follow-ups, queued for the #10294 ledger: item 4 (sort_by_cached_key + record-position index + (forwarder, target) memoization — agreed the backtracking visited.remove makes it path enumeration on barrel diamonds), item 5 (compute the wrap-all probe analysis and the Tarjan SCC pass once and thread them through), item 7 (fallback-trigger × barrel combination fixtures plus inlineDynamicImports; I'd fold one more into that batch: effectful_carrier / side_effect_boundary have no strict-off cell today, so "declared-false executes the same set as flag-off" is currently analytic rather than pinned), item 8 (drop the intentionally-empty shared wrapper when nothing routes to it), and the rest of item 10 (var ns = void 0; → var ns;, the unreachable FromCjsWrapKindEntry branch).

CI is green on be29220 (cargo test, Vite Ubuntu, Node dev-server suites; Node Validation finished after your pass), and I've added the ci: windows label so the full matrix runs before merge.

hyfdev commented Jul 29, 2026 •

Copy link
Copy Markdown
Member Author

Merge activity

  • Jul 29, 6:00 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 29, 6:00 AM UTC: hyfdev added this pull request to the Graphite merge queue.
  • Jul 29, 6:19 AM UTC: Merged by the Graphite merge queue.

…0488)

With `strictExecutionOrder`, importing one binding from an otherwise re-export-only barrel could initialize unrelated CommonJS re-exports and pull lazy-route code into the initial load. This PR makes each consumer initialize only the exports it can statically reach while preserving complete namespace and cycle semantics.

```js
// barrel.js
export { cn } from './cn.js';
export { default as cloneDeep } from './clone.cjs';

// main.js
import { cn } from './barrel.js';
export const loadRoute = () => import('./route.js');

// route.js
import { cloneDeep } from './barrel.js';

// Before: loading main.js also initialized clone.cjs.
// After: clone.cjs waits until loadRoute() loads route.js.
```

## Problem

The regression occurs in strict-order builds when tree shaking retains different exports from the same re-export-only barrel for eager and lazy consumers, especially when one re-export needs generated CommonJS interop. Both wrap-all and on-demand strict modes could put the lazy leaf in the eager entry's static closure.

Generated CommonJS interop previously gave the barrel one shared initialization body. Every consumer therefore initialized that body as a unit, and pre-chunk reachability followed the barrel's bundle-wide dependency union instead of the leaves selected by that consumer.

Non-strict builds are unaffected. The narrower routing is limited to tree-shaken source modules made entirely of direct re-exports; shapes whose evaluation cannot be safely split retain the existing behavior.

## Fix

Keep eligible re-export-only barrels as routing points and make generated CommonJS interop independently callable for each re-export record.

Each CommonJS re-export now has a memoized carrier beside its importee. Named imports and statically resolved namespace members select only their leaf and, when needed, its carrier; opaque namespace uses expand that consumer's complete statically known leaf/carrier list without disabling routing for other consumers. Effectful carriers become unconditional only when every forwarding hop retains their side effects, and selected leaves and carriers remain in source order.

The same importer-local resolution drives pre-chunk placement, on-demand cycle projection, cross-chunk registration, and final emission. Non-routing wrappers that materialize a consumer-local namespace initialize its complete ordered target list inside their existing module guard and at the original re-export position. A consumer-local entry instead invokes that list from its entry prologue, or from the rewritten `import()` call site when its dynamic-entry facade is collapsed, so namespace getters cannot observe uninitialized leaves or carriers.

The conservative monolithic path remains for tree-shaking-disabled builds, modules with local executable bodies, synchronous `import`/`require` SCCs, direct opaque CommonJS `require()` targets, top-level await, dynamic exports, CJS `export *`, missing-export shims, and concatenated wrappers. Keeping synchronous SCCs monolithic preserves one evaluating guard across dependency traversal and the module body.

## Validation

The directed fixtures cover the behavior at observable boundaries:

- `cjs_reexport_barrel_consumer_local` and `cjs_reexport_barrel_namespace_routing` are red on `main` and green here for named imports, static namespace members, opaque namespace expansion, and lazy-route isolation.
- `cjs_reexport_barrel_per_record_chunks` and `cjs_reexport_barrel_shared_importee` pin per-record carrier identity and placement, including multiple records that reach the same CommonJS module.
- `cjs_reexport_barrel_effectful_carrier` and `cjs_reexport_barrel_side_effect_boundary` pin source ordering and nested `moduleSideEffects` boundaries.
- `cjs_reexport_barrel_monolithic_require_namespace`, `cjs_reexport_barrel_monolithic_esm_namespace`, and `cjs_reexport_barrel_nested_namespace` were red in the initial implementation and are green in the final revision for complete namespaces above consumer-local routes and nested waypoint reachability.
- `cjs_reexport_barrel_cycle_fallback`, `cjs_reexport_barrel_require_cycle_fallback`, and `cjs_reexport_barrel_require_fallback` lock the conservative path. The require fallback now observes the unrelated CommonJS leaf before the eager entry body and confirms that the later lazy route does not initialize it twice.

On the recorded vue-vben-admin reproduction, initial-load gzip changes from 615,917 B before the fix to 81,271 B in wrap-all and 80,692 B in on-demand; strict mode off is 61,780 B.

Checks run on the final rebased commit:

- strict-execution-order fixtures: 95/95 passed
- strict-execution-order invariant fixtures: 5/5 passed
- strict-execution-order Rust invariant tests: 12/12 passed
- `cargo test -p rolldown --lib`: 104/104 passed
- `cargo clippy -p rolldown --all-targets -- --deny warnings`
- `cargo fmt --all -- --check`
- `just lint-repo`

The order fuzzer also found no new divergence for seeds 1000-1099 across wrap-all/on-demand and mixed/pure-ESM inputs; all four cells retained the known 97/3 baseline. Full Node, WASI, and Vite suites were not run locally and remain covered by CI.

Part of #10294.
@graphite-app
graphite-app Bot force-pushed the fix/strict-order-consumer-local-barrel-init branch from be29220 to 9fef009 Compare July 29, 2026 06:02
@graphite-app
graphite-app Bot merged commit 9fef009 into main Jul 29, 2026
35 of 36 checks passed
@graphite-app
graphite-app Bot deleted the fix/strict-order-consumer-local-barrel-init branch July 29, 2026 06:19
graphite-app Bot pushed a commit that referenced this pull request Jul 29, 2026
…quivalence (#10514)

The fallback decisions from #10488 — which barrel shapes must give up per-consumer routing — were mostly untested: of the rejecting triggers, only cycles and direct `require()` targets had fixtures, so a regressed decision would surface only as snapshot drift in unrelated fixtures. This PR pins every constructible trigger, plus the claim that a `moduleSideEffects: false` barrel executes the same set with the flag on and off, as runnable assertions. For example:

```js
// barrel: one leaf carries top-level await → the whole barrel refuses routing
export { cn } from './cn.js';                            // contains `await Promise.resolve()`
export { default as cloneDeep } from './clone-deep.cjs';

// pinned: the entry initializes clone-deep eagerly —
// asserted as runtime events ['cn', 'clone-deep', 'main:a b'], not only as a snapshot
```

Stacked on #10513 (the carrier-declaration change) so the snapshots carry the final declaration shape.

## Motivation

The routing side of the barrel fix is heavily fixtured, but the refusing side is load-bearing semantics with one-sided coverage. A wrong fallback decision — routing a shape that must stay monolithic, or vice versa — would not fail any test today; it would only drift snapshots elsewhere, which reads as noise. The strict/non-strict same-execution-set claim for side-effect boundaries was likewise argued in review, not asserted by a test.

## New fixtures

Each fallback fixture runs a wrap-all and an on-demand cell and asserts both placement (the entry's static import closure) and runtime event order on Node:

- `cjs_reexport_barrel_tla_fallback` — a top-level-await taint keeps the barrel monolithic: the unrelated CJS leaf joins the eager entry.
- `cjs_reexport_barrel_external_star_fallback` — `export *` from an external module (dynamic exports) keeps the barrel monolithic; the external import and the CJS leaf both become eager.
- `cjs_reexport_barrel_cjs_export_star_fallback` — `export *` from a CJS module keeps the barrel monolithic; star bindings resolve through the namespace merge.
- `cjs_reexport_barrel_shimmed_export_fallback` — a shimmed missing export keeps the barrel monolithic; the shimmed binding reads `undefined`.
- `cjs_reexport_barrel_code_splitting_disabled` — single-chunk output (`codeSplitting: false`, the current spelling of `inlineDynamicImports`). One observation here: the plans diverge. Wrap-all still routes per consumer, so the CJS leaf stays lazy behind the inlined `import()` trigger; on-demand sees no cross-chunk hazard in one chunk, leaves the barrel out of its wrap plan, and the monolithic interop body makes the leaf eager. Source order holds in both, and the eager-set gap is in wrap-all's favor, so the "wrap-all never executes more user code than on-demand" invariant stands — flagged in case on-demand should match wrap-all's laziness here, which this fixture would now catch.
- `cjs_reexport_barrel_effectful_carrier` / `cjs_reexport_barrel_side_effect_boundary` gain a `flag-off` cell each: strict and non-strict execute the same eager and lazy sets, with one legitimate order difference the cells document — non-strict hoists generated CJS interop via lazy-init transfer, strict keeps each require at its re-export source position.

A concatenated-wrapper × barrel fixture is not constructible today: `ConcatenateWrappedModuleKind::Inner`/`Root` never arises on this branch (see the `concatenate_basic` fixture's `_comment`), so that eligibility guard remains future-proofing.

## Validation

All fixtures pin current behavior — green here by construction; their value is turning a future fallback regression from silent snapshot drift into a named failure.

- strict-execution-order fixtures: 106/106 (101 on the base branch, +5 new)
- full `--ignored` integration corpus: no new failures relative to the base branch on this machine; this PR adds 5 passes
- Test-only: no source files change in this PR.

Part of #10294.
@rolldown-guard rolldown-guard Bot mentioned this pull request Jul 29, 2026
shulaoda added a commit that referenced this pull request Jul 29, 2026
## [1.2.1] - 2026-07-29

### 🚀 Features

- dev: support `hotUpdate` hook (#10305) by @h-a-n-a
- dev: expose `disableWatcher` through the dev engine bindings (#10474) by @shulaoda
- plugin: surface output-option callbacks in [PLUGIN_TIMINGS] (#10411) by @IWANABETHATGUY
- `import.meta.ROLLDOWN_FILE_URL_<referenceId>_<urlId>` support to pass context to `resolveFileUrl` hook (#10297) by @sapphi-red
- dev: skip the HMR update when a module's rebuilt output is unchanged (#10333) by @h-a-n-a
- code-splitting: wrap strict execution order modules on demand (#10104) by @hyfdev
- support `import.meta.ROLLDOWN_FILE_URL_*` (#10296) by @sapphi-red
- implement `resolveFileUrl` plugin hook (#10291) by @sapphi-red
- magic-string: support storeName on overwrite/update (#10312) by @IWANABETHATGUY

### 🐛 Bug Fixes

- external: keep `__toESM` when the importing module is tree-shaken (#10516) by @IWANABETHATGUY
- dev: resolve re-exports from externals through a real import (#10489) by @tbvjaos510
- code-splitting: route CJS barrel initialization per consumer (#10488) by @hyfdev
- error: align filename-pattern diagnostics with Rollup's wording (#10501) by @IWANABETHATGUY
- plugin: validate emitted prebuilt-chunk file names (#10399) by @IWANABETHATGUY
- code-splitting: point a two-argument dynamic import at the chunk that holds the module (#10479) by @hyfdev
- common: align is_path_fragment with Rollup's isPathFragment (#10398) by @IWANABETHATGUY
- code-splitting: never name an internal chunk export `then` (#10480) by @hyfdev
- code-splitting: avoid creating call-site-triggered entry facades (#10485) by @hyfdev
- code-splitting: collect top-level eager order reasons in every strict build (#10463) by @hyfdev
- code-splitting: let a cross-chunk dynamic importer carry the order trigger (#10456) by @hyfdev
- code-splitting: avoid the dynamic-entry facade when the same-chunk collapse carries the trigger (#10433) by @hyfdev
- binding: forward resolveId options.kind to callable builtin plugins (#10440) by @martijnwalraven
- dev: keep the export name of `export * as ns from` (#10476) by @tbvjaos510
- code-splitting: only split an entry facade when something else can load its chunk (#10441) by @hyfdev
- code-splitting: fold the runtime chunk back after order lowering (#10414) by @hyfdev
- runtime: don't leave default undefined for cjs that fakes __esModule (#10453) by @IWANABETHATGUY
- import-glob: escape generated string literals (#10438) by @shantanuraj
- preserve-modules: don't assume every chunk mirrors a module (#10442) by @hyfdev
- filter: treat missing hook inputs as non-matches, not panics (#10443) by @IWANABETHATGUY
- code-splitting: keep CommonJS modules wrapped under strict execution order (#10405) by @hyfdev
- code-splitting: align dynamicImports metadata with the rewritten import() specifier (#10430) by @hyfdev
- dev: skip user plugin hooks for ?rolldown-lazy proxy modules (#10426) by @unknownjedi
- treeshake: preserve side-effect-free spread arguments in manual-pure chains (#10432) by @IWANABETHATGUY
- treeshake: preserve eagerly evaluated child effects of manual pure chains (#10427) by @Nic-Polumeyv
- code-splitting: initialize pure definers behind star re-export barrels under strict execution order (#10409) by @hyfdev
- resolveId: reject string `id` filters (must be a RegExp) (#10412) by @IWANABETHATGUY
- code-splitting: collect eager order reasons for on-demand wrapping (#10387) by @hyfdev
- rolldown: apply output.paths to CJS export-star of external modules (#10406) by @IWANABETHATGUY
- dev: sourcemaps of lazily compiled chunks (#10386) by @tbvjaos510
- plugin: validate emitted file names at emitFile time (#10377) by @Nic-Polumeyv
- guarantee tokio runtime release when close rejects (#10381) by @shulaoda
- code-splitting: make strict transitive init registration deterministic and constant-time (#10320) by @hyfdev
- pair tokio runtime acquire and release on wasm to prevent premature shutdown (#10363) by @shulaoda
- don't body-demand modules from simulated facade chunk includes (#10351) by @IWANABETHATGUY
- tracing: invalid RD_LOG filter and RD_LOG_OUTPUT=json no longer panic (#10343) by @Brooooooklyn
- code-splitting: treat class definition-time global reads as order-sensitive (#10322) by @hyfdev
- code-splitting: deconflict force-included runtime helper statements (#10336) by @hyfdev
- binding: forward all missing parallel JS plugin hooks (#10345) by @Brooooooklyn
- code-splitting: re-derive chunk exec order after the runtime sweep (#10334) by @hyfdev
- types: add undefined to ExistingRawSourceMap optional properties (#10355) by @ocavue
- magic-string: validate relocate ranges before rewiring (#10327) by @IWANABETHATGUY
- add EMPTY_IMPORT_META warning for non-node CJS output (#10222) by @sapphi-red
- call `resolveFileUrl` in a deterministic order (#10330) by @sapphi-red
- magic-string: refuse repeated sendMagicString on a consumed instance (#10331) by @IWANABETHATGUY
- magic-string: refuse to use a MagicString after sendMagicString consumed it (#10326) by @IWANABETHATGUY
- magic-string: reject non-contiguous moves before rewiring the chunk list (#10311) by @IWANABETHATGUY
- handle `./foo/bar` glob pattern the same as `foo/bar` (#10313) by @sapphi-red
- magic-string: throw instead of panicking when append/prepend splits an edited chunk (#10301) by @IWANABETHATGUY
- output: skip separator for empty hoisted functions (#10310) by @hyfdev
- magic-string: don't report a change when edits cancel out (#10299) by @IWANABETHATGUY
- sourcemap: map wrapped imported callees (#10288) by @hyfdev
- magic-string: count positional inserts at index 0 on an empty source (#10306) by @IWANABETHATGUY
- magic-string: return UTF-16 code units from length() (#10295) by @IWANABETHATGUY
- output: skip separator for empty import prelude (#10289) by @hyfdev

### 🚜 Refactor

- dev: make it easier to customize the runtime (#10338) by @sapphi-red
- code-splitting: declare CJS carrier namespaces initializer-free (#10513) by @hyfdev
- rollup-tests: avoid relying on `NODE_PATH` env var resolution (#10496) by @sapphi-red
- code-splitting: derive symbol chunk ownership as pass-local link data (#10449) by @hyfdev
- plugin: share asset emission helpers between copy_module and asset_module (#10450) by @Nic-Polumeyv
- plugin: dedupe hook binding boilerplate (#10428) by @Nic-Polumeyv
- plugin: share the oxc parse preamble between import-glob and dynamic-import-vars (#10452) by @Nic-Polumeyv
- implement `GetAstBuilder` on visitor/pass types (#10424) by @overlookmotel
- pass arrays to AST builder methods (#10419) by @overlookmotel
- shorten AST builder code (#10418) by @overlookmotel
- centralize final ESM init metadata (#10376) by @hyfdev
- descriptor-based parallel-plugin detection (getParallelPluginInfo) (#10349) by @Brooooooklyn
- remove AstFactory in favor of new_* construction traits (#10353) by @Boshen
- enable oxc_ast's `disable_old_builder` feature (#10316) by @Boshen

### 📚 Documentation

- development-guide: update config.json link line reference (#10523) by @dogledogle
- clarify slash normalization for id hook filter (#10511) by @sapphi-red
- code-splitting: record the thenable-namespace rule (#10502) by @hyfdev
- clarify that `esmExternalRequirePlugin` must own its externals (#10439) by @TheAlexLichter
- add troubleshooting entry for the @rolldown/binding-... resolution error (#10390) by @Nic-Polumeyv
- add Code Splitting API reference category (#10382) by @vittorioexp

### ⚡ Performance

- use VisitJsMut in JavaScript-only AST passes (#10507) by @Boshen
- cache the resolved glob matcher for Id/ImporterId filters (#10410) by @IWANABETHATGUY
- scope_hoisting: remove `alloc` field from `ScopeHoistingFinalizer` (#10425) by @overlookmotel
- reduce string allocations (#10423) by @overlookmotel
- hmr: remove unnecessary string allocations (#10422) by @overlookmotel
- avoid allocating static strings via custom builder methods (#10421) by @overlookmotel
- pass string literals to AST builder methods (#10420) by @overlookmotel
- use VisitJs in JavaScript-only AST passes (#10396) by @Boshen
- plugin: shrink erased plugin debug vtables (#10370) by @Boshen
- reuse normalized path buffers (#10315) by @hyfdev

### 🧪 Testing

- code-splitting: pin CJS barrel fallback triggers and flag-off equivalence (#10514) by @hyfdev
- plugin: cover chunk fileName, absolute chunk name, and Windows drive names (#10400) by @IWANABETHATGUY
- code-splitting: cover a single-chunk dynamic import of a wrapped module (#10505) by @hyfdev
- file: remove the unused .dynamic_import fixture (#10481) by @hyfdev
- treeshake: reduce manual-pure fixture to a minimal smoke test, move matrix to unit tests (#10436) by @IWANABETHATGUY
- dev: run vite playgrounds under bundled dev (test-serve-bundled) (#10434) by @h-a-n-a
- stop snapshots from silently hiding user code inside the runtime region (#10431) by @hyfdev
- wasi: add tokio runtime lifecycle regression test (#10379) by @shulaoda
- dev: expect preserved hot.data in hmr-whole-chain-dispose (#10380) by @h-a-n-a
- code-splitting: pin flag-off wrapped-esm init emission (#10324) by @hyfdev
- sourcemap: fix Windows-only failures in composition fixtures (#10368) by @shulaoda
- generated-code: mark assert external in symbols_ns2 for deterministic output (#10339) by @hyfdev
- code-splitting: cover entries-aware strict init cycle (#10307) by @hyfdev
- make `just setup-vite` the only entry point that touches `vite/` (#10332) by @shulaoda
- vite-tests: reuse the shared root vite checkout (#10325) by @shulaoda
- test-dev-server: drop the vite submodule, track rolldown-canary (#10319) by @shulaoda
- vite-tests: track the latest rolldown-canary rebased onto vite main (#10318) by @shulaoda
- unify Vite in vite-test and test-dev-server (#10293) by @h-a-n-a

### ⚙️ Miscellaneous Tasks

- scope the binding artifact download to `bindings-*` (#10525) by @shulaoda
- deps: update napi (#10506) by @renovate[bot]
- deps: update rollup submodule for tests to v4.62.3 (#10494) by @rolldown-guard[bot]
- deps: upgrade oxc to 0.142.0 (#10497) by @shulaoda
- deps: update test262 submodule for tests (#10495) by @rolldown-guard[bot]
- deps: update github actions (#10460) by @renovate[bot]
- deps: update rust crates (#10462) by @renovate[bot]
- deps: update npm packages (#10461) by @renovate[bot]
- metric: alert Discord when the metric workflow fails (#10447) by @IWANABETHATGUY
- metric: mint a short-lived GitHub App token instead of a PAT (#10446) by @IWANABETHATGUY
- repo: repair dangling CLAUDE.md symlink (#10451) by @hanayashiki
- publint/package-metadata fixes and small correctness fixes (#10344) by @Brooooooklyn
- deps: update dependency vite-plus to v0.2.6 (#10404) by @renovate[bot]
- add Semgrep scan workflow (#10395) by @Boshen
- enable Windows CI with a PR label (#10375) by @hyfdev
- deps: upgrade oxc to 0.141.0 (#10373) by @camc314
- deps: update napi (#10369) by @renovate[bot]
- deps: update test262 submodule for tests (#10367) by @rolldown-guard[bot]
- deps: update taiki-e/install-action action to v2.83.3 (#10358) by @renovate[bot]
- deps: update rust crates (#10357) by @renovate[bot]
- deps: update npm packages (#10359) by @renovate[bot]
- deps: update rust crate syn to v3 (#10362) by @renovate[bot]
- deps: update rust crate oxc_sourcemap to v8.1.2 (#10356) by @renovate[bot]
- deps: update dependency vite-plus to v0.2.5 (#10329) by @renovate[bot]
- docs: migrate Netlify redirects to Void config (#10282) by @tux-tn
- deps: update dependency rust to v1.97.1 (#10317) by @renovate[bot]
- runtime: remove unused `runtime/index.js` (#10302) by @IWANABETHATGUY

### ❤️ New Contributors

* @dogledogle made their first contribution in [#10523](#10523)
* @tbvjaos510 made their first contribution in [#10489](#10489)
* @martijnwalraven made their first contribution in [#10440](#10440)
* @shantanuraj made their first contribution in [#10438](#10438)
* @Nic-Polumeyv made their first contribution in [#10450](#10450)
* @hanayashiki made their first contribution in [#10451](#10451)
* @unknownjedi made their first contribution in [#10426](#10426)
* @vittorioexp made their first contribution in [#10382](#10382)
* @tux-tn made their first contribution in [#10282](#10282)

Co-authored-by: shulaoda <[email protected]>
graphite-app Bot pushed a commit that referenced this pull request Jul 31, 2026
…he order-wrap plan is empty (#10544)

With `strictExecutionOrder`, a CJS multi-entry build whose entries `require()` ESM forwarders into one shared re-export-only barrel over CJS leaves emits chunks that `require()` each other in a cycle and crash at startup:

```
TypeError: require_barrel.init_barrel is not a function
```

Fixes #10515. Regression from #10488, shipped in v1.2.1.

## Problem

Consumer-local re-export routing is computed in three places: the pre-chunk placement probe, the on-demand projector probes, and real lowering. The probes run `consumer_local_reexport_plan` unconditionally, and its eligibility never reads the order-wrap plan — but real lowering sits behind the `plan.is_empty()` short-circuit in `apply_order_wraps`.

When every reachable ESM module is already interop-wrapped (the CJS entries `require()` the forwarders), the order-wrap plan is empty. Chunk placement has already routed each barrel leaf to only its consuming entry's chunk, while emission keeps the barrel's monolithic interop body referencing the per-entry `require_*` wrappers — so the emitted chunks require each other in a startup cycle.

The on-demand carrier force-add cannot rescue this: an interop-wrapped barrel never passes `is_order_wrap_eligible`, so the final plan can stay empty even when the wrap-all plan is not. That also rules out fixing this on the probe side — the probe runs before chunking, while the on-demand plan is only computed from the chunk graph afterwards.

## Fix

Compute the consumer-local plan before the short-circuit and take the fast path only when both the order-wrap plan and the consumer-local plan are empty. Real lowering then materializes exactly the routes placement consumed, in both strict modes, and `lower_order_state` receives the precomputed plan instead of recomputing it.

One exception keeps an existing contract: with code splitting disabled and at most one entry, placement has a single reachability bit, so the probe's routes moved nothing, and an inert on-demand plan keeps its promise of flag-off-equivalent output (pinned by `cjs_reexport_barrel_code_splitting_disabled` from #10514). The disabled option alone is not a sufficient key — only dynamic entries are dropped in disabled mode, so a plugin-emitted chunk still adds a second entry whose per-entry placement consumes the probe's routes — hence the exception is keyed on entry count as well.

## Test

- `cjs_reexport_barrel_probe_plan_divergence`: the seven-file reproduction from #10515, wrap-all + on-demand variants. Crashes on current `main`, passes with the fix; the barrel becomes an empty routing waypoint and each entry initializes only its own leaf through a per-record memoized carrier.
- `cjs_reexport_barrel_on_demand_inert_plan`: adds a plain-ESM third entry so the wrap-all plan is non-empty while the on-demand plan stays empty — the shape a probe-side gate could not fix. On current `main` the wrap-all variant passes and the on-demand variant crashes; both pass with the fix.
- No existing snapshot changes — every previously covered configuration emits byte-identical output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants