Skip to content

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

Open
alan-agius4 wants to merge 2 commits into
angular:mainfrom
alan-agius4:stats-sep
Open

feat(@angular/build): Support splitting browser and server stats jsonfiles for easier consumption#33870
alan-agius4 wants to merge 2 commits into
angular:mainfrom
alan-agius4:stats-sep

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

No description provided.

…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.
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/build labels Aug 17, 2026
@alan-agius4
alan-agius4 force-pushed the stats-sep branch 3 times, most recently from 9f9ef20 to 9f8f54c Compare August 17, 2026 13:38
@alan-agius4
alan-agius4 requested a review from clydin August 17, 2026 13:38
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Aug 17, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review August 17, 2026 16:51

@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 refactors the application builder to separate browser and server metafiles instead of merging them into a single metafile, enabling the generation of separate browser and server stats files. Feedback on these changes highlights two issues: first, removing the server bundle exclusion check in generateBudgetStats incorrectly includes server files in budget calculations, which should be resolved by filtering outputFiles beforehand; second, removing the BuildOutputFileType.Browser check in chunk-optimizer.ts allows server-side files to be added to chunk records, introducing unnecessary overhead.

Comment thread packages/angular/build/src/builders/application/execute-build.ts
Comment thread packages/angular/build/src/builders/application/chunk-optimizer.ts
…ndler context

Track the target platform (`browser` or `server`) on individual bundler context results and introduce `BundleMergedContextResult` to maintain separate `browser` and `server` metafiles when merging.

This simplifies downstream consumers:
- Enables direct usage of `metafiles.browser` for browser-specific steps (budgets, i18n, chunk optimization, CommonJS checks, and post-bundle processing).
- Allows `extractLicenses` and `logBuildStats` to process all platform metafiles directly without merging them into a single structure.
- Removes redundant filtering of server bundles in budget calculations.
- Streamlines the `statsJson` file emission for browser and server targets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer 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.

2 participants