Skip to content

fix(@angular/build): consolidate initial shared chunks into main with Rolldown - #34408

Draft
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/rolldown-initial-chunk-consolidation
Draft

clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/rolldown-initial-chunk-consolidation

Conversation

@clydin

@clydin clydin commented Oct 19, 2026

Copy link
Copy Markdown
Member

When esbuild bundles an application with lazy-loaded routes, modules that are statically reachable from the main entry point and also imported by different subsets of lazy routes are split into separate shared chunks, often forming multi-level import chains from main.js. Previously, the Rollup-based chunk optimization pass recognized that the main entry point is always loaded before any dynamic import can execute and merged all modules in its static closure back into main.js.

After switching chunk optimization to Rolldown, unconfigured Rolldown only merged direct single-hop shared chunks into main.js while leaving deeper initial shared chunks as separate files. Configuring Rolldown with preserveEntrySignatures set to allow-extension and a codeSplitting group targeting the built-in $initial tag restores the consolidation of all initial shared modules into the main entry chunk while keeping lazy-only shared chunks separate.

… Rolldown

When esbuild bundles an application with lazy-loaded routes, modules that are statically
reachable from the main entry point and also imported by different subsets of lazy routes are
split into separate shared chunks, often forming multi-level import chains from main.js.
Previously, the Rollup-based chunk optimization pass recognized that the main entry point is
always loaded before any dynamic import can execute and merged all modules in its static
closure back into main.js.

After switching chunk optimization to Rolldown, unconfigured Rolldown only merged direct
single-hop shared chunks into main.js while leaving deeper initial shared chunks as separate
files. Configuring Rolldown with preserveEntrySignatures set to allow-extension and a
codeSplitting group targeting the built-in $initial tag restores the consolidation of all
initial shared modules into the main entry chunk while keeping lazy-only shared chunks
separate.
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.

1 participant