Skip to content

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

Open
tsteuwer-accesso wants to merge 12 commits intoangular:mainfrom
tsteuwer-accesso:main
Open

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

Conversation

@tsteuwer-accesso
Copy link
Copy Markdown

@tsteuwer-accesso tsteuwer-accesso commented Apr 12, 2026

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.

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-initial-stats.json and server-initial-stats.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 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.

Fixes angular#28185 angular#28671
…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.
Addressing Alans concerns and removing the function and keeping the bundles separate
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/build labels Apr 12, 2026
@tsteuwer-accesso
Copy link
Copy Markdown
Author

@alan-agius4 , made the requested changes. Let me know if there's anything else.

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 refactors the build process to generate separate and filtered stats files for browser and server outputs, replacing the single stats.json with more granular files like browser-stats.json and browser-initial-stats.json. The changes include updates to the application builder, esbuild bundling context, and Webpack configuration. Feedback highlights an opportunity to refactor the metafile filtering logic into a shared utility to reduce code duplication. Additionally, it was noted that the Webpack implementation currently produces a duplicate file for initial stats instead of a filtered one, which should be addressed to ensure feature parity with the esbuild implementation.

Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Thanks for this. Please see the comments. In addition please rebase and squash your commits.

@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: minor This PR is targeted for the next minor release labels Apr 14, 2026
This reverts commit dd80e0f.
… file that was in my main branch off of @angular/angular-cli repository"

This reverts commit 24c509f.
…ats json files for easier consumption"

This reverts commit 9545676.
@tsteuwer-accesso
Copy link
Copy Markdown
Author

Thanks @alan-agius4 , looking into this.

…erting all previous changes and then splitting out the browser/server metafiles and then filtering at the end when were generating the json files
@tsteuwer-accesso
Copy link
Copy Markdown
Author

@alan-agius4 , I've changed this per your review.

When I was creating the unit tests files, I can't import Metafile from esbuild. I kept getting an error stating that No explicit Bazel dependency for this module. Do you know how I can fix this so I don't have to make types for a Metafile or use the hack of Parameters[0] to get the Metafile type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: @angular/build detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

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