angular/angular-cli · error · Error

Unknown error occurred processing bundle for "${options.file

Error message

Unknown error occurred processing bundle for "${options.filename}".

What it means

During per-locale transformation inside inlineLocales, after the localize transform runs the code checks that a transform result with code was produced. If the transform returned nothing (or no code), the library cannot write the translated bundle and throws this error naming the file being processed.

Source

Thrown at packages/angular_devkit/build_angular/src/utils/process-bundle.ts:190

      localeDataContent,
    );
    const transformResult = transformFromAstSync(ast, options.code, {
      filename: options.filename,
      // using false ensures that babel will NOT search and process sourcemap comments (large memory usage)
      // The types do not include the false option even though it is valid
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      inputSourceMap: false as any,
      babelrc: false,
      configFile: false,
      plugins,
      compact: !shouldBeautify,
      sourceMaps: !!options.map,
    });

    diagnostics.push(...localeDiagnostics.messages);

    if (!transformResult || !transformResult.code) {
      throw new Error(`Unknown error occurred processing bundle for "${options.filename}".`);
    }
    const subPath = i18n.locales[locale].subPath;
    const outputPath = path.join(
      options.outputPath,
      i18n.flatOutput ? '' : subPath,
      options.filename,
    );
    await fs.writeFile(outputPath, transformResult.code);

    if (options.map && transformResult.map) {
      const outputMap = remapping([transformResult.map as SourceMapInput, options.map], () => null);

      await fs.writeFile(outputPath + '.map', JSON.stringify(outputMap));
    }
  }

  return { file: options.filename, diagnostics };
}

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Re-run a clean build (delete node_modules/.cache and dist) to remove stale artifacts.
  2. Ensure @angular/localize and @angular-devkit/build-angular versions are aligned in package.json.
  3. Check that the transform inputs are valid; if it reproduces on a minimal bundle, report it to the Angular CLI repository.

Example fix

// before
npx ng build --localize  // stale artifacts cause transformResult.code to be empty
// after
rm -rf node_modules/.cache dist && npx ng build --localize
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeof babelTransform !== 'function') throw new Error('Localize transform unavailable; check @angular/localize installation.');

Type guard

function hasTransformCode(r: unknown): r is { code: string } {
  return typeof r === 'object' && r !== null && typeof (r as any).code === 'string' && (r as any).code.length > 0;
}

Try / catch

try {
  await inlineLocales(options);
} catch (e) {
  if (String(e.message).includes('Unknown error occurred processing bundle')) {
    // clean rebuild / verify tool versions, then retry once
  } else throw e;
}

Prevention

When it happens

Trigger: The localize transform (via babel/localize plugins) returns a falsy result or a result without `code` for a given locale while processing options.filename.

Common situations: Version mismatches between @angular/localize plugins and build tooling, unsupported bundle content that the transformer silently fails on, or corrupted intermediate build artifacts.

Related errors


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