Skip to content

feat(@angular/build): Support splitting browser and server stats jsonfiles for easier consumption#32631

Closed
tsteuwer-accesso wants to merge 2 commits into
angular:mainfrom
tsteuwer-accesso:main
Closed

feat(@angular/build): Support splitting browser and server stats jsonfiles for easier consumption#32631
tsteuwer-accesso wants to merge 2 commits into
angular:mainfrom
tsteuwer-accesso:main

Conversation

@tsteuwer-accesso

@tsteuwer-accesso tsteuwer-accesso commented Mar 1, 2026

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. 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.

Original closed feature: #32631

Fixes #28185 #28671

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?

We now receive a browser-stats.json, server-stats.json, browser-stats-initial.json and server-stats-initial.json

Does this PR introduce a breaking change?

  • Yes
  • No

This is a breaking change for anyone relying on CI processes that inspect the old stats.json file as it will no longer be named that.

Other information

… 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. Today, everything gets dumped into a single file and it's nearly impossible to use without hours of fix -> remove unused browser 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.

Fixes #28185 #28671
@google-cla

google-cla Bot commented Mar 1, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/build labels Mar 1, 2026
@tsteuwer-accesso

Copy link
Copy Markdown
Author

Signed CLA.

…at was in my main branch off of @angular/angular-cli repository

This addresses an issue of including the (browser|server)-initial-stats.json file that was in my original repository. It also fixes unit tests that were also addressed in the original repo.
@@ -83,9 +83,8 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
// Once TypeScript provides support for keeping the dynamic import this workaround can be

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This changes are unrelated and unneeded.

Please revert.

@@ -208,7 +208,7 @@
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please revert.

@@ -394,7 +394,7 @@
},

@alan-agius4 alan-agius4 Mar 2, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please revert.

PrerenderedRoutesRecord,
} from './bundler-execution-result';

export function buildMetafileForType(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This isn't the ideal place for this logic. Since metadata is already being merged here, we should instead modify that process to skip merging for specific fields or keep them isolated from the start.

@tsteuwer-accesso

Copy link
Copy Markdown
Author

Thanks, will update when I get a chance. Give me a bit :)

@tsteuwer-accesso

Copy link
Copy Markdown
Author

@alan-agius4 , so looking into this, I was reviewing that mergeResults function and there are several places that look at metafile on the BundleContextResult like chunk-optimizer.ts, server-bundle-metadata-plugin.ts, etc. Should I keep the metafile that includes everything and then add separate browserMetafile and serverMetafile? Or what would you rather me do?

@alan-agius4

Copy link
Copy Markdown
Collaborator

@tsteuwer-accesso, thanks for looking into this.

The createServerBundleMetadata pulls metadata directly from a specific build, it remains unaffected by any changes in mergeResults. Furthermore, chunk-optimizer.ts utilizes browser metadata, keeping these separate shouldn't be an issue either.

@alan-agius4

Copy link
Copy Markdown
Collaborator

Closing this out for now as it looks like this has stalled. Please reopen if you're still interested in pursuing these changes

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--stats-json to allow giving stats to both server and browser, separately

2 participants