angular/angular-cli · error · Error

Unknown error occurred inlining file "${options.filename}"

Error message

Unknown error occurred inlining file "${options.filename}"

What it means

After attempting to parse/inling a bundle, if the resulting AST is still undefined without a caught error, inlineLocales throws this as a last-resort signal that inlining produced no parse result for the given file. It indicates an unexpected/unknown failure rather than a reported translation error.

Source

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

      configFile: false,
      sourceType: 'unambiguous',
      filename: options.filename,
    });
  } catch (error) {
    assertIsError(error);

    // Make the error more readable.
    // Same errors will contain the full content of the file as the error message
    // Which makes it hard to find the actual error message.
    const index = error.message.indexOf(')\n');
    const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;
    throw new Error(`${msg}\nAn error occurred inlining file "${options.filename}"`, {
      cause: error,
    });
  }

  if (!ast) {
    throw new Error(`Unknown error occurred inlining file "${options.filename}"`);
  }

  if (!USE_LOCALIZE_PLUGINS) {
    return inlineLocalesDirect(ast, options);
  }

  const diagnostics = [];
  for (const locale of i18n.inlineLocales) {
    const isSourceLocale = locale === i18n.sourceLocale;
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    const translations: any = isSourceLocale ? {} : i18n.locales[locale].translation || {};
    let localeDataContent;
    if (options.setLocale) {
      // If locale data is provided, load it and prepend to file
      const localeDataPath = i18n.locales[locale]?.dataPath;
      if (localeDataPath) {
        localeDataContent = await loadLocaleData(localeDataPath, true);
      }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Verify the input bundle exists, is non-empty, and is valid JavaScript the inliner can parse.
  2. Update @angular-devkit/build-angular and @angular/localize to matching versions.
  3. Log inputs and reproduce with a minimal bundle; file an issue with the file content if it persists.

Example fix

// before: inlining a corrupt/empty bundle
await inlineLocales({ filename: 'main.js', code: '', ... });
// after: guard before calling
if (!options.code || !options.code.trim()) throw new Error('bundle is empty');
await inlineLocales(options);
Defensive patterns

Strategy: validation

Validate before calling

const code = fs.readFileSync(bundlePath, 'utf8');
if (!code.trim()) throw new Error(`Bundle ${bundlePath} is empty; rebuild before inlining.`);

Type guard

function isAstDefined(ast: unknown): ast is NonNullable<typeof ast> {
  return ast !== null && ast !== undefined;
}

Try / catch

try {
  await inlineLocales(options);
} catch (e) {
  if (String(e.message).includes('Unknown error occurred inlining')) {
    // fall back to re-parsing the bundle manually or failing fast with diagnostics
  } else throw e;
}

Prevention

When it happens

Trigger: inlineLocales processes a file and no exception was thrown but the AST variable is falsy — i.e. the translation parser returned nothing for options.filename.

Common situations: Edge cases with empty or invalid bundles, unsupported bundle formats passed to the inliner, or plugin/tool version mismatches where the parser silently returns no result.

Related errors


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