angular/angular-cli · error · Error

Webpack stats build result is required.

Error message

Webpack stats build result is required.

What it means

The server builder subscribes to webpack build events and destructures `webpackStats` from each emitted output. If a build event arrives without webpack stats, the builder cannot produce a meaningful result and throws this error. It is an internal invariant check: every completed webpack compilation must carry stats.

Source

Thrown at packages/angular_devkit/build_angular/src/builders/server/index.ts:94

  const baseOutputPath = path.resolve(root, options.outputPath);
  let outputPaths: undefined | Map<string, string>;

  return from(initialize(options, context, transforms.webpackConfiguration)).pipe(
    concatMap(({ config, i18n, projectRoot, projectSourceRoot }) => {
      return runWebpack(config, context, {
        webpackFactory: require('webpack') as typeof webpack,
        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 (output) => {
          const { emittedFiles = [], outputPath, webpackStats, success } = output;
          if (!webpackStats) {
            throw new Error('Webpack stats build result is required.');
          }

          if (!success) {
            if (statsHasWarnings(webpackStats)) {
              context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
            }
            if (statsHasErrors(webpackStats)) {
              context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
            }

            return output;
          }

          const spinner = new Spinner();
          spinner.enabled = options.progress !== false;
          outputPaths = ensureOutputPaths(baseOutputPath, i18n);

          // Copy assets

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Remove or update custom webpack plugins/builder wrappers until the build emits proper webpack stats.
  2. Align @angular-devkit/build-angular and related @angular/* package versions (all from the same major/minor release).
  3. Reproduce with a minimal config (no custom webpack extras) to isolate the plugin that drops stats.
  4. Check for a merged/incompatible builder (e.g. custom execute implementations) and ensure it forwards webpackStats in its results.

Example fix

// custom builder result missing stats
return { success, outputPath, emittedFiles };
// after: include webpackStats from the webpack compilation
return { success, outputPath, emittedFiles, webpackStats: compilationToStats(result) };
Defensive patterns

Strategy: try-catch

Validate before calling

if (result && typeof result === 'object' && 'webpackStats' in result) { /* safe to use builder */ }

Type guard

function hasWebpackStats(r: unknown): r is { webpackStats: object; success: boolean; outputPath: string } {
  return typeof r === 'object' && r !== null && 'webpackStats' in r && r.webpackStats != null;
}

Try / catch

try {
  await firstValueFrom(ngBuild(context, options));
} catch (err) {
  if (err instanceof Error && err.message.includes('Webpack stats build result is required.')) {
    context.logger.error('A custom webpack plugin dropped build stats; disable custom plugins.');
  }
  throw err;
}

Prevention

When it happens

Trigger: Running `ng run <project>:server` when the underlying webpack builder emits an output event where `output.webpackStats` is undefined — typically from a misbehaving custom webpack plugin, an incompatible builder/plugin version, or a build event emitted before compilation stats exist.

Common situations: Using third-party webpack plugins (or custom builders extending the server builder) that emit build results without stats; version mismatches between @angular-devkit/build-angular and custom tooling; builder harness/test setups feeding incomplete build results.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/2a75f0c0abdab178. Report an issue: GitHub.