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.
This commit is contained in:
Charles Lyding 2025-02-25 10:36:37 -05:00 committed by Charles
parent 2f8e7dbc94
commit eb058d0659

View File

@ -117,6 +117,16 @@ export async function* serveWithVite(
autoCsp: false, 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 // Set all packages as external to support Vite's prebundle caching
browserOptions.externalPackages = serverOptions.prebundle; browserOptions.externalPackages = serverOptions.prebundle;