Skip to content

feat(@angular/build): Support splitting browser and server stats json files for easier consumption#33209

Open
tsteuwer-accesso wants to merge 1 commit into
angular:mainfrom
tsteuwer-accesso:main
Open

feat(@angular/build): Support splitting browser and server stats json files for easier consumption#33209
tsteuwer-accesso wants to merge 1 commit into
angular:mainfrom
tsteuwer-accesso:main

Conversation

@tsteuwer-accesso
Copy link
Copy Markdown

This feature supports splitting out the browser and server stats json files so it's easier to inspect the bundle in various analyzers and addresses #28185 #28671. Today, everything gets dumped into a single file and it's nearly impossible to use without hours of fix -> remove unused browser/server chunks -> analyze and starting the loop all over again.

This feature implements the feature request I made in #28185, along with another developers request to see a stats json file for just the initial page bundle. I've tested this out in my own repository and it's already helped an incredible amount. This will be required to be in the next Major version as it will break any existing build pipeline that relies on a single stats.json file.

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?

When using --stats-json, the CLI outputs a single stats.json file.

Issue Number: #28185

What is the new behavior?

When using --stats-json, the CLI now outputs four separate files:

  • browser-stats.json The full browser stats.json
  • browser-initial-stats.json Just the files that will be delivered on the main request.
  • server-stats.json SSR version
  • server-initial-stats.json SSR version

Does this PR introduce a breaking change?

  • Yes
  • No

If anyone is relying on there being a single stats.json file, then this will break their existing pipelines as there will be four files now and they aren't the same name as before.

Other information

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/build labels May 17, 2026
Copy link
Copy Markdown

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

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 updates the application builder to generate four distinct stats files—browser-stats.json, browser-initial-stats.json, server-stats.json, and server-initial-stats.json—replacing the previous single stats.json output. The changes introduce infrastructure to track separate browser and server metafiles throughout the bundling process and include a new utility to filter these metafiles for initial files. Feedback was provided regarding the browserMetafile reconstruction logic in chunk-optimizer.ts, suggesting an explicit check for input existence to ensure consistency and prevent potential undefined assignments.

Comment thread packages/angular/build/src/builders/application/chunk-optimizer.ts
…files for easier consumption

This feature supports splitting out the browser and server stats json files so it's easier to inspect the bundle in various analyzers and addresses angular#28185 angular#28671. Today, everything gets dumped into a single file and it's nearly impossible to use without hours of `fix -> remove unused browser/server chunks -> analyze` and starting the loop all over again.

This feature implements the feature request I made in angular#28185, along with another developers request to see a stats json file for just the initial page bundle. I've tested this out in my own repository and it's already helped an incredible amount. This will be required to be in the next Major version as it will break any existing build pipeline that relies on a single stats.json file.
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.

1 participant