Repository navigation
fix(@angular/build): consolidate initial shared chunks into main with Rolldown - #34408
Merged
alan-agius4 merged 1 commit intoOct 20, 2026
Merged
Conversation
… 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.
clydin
force-pushed
the
fix/rolldown-initial-chunk-consolidation
branch
from
October 20, 2026 13:16
d6d8b8f to
9aec53b
Compare
clydin
marked this pull request as ready for review
October 20, 2026 13:18
There was a problem hiding this comment.
Code Review
This pull request optimizes chunking in the Angular application builder when using Rolldown by consolidating initial shared modules into the main chunk and adding a fallback mechanism to handle top-level await (TLA) scenarios. Corresponding integration tests have also been added. Regarding the review feedback, there is a potential runtime TypeError when checking for empty entry facades, as chunk.modules can be undefined and should be accessed safely using optional chaining or a nullish coalescing operator.
Collaborator
|
This PR was merged into the repository. The changes were merged into the following branches:
|
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.
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.