feat(@angular/build): enable chunk optimization by default with heuristics#32971
Open
clydin wants to merge 2 commits intoangular:mainfrom
Open
feat(@angular/build): enable chunk optimization by default with heuristics#32971clydin wants to merge 2 commits intoangular:mainfrom
clydin wants to merge 2 commits intoangular:mainfrom
Conversation
2ade868 to
ae4b8c3
Compare
This commit transitions the chunk optimization logic in the application builder from the experimental Rolldown bundler to the stable Rollup bundler. Rollup is now used by default, while support for the NG_BUILD_CHUNKS_ROLLDOWN environment variable has been added to allow opting back into Rolldown for testing and debugging. To make Rolldown truly optional for end users, it has been moved from dependencies to devDependencies, and is now loaded via dynamic import only when requested.
ab860cd to
189b33d
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a heuristic-based chunk optimization pass that runs after the initial esbuild bundle. It replaces the previous unconditional optimization with a threshold-based approach (defaulting to 3 lazy chunks) and adds support for using Rollup or Rolldown as the optimization engine. Several improvements were made to the chunk optimizer to handle entry point identification and environment configuration. I have identified a potential issue regarding the removal of the entry point check, a concern about the compatibility of manifest generation with optimized chunks, and a suggestion to improve the robustness of the environment variable parsing.
189b33d to
b1e4260
Compare
…stics Enable the advanced chunk optimization pass by default for applications with multiple lazy chunks to improve loading performance. A heuristic is introduced that automatically triggers this optimization when the build generates 3 or more lazy chunks. Developers can customize this behavior or disable it entirely using the NG_BUILD_OPTIMIZE_CHUNKS environment variable. Setting it to a number adjusts the threshold of lazy chunks required to trigger optimization, while setting it to false disables the feature if issues arise in specific projects.
b1e4260 to
2b8e08d
Compare
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.
Enable the advanced chunk optimization pass by default for applications with multiple lazy chunks to improve loading performance. A heuristic is introduced that automatically triggers this optimization when the build generates 3 or more lazy chunks. Developers can customize this behavior or disable it entirely using the
NG_BUILD_OPTIMIZE_CHUNKSenvironment variable. Setting it to a number adjusts the threshold of lazy chunks required to trigger optimization, while setting it to false disables the feature if issues arise in specific projects.