{"record":{"id":"07eddcec1a699b23","repo":"angular/angular-cli","slug":"i18n-options-are-missing","errorCode":null,"errorMessage":"i18n options are missing","messagePattern":"i18n options are missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/utils/process-bundle.ts","lineNumber":308,"sourceCode":"      options.filename,\n    );\n    await fs.writeFile(outputPath, outputCode);\n\n    if (inputMap && outputMap) {\n      outputMap.file = options.filename;\n      if (mapSourceRoot) {\n        outputMap.sourceRoot = mapSourceRoot;\n      }\n      await fs.writeFile(outputPath + '.map', JSON.stringify(outputMap));\n    }\n  }\n\n  return { file: options.filename, diagnostics: diagnostics.messages, count: positions.length };\n}\n\nasync function inlineCopyOnly(options: InlineOptions) {\n  if (!i18n) {\n    throw new Error('i18n options are missing');\n  }\n\n  for (const locale of i18n.inlineLocales) {\n    const subPath = i18n.locales[locale].subPath;\n    const outputPath = path.join(\n      options.outputPath,\n      i18n.flatOutput ? '' : subPath,\n      options.filename,\n    );\n    await fs.writeFile(outputPath, options.code);\n    if (options.map) {\n      await fs.writeFile(outputPath + '.map', options.map);\n    }\n  }\n\n  return { file: options.filename, diagnostics: [], count: 0 };\n}\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/utils/process-bundle.ts#L290-L326","documentation":"inlineCopyOnly (and the inlining flow generally) requires the module-level i18n options to have been initialized via the i18n plugin machinery. If inlineCopyOnly is called with i18n still undefined, the library cannot know locales or output layout and throws 'i18n options are missing'.","triggerScenarios":"Calling inlineCopyOnly (directly or via inlineLocales/inlineLocalesDirect) before the i18n options were set up — e.g. invoking the inlining utilities outside the normal builder pipeline where the i18n context was never initialized.","commonSituations":"Custom scripts or tools that import process-bundle utilities directly without calling the i18n initialization; using the utilities in tests without stubbing the i18n options; internal state lost across worker/process boundaries.","solutions":["Initialize the i18n options (via the builder's i18n context/plugin) before invoking any inlining function.","If writing a custom tool, replicate the builder's i18n setup steps (load locales, set i18n.flatOutput/inlineLocales) first.","In tests, mock or set the module's i18n state to a valid InlineOptions-compatible object."],"exampleFix":"// before\ncustomBundle();\ninlineCopyOnly(options); // throws: i18n never initialized\n// after\nsetupI18nContext(ngI18nOptions); // initializes i18n state first\ninlineCopyOnly(options);","handlingStrategy":"validation","validationCode":"if (typeof i18nOptions === 'undefined' || i18nOptions == null) {\n  throw new Error('Initialize i18n options before calling inlining utilities.');\n}","typeGuard":"function i18nInitialized(i18n: unknown): i18n is NonNullable<typeof i18n> {\n  return i18n !== null && i18n !== undefined;\n}","tryCatchPattern":"try {\n  await inlineCopyOnly(options);\n} catch (e) {\n  if (String(e.message).includes('i18n options are missing')) {\n    // initialize i18n context and retry once\n  } else throw e;\n}","preventionTips":["Always route inlining through the standard Angular builder pipeline that initializes i18n options.","When calling utilities directly (scripts/tests), set up the i18n state first.","Assert i18n options exist in unit tests before exercising inlining code paths.","Avoid caching module state across worker boundaries where i18n context may be lost."],"tags":["i18n","angular-cli","initialization","state"],"backgroundTag":"missing-initialization","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}