feat(@angular/build): Support splitting browser and server stats json files for easier consumption#33209
Open
tsteuwer-accesso wants to merge 1 commit into
Open
feat(@angular/build): Support splitting browser and server stats json files for easier consumption#33209tsteuwer-accesso wants to merge 1 commit into
tsteuwer-accesso wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -> analyzeand 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?
What is the current behavior?
When using
--stats-json, the CLI outputs a singlestats.jsonfile.Issue Number: #28185
What is the new behavior?
When using
--stats-json, the CLI now outputs four separate files:browser-stats.jsonThe full browser stats.jsonbrowser-initial-stats.jsonJust the files that will be delivered on the main request.server-stats.jsonSSR versionserver-initial-stats.jsonSSR versionDoes this PR introduce a breaking change?
If anyone is relying on there being a single
stats.jsonfile, 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