From eb058d06592f86dbe02b86adeff13d0d7b3e2f9f Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 25 Feb 2025 10:36:37 -0500 Subject: [PATCH] fix(@angular/build): always disable JSON stats with dev-server When using the development server, the `statsJson` option will now unconditionally be disabled. The output JSON file is not accessible with the server and the analysis/generation of the JSON file may increase the rebuild time. Additionally, the JSON file changes during a rebuild may unexpectedly cause component HMR fallback to a full reload due to non-component file changes in the build output. --- .../build/src/builders/dev-server/vite-server.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/angular/build/src/builders/dev-server/vite-server.ts b/packages/angular/build/src/builders/dev-server/vite-server.ts index 4ca99252131f..241ff2cdc505 100644 --- a/packages/angular/build/src/builders/dev-server/vite-server.ts +++ b/packages/angular/build/src/builders/dev-server/vite-server.ts @@ -117,6 +117,16 @@ export async function* serveWithVite( autoCsp: false, }; + // Disable JSON build stats. + // These are not accessible with the dev server and can cause HMR fallbacks. + if (browserOptions.statsJson === true) { + context.logger.warn( + 'Build JSON statistics output (`statsJson` option) has been disabled.' + + ' The development server does not support this option.', + ); + } + browserOptions.statsJson = false; + // Set all packages as external to support Vite's prebundle caching browserOptions.externalPackages = serverOptions.prebundle;