Skip to content

feat: experimental inlineCommonChunks support - #10899

Merged
hyfdev merged 7 commits into
fix/chunk-exec-order-after-runtime-evictionfrom
feat/experimental-inline-common-chunks
Sep 30, 2026
Merged

hyfdev merged 7 commits into
fix/chunk-exec-order-after-runtime-evictionfrom
feat/experimental-inline-common-chunks

Conversation

@hyfdev

@hyfdev hyfdev commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

How to use

For an application with ESM output, enable it in your Rolldown configuration:

// rolldown.config.mjs
import { defineConfig } from 'rolldown';

export default defineConfig({
  input: 'src/main.js',
  output: {
    dir: 'dist',
    format: 'es',
    preserveEntrySignatures: false,
    codeSplitting: {
      experimentalInlineCommonChunks: {
        // Inline eligible common chunks whose transformed source size is smaller than 10 KiB.
        maxSize: 10 * 1024,
      },
    },
  },
});
  • maxSize is measured in bytes of transformed source, summed across a common chunk.
  • The 10 KiB value above is an example starting point; tune it based on your application's loading results.

Concrete behaviors

Two entries importing shared.js, built with experimentalInlineCommonChunks.maxSize: 4096:

Before (three files; both entries import the third):

// 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:

// 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

See RFC (#10693)

@netlify

netlify Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

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

@hyfdev
hyfdev force-pushed the feat/experimental-inline-common-chunks branch from 2ce9ea5 to cb9f3af Compare September 27, 2026 03:56
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://feat-experimental-inline-common-chunks-rolldown-rs.voidzero-docs.workers.dev (commit 9da34f0)

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://b85b8c2e-rolldown-rs.voidzero-docs.workers.dev 9da34f0 2026-09-30T12:48:38.699Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://22885ac0-rolldown-rs.voidzero-docs.workers.dev 08e3943 2026-09-30T12:42:23.777Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://52c264d3-rolldown-rs.voidzero-docs.workers.dev 7197a0b 2026-09-30T10:37:21.607Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://70fde621-rolldown-rs.voidzero-docs.workers.dev 0ee1f62 2026-09-30T05:26:33.860Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f0ad193c-rolldown-rs.voidzero-docs.workers.dev 11f5d00 2026-09-28T05:33:19.335Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://fd31b921-rolldown-rs.voidzero-docs.workers.dev 715c8fb 2026-09-28T02:47:55.240Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://3b40778a-rolldown-rs.voidzero-docs.workers.dev 2ea31b6 2026-09-27T12:34:17.538Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://e32e9c03-rolldown-rs.voidzero-docs.workers.dev 619b07c 2026-09-27T08:57:09.465Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://9bdd5b45-rolldown-rs.voidzero-docs.workers.dev 6d8c3da 2026-09-27T04:58:24.169Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://c41264b8-rolldown-rs.voidzero-docs.workers.dev cb9f3af 2026-09-27T03:58:29.572Z Visit the dashboard ↗

@hyfdev hyfdev changed the title feat: experimental inlineCommonChunks support (claude) feat: experimental inlineCommonChunks support Sep 27, 2026
@hyfdev
hyfdev changed the base branch from main to fix/chunk-exec-order-after-runtime-eviction September 27, 2026 03:57
@hyfdev
hyfdev added this pull request to stack #11006 September 27, 2026 03:57
@hyfdev
hyfdev force-pushed the feat/experimental-inline-common-chunks branch from cb9f3af to 6d8c3da Compare September 27, 2026 04:56

This comment has been minimized.

@hyfdev
hyfdev force-pushed the feat/experimental-inline-common-chunks branch 4 times, most recently from 715c8fb to 11f5d00 Compare September 28, 2026 05:30
@hyfdev
hyfdev marked this pull request as ready for review September 30, 2026 02:39
Copilot AI balanced review requested due to automatic review settings September 30, 2026 02:39

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 review overview

🔵 Needs a closer look

It changes chunk-graph ownership, naming, rendering, and runtime execution semantics, while browser integration, watch mode, and minified source maps still require human validation.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds experimental inlining of eligible common chunks into carrier files through shared runtime factories, reducing requests while preserving module semantics.

Changes:

  • Adds chunk selection, placement, finalization, rendering, and runtime registry support.
  • Exposes and validates the option across Rust, bindings, and TypeScript.
  • Adds extensive fixtures, differential tests, fuzzing, and internal documentation.
File Description
crates/​rolldown/​src/​ast_scanner/​impl_visit.rs Tracks import.meta usage.
crates/​rolldown/​src/​ecmascript/​ecma_generator.rs Integrates record rendering.
crates/​rolldown/​src/​ecmascript/​format/​esm.rs Emits ESM record factories.
crates/​rolldown/​src/​ecmascript/​format/​mod.rs Registers the new formatter.
crates/​rolldown/​src/​ecmascript/​format/​share_factory.rs Renders factories and bridges.
crates/​rolldown/​src/​module_finalizers/​finalizer_context.rs Supplies record finalization state.
crates/​rolldown/​src/​module_finalizers/​impl_visit_mut.rs Rewrites bridged references.
crates/​rolldown/​src/​module_finalizers/​mod.rs Guards and resolves bridged symbols.
crates/​rolldown/​src/​runtime/​runtime-base.js Implements the shared registry.
crates/​rolldown/​src/​stages/​generate_stage/​chunk_optimizer.rs Accounts for record eligibility.
crates/​rolldown/​src/​stages/​generate_stage/​compute_cross_chunk_links.rs Separates link derivation and commit.
crates/​rolldown/​src/​stages/​generate_stage/​detect_ineffective_dynamic_imports.rs Preserves dynamic-import constraints.
crates/​rolldown/​src/​stages/​generate_stage/​finalize_modules.rs Finalizes carrier-specific copies.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​callee_guard.rs Validates bridged call forms.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​exclude.rs Applies exclusion matchers.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​finalize.rs Finalizes copied record ASTs.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​mod.rs Defines feature state and IDs.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​naming.rs Builds per-carrier naming inputs.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​place.rs Computes factory placement.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​rewire.rs Projects record dependencies.
crates/​rolldown/​src/​stages/​generate_stage/​inline_common_chunks/​select.rs Selects eligible common chunks.
crates/​rolldown/​src/​stages/​generate_stage/​manual_code_splitting.rs Integrates exclusion callbacks.
crates/​rolldown/​src/​stages/​generate_stage/​mod.rs Adds the feature pipeline.
crates/​rolldown/​src/​stages/​generate_stage/​order_wrap_state.rs Supports wrapped record modules.
crates/​rolldown/​src/​stages/​generate_stage/​render_chunk_to_assets.rs Includes copied modules in metadata.
crates/​rolldown/​src/​stages/​generate_stage/​resolve_file_urls.rs Handles carrier-relative output.
crates/​rolldown/​src/​types/​generator.rs Exposes bridge-aware generation state.
crates/​rolldown/​src/​utils/​chunk/​deconflict_chunk_symbols.rs Deconflicts carrier and record names.
crates/​rolldown/​src/​utils/​chunk/​render_chunk_exports.rs Resolves record-backed exports.
crates/​rolldown/​src/​utils/​mod.rs Exports supporting utilities.
crates/​rolldown/​src/​utils/​module_id_matcher.rs Adds reusable module matching.
crates/​rolldown/​src/​utils/​prepare_build_context.rs Validates and normalizes the option.
crates/​rolldown/​src/​utils/​renamer.rs Supports combined naming scopes.
crates/​rolldown_binding/​src/​options/​binding_output_options/​binding_manual_code_splitting_options.rs Adds binding option types.
crates/​rolldown_binding/​src/​utils/​normalize_binding_options.rs Normalizes binding matchers.
crates/​rolldown_common/​src/​ecmascript/​ecma_view.rs Records relevant AST usage.
crates/​rolldown_common/​src/​generated/​runtime_helper.rs Registers new runtime helpers.
crates/​rolldown_common/​src/​inner_bundler_options/​types/​inline_common_chunks_options.rs Defines core options.
crates/​rolldown_common/​src/​inner_bundler_options/​types/​manual_code_splitting_options.rs Nests the feature option.
crates/​rolldown_common/​src/​inner_bundler_options/​types/​mod.rs Exports option types.
crates/​rolldown_common/​src/​inner_bundler_options/​types/​normalized_bundler_options.rs Stores normalized settings.
crates/​rolldown_common/​src/​lib.rs Re-exports feature types.
crates/​rolldown_error/​src/​build_diagnostic/​events/​invalid_option.rs Adds configuration diagnostics.
crates/​rolldown_testing/​_config.schema.json Adds fixture schema support.
internal-docs/​code-splitting/​implementation.md Updates pipeline documentation.
internal-docs/​inline-common-chunks/​design.md Documents semantics and tradeoffs.
internal-docs/​inline-common-chunks/​implementation.md Documents implementation invariants.
internal-docs/​runtime-helpers/​implementation.md Documents registry helpers.
packages/​rolldown/​src/​binding.d.cts Updates generated binding declarations.
packages/​rolldown/​src/​index.ts Exports the public option.
packages/​rolldown/​src/​options/​output-options.ts Defines the TypeScript API.
packages/​rolldown/​src/​rolldown-binding.wasi.d.cts Updates WASI declarations.
packages/​rolldown/​src/​utils/​bindingify-output-options.ts Converts matchers for bindings.
packages/​rolldown/​src/​utils/​validator.ts Validates the public option.
packages/​rolldown/​tests/​behaviors/​inline-common-chunks/​inline-common-chunks-fuzz.test.ts Differentially tests generated graphs.
packages/​rolldown/​tests/​behaviors/​inline-common-chunks/​inline-common-chunks.test.ts Tests behavior and selection rules.
packages/​rolldown/​tests/​behaviors/​inline-common-chunks/​registry.test.ts Tests registry states.
packages/​rolldown/​tests/​behaviors/​inline-common-chunks/​run-root.mjs Runs isolated test roots.
packages/​rolldown/​tests/​src/​inline-common-chunks/​fuzz.ts Generates deterministic graphs.
packages/​rolldown/​tests/​src/​inline-common-chunks/​harness.ts Provides differential-test utilities.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​basic/​* Tests basic factory output.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​call_forms/​* Tests bridged call semantics.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​carrier_names_collide/​* Tests naming collisions.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​carrier_shadows_record_global/​* Tests global-name shadowing.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​cjs_member/​* Tests CommonJS members.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​cycle_in_record_from_x/​* Tests record cycles.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​dynamic_entry_reader/​* Tests dynamic-entry readers.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​errors/​dev_mode/​* Tests dev-mode rejection.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​errors/​max_size_negative/​* Tests size validation.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​errors/​preserve_entry_signatures_missing/​* Tests signature preconditions.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​errors/​strict_execution_order_false/​* Tests execution-order rejection.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​inherited_from_dependency/​* Tests inherited registration.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​inherited_through_projection/​* Tests projected inheritance.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​kept_as_file/​dynamic_import_member/​* Keeps dynamic-import members as files.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​kept_as_file/​emitted_asset_member/​* Keeps asset modules as files.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​kept_as_file/​entry_module_host/​* Keeps entry hosts as files.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​kept_as_file/​reexported_by_dynamic_entry/​* Keeps re-exported chunks as files.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​kept_as_file/​static_cycle_with_file/​* Keeps file-cycle chunks emitted.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​minify/​* Tests minified output.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​record_imports_file/​* Tests record-to-file imports.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​record_reads_global_exports/​* Tests global export reads.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​record_reads_record/​* Tests record dependencies.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​sourcemap/​* Tests source maps.
crates/​rolldown/​tests/​rolldown/​function/​inline_common_chunks/​two_records_share_import/​* Tests shared imports between records.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codspeed

codspeed Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing feat/experimental-inline-common-chunks (9da34f0) with fix/chunk-exec-order-after-runtime-eviction (130a3bc)2

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

  2. No successful run was found on fix/chunk-exec-order-after-runtime-eviction (3ff6b79) during the generation of this report, so 1052147 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@hyfdev
hyfdev force-pushed the feat/experimental-inline-common-chunks branch from 7197a0b to 08e3943 Compare September 30, 2026 12:39
`experimentalInlineCommonChunks: { maxSize, exclude }` is an experimental
output option. `maxSize`, a non-negative safe integer that defaults to 0, is
the source-size limit under which a common chunk becomes a registry record
printed into the files that read it (unless a static dependency outside a
file's import cycle already prints it); 0 is the same as leaving the option out.
`exclude` takes a string, a RegExp, a function, or an array of them, and
keeps a chunk as a file when any of its modules matches. A build with
`maxSize > 0` requires ESM output, code splitting and
`preserveEntrySignatures: false`; it turns on `strictExecutionOrder` when
that option is omitted, and reports `strictExecutionOrder: false`,
`preserveModules`, `experimental.devMode`, `experimental.onDemandWrapping`
and a set `intro` or `outro` as configuration errors. The option is
exposed on the binding and the JS API with `@experimental` types.
`__share(id, factory)` records a factory under an id unless one is already
registered; the first registration wins and registering never runs the
factory. `__share_require(id)` runs the factory on first use with a fresh
exports object, returns that object on every later call, returns the
partially filled object to a nested require of the same id, rethrows the
value a failed factory threw (including `undefined` and `null`) on every
later call, and throws for an id nothing registered. `__share_export`
defines live getters on the exports object. The generated helper flags
follow the runtime source.
With `experimentalInlineCommonChunks` on, the generate stage derives the
final cross-chunk links, selects the common chunks that stop being files
(records), computes which files print their factories, registers the
registry's runtime demand on those files, derives the links once more and
commits them; the record edges are then projected onto files. A record stays
a live chunk that is never named as a file, finalized in place, rendered on
its own or instantiated. A file that reads a record prints, right after its
imports, the factory of that record and of every record it reads
transitively, minus the factories a static dependency outside the file's
import cycle already registers (a dependency the file imports once records
are expanded into their importees), and obtains the exports through `var
share_x = __share_require(id)`. Each carrier finalizes and prints its own
copy of a record's modules on a clone of their ASTs with the carrier's
names, so a file's names come from one renamer and its imports from one
table. References to a record's symbols become bridge members, and every
callee read through a bridge is printed as `(0, share_x.f)` so `this` stays
undefined, except the module wrappers `init_*`/`require_*`, which never read
`this`; any other bare bridge callee left in a finalized module or record
copy fails the build, from whichever carrier's copy it comes. 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 that keeps
its name keeps its bytes; it does not tell two builds apart, and files of
two builds meeting in one page under one runtime file are not supported. The
name does not go through `sanitizeFileName`. A file keeps its import order
and expands each record it reads in place, so the files behind a record,
externals included, evaluate in the order they do with the option off. The
runtime chunk stays standalone while the option is on, and `import.meta` use
is a scan-time flag on the module.

Candidates are rejected rather than special-cased: entry chunks and entry
hosts, manual groups, dynamic-import targets, chunks re-exported elsewhere
or read by direct eval, members with external, unresolved, dynamic or
unsupported imports, top-level await, `import.meta`, an emitted asset, no
wrapper or an `exclude` match, chunks in a static import cycle with a file,
chunks a file with a direct `eval` module would print, and chunks not under
`maxSize`. The placement computed at selection must equal the one recomputed
from the committed edges, which leaves every record with a carrier, and no
file may import a record after projection; both are asserted.

See internal-docs/inline-common-chunks/.
Rust fixtures under
`crates/rolldown/tests/rolldown/function/inline_common_chunks/` pin the
output shape of the behaviours (records reading records, cycles, CommonJS
members, plain, optional, member and tagged-template calls and `new`,
minify, sourcemap, name collisions, inheritance from a static dependency and
through a dependency a record exposes after projection, globals a record
reads that a carrier declares), five kept-as-file shapes and the
configuration errors; four of them also snapshot the option-off build
through a `codeSplitting` config variant. The Node suite under
`packages/rolldown/tests/behaviors/inline-common-chunks/` builds every
differential case with the option off and on, runs each entry and dynamic
entry as a root in a fresh Node process, and compares logs, exports,
identities and errors; it checks that every `__share_require(id)` follows a
registration of `id` in the same file or in a static dependency outside the
file's cycle, covers fourteen selection rules, every precondition the JS API
lets through (`experimental.devMode` is rejected before validation, so only
a Rust fixture reaches its error), option combinations, plugin hooks, `this`
in every call form including functions marked `__NO_SIDE_EFFECTS__`,
external import order, assignments to a CommonJS default export's
properties, a lazy route re-exporting a CommonJS binding, a record id that
follows the module set rather than the code, and an edit inside one carrier
that must leave the record id and the other hashed files alone, tests the
registry helpers from `runtime-base.js` directly, and adds a seeded
generator of module graphs and output option sets, each graph compared root
by root and pair by pair.
`internal-docs/inline-common-chunks/design.md` states the contract, the
principles, the selection rules, the rejected alternatives and the open
questions, citing the RFC and backlog decisions; `implementation.md` walks
the pipeline position, the state, selection, placement, projection, naming,
finalization, rendering, tests and invariants. The code-splitting and
runtime-helpers documents gain the paragraphs the feature touches.
@hyfdev
hyfdev force-pushed the feat/experimental-inline-common-chunks branch from 08e3943 to 9da34f0 Compare September 30, 2026 12:45
@hyfdev
hyfdev merged commit bad4b6e into main Sep 30, 2026
37 of 41 checks passed
@hyfdev
hyfdev deleted the feat/experimental-inline-common-chunks branch September 30, 2026 13:00
hyfdev added a commit that referenced this pull request Sep 30, 2026
… code in lazy chunks (#11034)

With common-chunk inlining enabled, shared loaders can remain separate
files, and lazy chunks can include shared code already supplied by their
importers. This PR inlines eligible shared loaders containing resolved
internal `import()` calls and omits redundant copies when every entry
loading path provides the shared module.

For an entry that uses a shared module and dynamically loads a second
reader:

```js
// main.js
import { state } from './shared.js';
console.log(state);
globalThis.load = () => import('./lazy.js');

// lazy.js
import { state } from './shared.js';
console.log(state);
```

Before, the shared module is merged with the entry's implementation,
leaving a separate file to start the entry. Simplified output:

```text
main.js          starts the entry
main-impl.js     main + shared
lazy.js          lazy, importing shared from main-impl
runtime.js
```

After:

```text
main.js          main + shared factory
lazy.js          lazy, reading shared from the runtime
runtime.js
```

## Changes

- Allow common chunks containing resolved internal dynamic imports to be
inlined. Each output file containing a copy gets the correct relative
import path, dynamic-import metadata and target hash dependency.
Computed and ignored imports stay in their own file to preserve relative
resolution.
- Apply the `import.meta` restriction only to statements retained by
tree-shaking. An unused function or initializer containing `import.meta`
does not keep an otherwise eligible common chunk as a file.
- Keep eligible shared code separate during the earlier entry assignment
and merging steps, so the inline pass can remove the common file rather
than leave shared code inside an entry implementation chunk.
- Omit a shared factory only when every loading path from configured or
plugin-emitted entries has registered it. Intersect multiple parents,
include imports in every possible copy of a shared loader, and treat an
unknown dynamic target as potentially reaching any output file. A lazy
chunk retains its copy if a parent cannot provide the shared module.
- Accept `maxSize: Infinity` as an unlimited threshold.

With two independent entries that each provide the shared module before
loading the same lazy chunk, the shared factory count falls from three
to two. Module initialization and shared state remain common to all
readers.

## Validation

- 111 feature tests, 17 placement unit tests and 300 generated module
graphs passed. Coverage includes copied loaders in different
directories, target hash changes, discarded `import.meta`, missing and
unknown parents, nested imports, entry roots and minified output.
- `just test-rust`, `just t-node` and `just lint` passed.

Stacked on #10899.
@rolldown-guard rolldown-guard Bot mentioned this pull request Sep 30, 2026
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]>
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