Skip to content

feat(@angular/build): enable chunk optimization for server builds#33602

Open
jsaguet wants to merge 1 commit into
angular:mainfrom
jsaguet:feat/enable-server-optimizer
Open

feat(@angular/build): enable chunk optimization for server builds#33602
jsaguet wants to merge 1 commit into
angular:mainfrom
jsaguet:feat/enable-server-optimizer

Conversation

@jsaguet

@jsaguet jsaguet commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

The chunk optimization pass was disabled when a server entry point was present due to a concern that renamed browser chunks would cause incorrect preloading. The preload metadata (route tree preload arrays and entryPointToBrowserMapping in the server app manifest) is generated after the optimization pass from the optimized metafile, so renamed and merged chunks stay consistent with the emitted files.

A behavior test now asserts that the server manifest only references browser chunks that exist after optimization and that every lazy route retains its entry point mapping. The server-routes-preload-links e2e test now verifies that every route of an optimized build emits preload links that resolve successfully, instead of only checking the root route.

Fixes #33438

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Chunk optimization is never used for SSR builds.

What is the new behavior?

Chunk optimization is used for SSR builds

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/build labels Jul 19, 2026
@jsaguet
jsaguet marked this pull request as ready for review July 19, 2026 08:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables chunk optimization for server builds by removing the restriction on server entry points during the build execution. It also introduces a new behavior test suite to verify chunk optimization with server entry points and updates existing E2E tests to dynamically validate that preload links are generated and resolve correctly. The review feedback suggests improving the robustness of a regular expression in the new test file by removing a strict trailing comma requirement.

The chunk optimization pass was disabled when a server entry point was
present due to a concern that renamed browser chunks would cause incorrect
preloading. The preload metadata (route tree preload arrays and
entryPointToBrowserMapping in the server app manifest) is generated after
the optimization pass from the optimized metafile, so renamed and merged
chunks stay consistent with the emitted files.

A behavior test now asserts that the server manifest only references
browser chunks that exist after optimization and that every lazy route
retains its entry point mapping. The server-routes-preload-links e2e test
now verifies that every route of an optimized build emits preload links
that resolve successfully, instead of only checking the root route.
@jsaguet
jsaguet force-pushed the feat/enable-server-optimizer branch from 9458788 to 87f0e56 Compare July 19, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable chunk optimizer for SSR apps

1 participant