Repository navigation
fix(chunking): re-derive chunk exec orders after the runtime leaves its host chunk - #11005
Merged
Merged
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A critical unresolved comment identifies a runtime-ordering path that can still place the standalone runtime after user chunks.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes strict execution-order chunk imports after runtime helpers move to a standalone chunk.
Changes:
- Re-derives chunk execution orders after runtime relocation.
- Re-runs on-demand analysis for the corrected layout.
- Adds regression fixtures, snapshots, and documentation.
| File | Change |
|---|---|
internal-docs/code-splitting/implementation.md |
Documents runtime ordering |
crates/rolldown/tests/rolldown/topics/preserve_semantic_of_entries_exports/runtime_merge_respects_preserve_entry_signatures/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/topics/exports/entry_esm_named_named/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/topics/exports/entry_esm_named_default/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/strict_execution_order_invariants/m4_dynamic_facade_race/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/strict_execution_order_invariants/dynamic_import_options/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/tree_shaken_dynamic_importer_keeps_collapse/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/pure_definer_star_barrel_opaque_and_resolved_reads/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/pure_definer_nested_star_barrel_split_readers/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/pure_definer_delegated_breadth_nested_barrels/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/on_demand_wrapping/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/namespace_pure_reexport_barrel/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/manual_group_phantom_dynamic/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/manual_group_interop_cycle/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/z.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/q.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/p.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/e1.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/e0.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/c.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/b.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/artifacts.snap |
Expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/a.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/_test.mjs |
Test definition |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_on_demand/_config.json |
Test configuration |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/z.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/q.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/p.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/e1.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/e0.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/c.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/b.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/artifacts.snap |
Expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/a.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/_test.mjs |
Test definition |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_inert_plan/_config.json |
Test configuration |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/node_modules/ext-b/package.json |
External fixture metadata |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/node_modules/ext-b/index.js |
External evaluation fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/node_modules/ext-a/package.json |
External fixture metadata |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/node_modules/ext-a/index.js |
External evaluation fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/e2.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/e1.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/e0.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/c.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/b.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/artifacts.snap |
Expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/a.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/_test.mjs |
Test definition |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_host_import_order/_config.json |
Test configuration |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/z.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/q.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/p.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/e1.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/e0.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/d.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/c.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/b.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/artifacts.snap |
Expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/a.js |
Regression fixture |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/_test.mjs |
Test definition |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/evicted_runtime_helper_consumer_on_demand/_config.json |
Test configuration |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/esm_dynamic_entry_transitive_external_star_keeps_facade/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cross_chunk_dynamic_importer_uses_call_site_trigger/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_tla_fallback/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_shimmed_export_fallback/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_shared_importee/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_require_fallback/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_namespace_routing/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_external_star_fallback/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_effectful_carrier/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_consumer_local/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_reexport_barrel_cjs_export_star_fallback/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_dynamic_entry_transitive_external_star/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_carrier_pure_value_gap/artifacts.snap |
Updates expected output |
crates/rolldown/tests/rolldown/function/experimental/strict_execution_order/cjs_carrier_gap/artifacts.snap |
Updates expected output |
crates/rolldown/src/stages/generate_stage/order_wrapping.rs |
Re-derives chunk execution orders |
crates/rolldown/src/stages/generate_stage/finalize_chunk_plan.rs |
Re-runs on-demand analysis |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Merging this PR will not alter performance
Comparing Footnotes
|
IWANABETHATGUY
approved these changes
Sep 28, 2026
…ts host chunk Under `strictExecutionOrder`, `ensure_runtime_module_for_order_wraps` moves a runtime module that shares a chunk with user modules onto a standalone chunk before the order wrappers' helper demand is re-proved. The former host kept the `exec_order` it had derived from the runtime module (`exec_order` 0), so the cross-chunk import sort placed it, and the external modules it imports, ahead of chunks that execute before it in source order, while the new runtime chunk sorted last. The chunk orders are now re-derived from each live chunk's lead module right after the move, as `finalize_chunk_plan` already does after the runtime sweep. In the affected snapshots the runtime import moves first; in `manual_group_phantom_dynamic` the entry facade imports `group-0`, whose modules execute first, before `group-l`, the runtime's former host. The new fixture `evicted_runtime_host_import_order` runs the output: an entry that imports `b` before `a` sees the external module behind `b`'s chunk evaluate before the one behind `a`'s chunk, although `a`'s chunk hosted the runtime until the move.
…ts host chunk Eviction changes chunk order and helper-import edges, so on-demand analysis must observe the standalone runtime before selecting wrappers. The entry-facade edge query also needs the runtime placed so it can resolve helper symbols to their chunk. The caller folds the runtime after lowering and facade creation, when `OrderWrapState` contains the complete helper demand and the runtime's consumer set is final.
hyfdev
force-pushed
the
fix/chunk-exec-order-after-runtime-eviction
branch
from
September 30, 2026 12:39
0b1db59 to
130a3bc
Compare
hyfdev
force-pushed
the
fix/chunk-exec-order-after-runtime-eviction
branch
from
September 30, 2026 12:45
130a3bc to
3ff6b79
Compare
hyfdev
added a commit
that referenced
this pull request
Sep 30, 2026
Stacked on #11005. Code splitting writes every module set shared by two entries as a file of its own, so a page with many entries loads one small file per shared chunk. With `output.codeSplitting.experimentalInlineCommonChunks: { maxSize }`, a common chunk under that source size is not written: every file that reads it prints a copy of its modules inside a registered factory, and the copy in the first file to run is the one every file shares. Modules still run once and in source order, and live bindings, `this`, module cycles and CommonJS interop behave as they do with the option off. Two entries importing `shared.js`, built with `maxSize: 4096`: Before (three files; both entries import the third): ```js // a.js import { n as count, r as marker, t as bump } from "./shared.js"; globalThis.events.push("A " + count + " " + bump() + " " + count); globalThis.markers.push(marker); ``` After (two entry files plus the runtime chunk; `b.js` prints the same factory; the `init_*` wrappers come from `strictExecutionOrder`, which the option turns on): ```js // a.js import { i as __share_require, n as __share, r as __share_export, t as __esmMin } from "./rolldown-runtime.js"; __share("shared-ZmCA4nrZ", (exports) => { function bump() { count += 1; return this === void 0 ? "this:undefined" : "this:bound"; } var count, marker; function init_shared() { return (init_shared = __esmMin((() => { globalThis.events.push("S body"); count = 0; marker = { tag: "shared" }; })))(); } __share_export(exports, { i: () => marker, n: () => count, r: () => init_shared, t: () => bump }); }); var share_shared = __share_require("shared-ZmCA4nrZ"); function init_a() { return (init_a = __esmMin((() => { share_shared.r(); globalThis.events.push("A " + share_shared.n + " " + (0, share_shared.t)() + " " + share_shared.n); globalThis.markers.push(share_shared.i); })))(); } init_a(); ``` ## Motivation A large application with route-level entries pays one request per shared chunk on every page; the RFC (#10693) collects the reports. GitLab's frontend (gitlab-org/gitlab) built with this branch, over the 593 distinct sets of files its pages load initially: with a chunk-grouping policy that puts the modules at least 90% of routes load into named chunks, `maxSize: 30720` brings the JavaScript requests per page from a median of 25 (P90 63, max 298) to 10 (P90 18, max 89) and the gzipped bytes per page down by a median of 4.4 KB, at 3.2 MB more gzipped output in total; with GitLab's shipped chunking configuration the median goes from 240 to 133. The measuring harness is not public. ## How it works - Selection runs on the final chunk graph, after the cross-chunk links are derived, so nothing moves a module between chunks afterwards. A common chunk becomes a record when it passes every rule. It stays a file when it is an entry or hosts one, belongs to a manual group, is an emitted chunk, is the target of an `import()`, is re-exported by another chunk, is read by a module with direct `eval` or would be printed into a file holding one, has a member with an external, unresolved, dynamic or otherwise unsupported import, top-level await, direct `eval`, `import.meta` or an emitted asset, is in a static import cycle with a file, matches `exclude`, or is not under `maxSize`; `internal-docs/inline-common-chunks/design.md` lists every rule with its reason. - A file that reads a record prints, right after its imports, a factory for that record and for every record it reads through it, except those a static dependency outside the file's import cycle already registers (a dependency the file imports once records are expanded into their importees), and reads the exports through `__share_require(id)`. `__share(id, factory)` keeps the first registration. `__share_require` runs the factory once, returns the same exports object to every caller (including a nested require from inside the record's own cycle) and rethrows a factory's error on every later call. - Each carrier finalizes its own copy of the record's modules (the pass that renames bindings and rewrites imports for a chunk) with the carrier's names and import table, so a file has one set of names and one list of imports. A read of a record's symbol goes through the exports object (`share_shared.n`), and a call prints as `(0, share_shared.t)()` so `this` stays undefined; a call form that pass does not cover fails the build with a message naming the module. - A record id is the chunk name plus eight hash characters of its module set (the members' stable ids, sorted). It identifies the record within its build and stays the same across builds while the module set does, so a hashed file's name moves only with the file's own content, copies included. Like webpack's module ids, it does not tell two builds apart. - A file keeps its import order and expands each record in place, so the files behind a record, external modules included, evaluate in the order they do with the option off. - Plugins see one `renderChunk` per file; a carrier lists the record's modules after its own in `moduleIds` and in execution order in `modules`, and a record never reaches the file name hooks. ## Preconditions `maxSize > 0` requires ESM output, code splitting and an explicit `preserveEntrySignatures: false`. It turns `strictExecutionOrder` on when that option is omitted, because the factories rely on wrapped modules to keep source order. `strictExecutionOrder: false`, `preserveModules`, `experimental.devMode` and `experimental.onDemandWrapping` are configuration errors. `maxSize: 0`, the default, is byte-identical to leaving the option out. ## Known limits - `maxSize` bounds the duplicated source, not the output: nothing limits how many files print one record, and each copy adds its bytes. - Vite's SSR manifest and CSS code splitting answer "which chunk owns this module" from a chunk's module list and get several answers for a record's modules; Vite's CSS plugin copies a style module's CSS into every carrier's stylesheet. A Vite build passes `exclude: /\.(css|scss|sass|less|styl|stylus|pcss|postcss|sss)(\?|$)/` so chunks holding styles stay files, and Vite does not turn the option on itself. Vite's manifest and modulepreload follow `facadeModuleId`, `imports` and `importedCss`, which see only carriers. - The option turns `strictExecutionOrder` on, and strict execution order has an open issue with top-level await inside static import cycles (#9548); run the application under `strictExecutionOrder: true` before adding the option. - Addons (`banner`, `intro`, `outro` and `footer`), including plugin hooks, apply to emitted files. An inlined chunk shares the addon bindings of the file that registers its factory first. Exclude modules that depend on separate file-local bindings or addon initialization order. - Within one build, the `.name` of a record's function or class depends on which carrier a page runs first; `output.keepNames` pins it. - Files from two builds that import the same runtime chunk URL share one registry, and the first registration of an id serves both; a page loads the output of one build, as with webpack's module registry. `internal-docs/inline-common-chunks/` holds the design and the implementation notes. ## Validation - 24 Rust fixtures under `crates/rolldown/tests/rolldown/function/inline_common_chunks/` pin the output shapes, the kept-as-file cases and the configuration errors; four also snapshot the option-off variant. - The Node suite under `packages/rolldown/tests/behaviors/inline-common-chunks/` builds each case with the option off and on, runs every entry and dynamic entry as a root in a fresh process, and compares logs, exports, identities and errors. It covers the selection rules, the preconditions, plugin hooks, every call form, a record id that follows the module set rather than the code, an edit inside one carrier that must leave the record id and the other hashed files alone (no hook rewrites the factory there), the registry helpers, and a seeded generator of module graphs and option sets (12 seeds per run; `INLINE_COMMON_CHUNKS_FUZZ_SEEDS` raises it, and 800 seeds pass locally). - Outside the repository: this repository's fixtures, each given two or three extra entries so that shared modules become records, built with the option off and on and run entry by entry; 339 and 347 fixtures produce records and all but one match, and in that one (`strict_execution_order/cjs_reexport_barrel_monolithic_esm_namespace`) both builds throw the same `TypeError` and only the quoted expression differs. GitLab's frontend built five times (three chunking policies, `maxSize` 30 KiB or 150 kB): every emitted chunk loads without a registry error, and the most-carried record (73 carriers at 30 KiB, 181 at 150 kB) resolves to one exports object. - Not covered by the tests: a browser loading a real application built with the option; source maps under `minify`; watch mode. - `just test-rust`, `just test-node` and `just lint` pass. Written with Claude Code; I reviewed and verified every change before submission.
Merged
shulaoda
added a commit
that referenced
this pull request
Sep 30, 2026
## [1.2.12] - 2026-09-30 ### 🚀 Features - inline common chunks containing import() and deduplicate shared code in lazy chunks (#11034) by @hyfdev - experimental `inlineCommonChunks` support (#10899) by @hyfdev - dev: ship imported bindings for HMR partial accept (#10856) by @h-a-n-a ### 🐛 Bug Fixes - chunking: re-derive chunk exec orders after the runtime leaves its host chunk (#11005) by @hyfdev - code-splitting: gate member-read init paths on the reading statement (#11039) by @hyfdev - code-splitting: retain initialization paths through re-exported namespaces (#11037) by @hyfdev - dev: reject non-ESM output formats in dev mode (#11038) by @h-a-n-a - dev: align `import.meta.hot.accept` deps with Vite (#10997) by @h-a-n-a - dev: clear the resolver cache when a file is created or deleted (#10986) by @waltuov - error: name the resolved specifier in unresolved import diagnostics (#11014) by @linyiru - make entries-aware chunk merging deterministic (#11002) by @hyfdev - watch: avoid restarting macOS watcher for unchanged paths (#10992) by @sep2 ### 🚜 Refactor - dev: ship the dev runtime entry as one file (#10998) by @h-a-n-a - binding: remove `__internalForcePanic` (#10989) by @IWANABETHATGUY ### 📚 Documentation - fix cloudflare preview builds (#10996) by @sapphi-red - fix build config loader warning (#10994) by @sapphi-red - deps: use Vite 8 (#10993) by @sapphi-red ### ⚡ Performance - dev: only ship rows with dynamic edges in registerGraph (#11019) by @h-a-n-a ### 🧪 Testing - code-splitting: cover more re-exported namespace shapes (#11042) by @hyfdev - webcontainer: cover the WebContainer download fallback in plain Node (#10966) by @shulaoda - dev: pin the runtime entry file layout that Vite serves (#10983) by @h-a-n-a ### ⚙️ Miscellaneous Tasks - pin VOID_API_URL for the docs deploy (#11041) by @shulaoda - opt into the WebContainer smoke test for napi bumps and loader changes (#10967) by @shulaoda - deps: upgrade oxc to 0.152.0 (#11018) by @camc314 - deps: update rust crates (#11012) by @renovate[bot] - deps: update npm packages (#11011) by @renovate[bot] - deps: update crate-ci/typos action to v1.50.3 (#11023) by @renovate[bot] - deps: update test262 submodule for tests (#11022) by @rolldown-guard[bot] - deps: update rollup submodule for tests to v4.63.5 (#11021) by @rolldown-guard[bot] - deps: update dependency vite-plus to v1 (#11017) by @renovate[bot] - deps: update github actions (#11010) by @renovate[bot] - remove `CLAUDE.md` (#10925) by @iiio2 - verify release debug info by matching file IDs (#10988) by @IWANABETHATGUY - deps: update rollup submodule for tests to v4.63.4 (#10940) by @rolldown-guard[bot] ### ❤️ New Contributors * @waltuov made their first contribution in [#10986](#10986) * @linyiru made their first contribution in [#11014](#11014) * @sep2 made their first contribution in [#10992](#10992) Co-authored-by: shulaoda <[email protected]>
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.

Under
strictExecutionOrder, an entry could import its chunks in the wrong order when one of them had hosted the runtime helpers: that chunk, and every external module it imports, came before chunks that execute earlier in source order. Chunk order is now re-derived once the helpers move to a file of their own, so imports follow source order again.An entry that imports
bbeforea, whereareads a namespace and so hosted the runtime helpers until they were moved out:Before (
e0.jsoutput;ext-aevaluates beforeext-b):After (
ext-bevaluates beforeext-a, as in the source):The runtime module is first merged into the only chunk that needs its helpers. When strict execution order then wraps the modules, the helpers are moved to a standalone chunk, but the former host keeps the execution order it derived from the runtime module, which sorts before every user module. The cross-chunk import sort reads that stale order, so the former host lands first and the new runtime chunk last.
Right after the move, every chunk's execution order is derived again from its current first module, as the build already does after it removes a runtime chunk nothing needs. The same refresh applies when order wrapping creates the first runtime chunk, so its imports also sort by the runtime module's execution order.
Validation:
evicted_runtime_host_import_orderruns the output and asserts the log orderext-b, ext-a, B, A c, E0; without the fix it logsext-afirst.requirecalls, with corresponding local renaming in minified output: the runtime chunk's comes first; inmanual_group_phantom_dynamicthe entry facade importsgroup-0, whose modules execute first, beforegroup-l, the runtime's former host.cargo test -p rolldown --test integration: 2020 passed, 68 ignored, with snapshot updates disabled.cargo fmt --all --checkand thevp check --fixcommit hook pass.Written with Claude Code; I reviewed and verified every change before submission.