angular/angular-cli · error · Error
Webpack stats build result is required.
Error message
Webpack stats build result is required.
What it means
The browser builder's webpack completion event must carry webpackStats, which the builder uses to compute emitted files, budgets, index generation, and the final BrowserBuilderOutput. If the build event arrives without stats (undefined), the builder refuses to continue because downstream processing would crash or produce wrong output.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/browser/index.ts:193
transforms.logging ||
((stats, config) => {
if (options.verbose && config.stats !== false) {
const statsOptions = config.stats === true ? undefined : config.stats;
context.logger.info(stats.toString(statsOptions));
}
}),
}).pipe(
concatMap(
async (
buildEvent,
): Promise<{ output: BuilderOutput; webpackStats: StatsCompilation }> => {
const spinner = new Spinner();
spinner.enabled = options.progress !== false;
const { success, emittedFiles = [], outputPath: webpackOutputPath } = buildEvent;
const webpackRawStats = buildEvent.webpackStats;
if (!webpackRawStats) {
throw new Error('Webpack stats build result is required.');
}
// Fix incorrectly set `initial` value on chunks.
const extraEntryPoints = [
...normalizeExtraEntryPoints(options.styles || [], 'styles'),
...normalizeExtraEntryPoints(options.scripts || [], 'scripts'),
];
const webpackStats = {
...webpackRawStats,
chunks: markAsyncChunksNonInitial(webpackRawStats, extraEntryPoints),
};
if (!success) {
// If using bundle downleveling then there is only one build
// If it fails show any diagnostic messages and bail
if (statsHasWarnings(webpackStats)) {
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));View on GitHub (pinned to bb72145f9a)
Solutions
- Remove or fix any webpackConfiguration/logging transforms that mutate the build pipeline and drop stats.
- If wrapping the builder, forward the original buildEvent (with webpackStats) rather than a reconstructed object.
- Update @angular-devkit/build-angular to latest and verify custom plugins match its BuildEvent interface.
- Run a plain build without custom config to confirm stock webpack emits stats; bisect from there.
Example fix
// before
return build.pipe(map(ev => ({ success: ev.success }))); // drops webpackStats
// after
return build; // forward full build event including webpackStats Defensive patterns
Strategy: type-guard
Validate before calling
import type { BuildEvent } from '@angular-devkit/build-angular';
function hasStats(ev: Partial<BuildEvent>): ev is BuildEvent & { webpackStats: NonNullable<BuildEvent['webpackStats']> } {
return !!ev.webpackStats;
} Type guard
const hasWebpackStats = (ev: { webpackStats?: unknown }): ev is { webpackStats: NonNullable<typeof ev.webpackStats> } =>
ev.webpackStats != null; Try / catch
try {
await ngBuild();
} catch (e) {
if (String(e.message).includes('Webpack stats build result is required')) {
// stop forwarding modified build events; forward the original event
}
throw e;
} Prevention
- Do not pipe/map the build observable into reconstructed events
- Keep transforms minimal and stats-preserving
- Pin compatible @angular-devkit/build-angular versions
- Test custom wrappers against stock builds
When it happens
Trigger: A custom webpack configuration transformation strips or fails to attach webpackStats to the compilation/build event; using transforms.webpackConfiguration that returns a config incompatible with stats generation; webpack plugin versions whose BuildEvent no longer populates webpackStats; intercepting the build observable and re-emitting events without stats.
Common situations: Custom Angular CLI plugins/scripts that pipe the build observable; third-party builders wrapping the browser builder and forwarding malformed build events; upgrading @angular-devkit/build-angular while keeping custom transforms that assume an older event shape.
Related errors
- Webpack stats build result is required.
- The "@angular-devkit/build-angular:app-shell" builder is dep
- The "@angular-devkit/build-webpack:webpack" builder is depre
- Error(s) occurred while extracting routes:\n${errors.map((er
- Could not find server output directory: ${outputPath}.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/682bc675f567012c.
Report an issue: GitHub.