Skip to content

Commit

Permalink
fix(@angular/build): always disable JSON stats with dev-server
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clydin committed Feb 25, 2025
1 parent 2f8e7db commit eb058d0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/angular/build/src/builders/dev-server/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit eb058d0

Please sign in to comment.