feat(@angular/build): enable chunk optimization by default with heuristics#32971
feat(@angular/build): enable chunk optimization by default with heuristics#32971alan-agius4 merged 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 PR was merged into the repository. The changes were merged into the following branches:
|
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.