From 48a21b70552bd773be7cc558d6bd7fb1b707657d Mon Sep 17 00:00:00 2001 From: roma-claudio Date: Fri, 7 Nov 2025 16:46:32 +0700 Subject: [PATCH] fix(@angular/build): builder removes @angular/localize when external packages are not inlined The current bundle logic removes any import starting with `@angular/localize` if i18n inline is active. The i18n inline transformation is only applied to internal packages. This causes an issue at run time execution of the packages which are external (pre-bundled) and therefore not inlined. The current fix aims at removing import starting with `@angular/localize` only if both i18n inline is active and there are no external packages. --- .../build/src/tools/esbuild/application-code-bundle.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/angular/build/src/tools/esbuild/application-code-bundle.ts b/packages/angular/build/src/tools/esbuild/application-code-bundle.ts index 51d3702887f7..635faca8c82e 100644 --- a/packages/angular/build/src/tools/esbuild/application-code-bundle.ts +++ b/packages/angular/build/src/tools/esbuild/application-code-bundle.ts @@ -654,7 +654,7 @@ function getEsBuildCommonPolyfillsOptions( tryToResolvePolyfillsAsRelative: boolean, loadResultCache: LoadResultCache | undefined, ): BuildOptions | undefined { - const { jit, workspaceRoot, i18nOptions } = options; + const { jit, workspaceRoot, i18nOptions, externalPackages } = options; const buildOptions = getEsBuildCommonOptions(options); buildOptions.splitting = false; @@ -671,8 +671,10 @@ function getEsBuildCommonPolyfillsOptions( // Locale data should go first so that project provided polyfill code can augment if needed. let needLocaleDataPlugin = false; if (i18nOptions.shouldInline) { - // Remove localize polyfill as this is not needed for build time i18n. - polyfills = polyfills.filter((path) => !path.startsWith('@angular/localize')); + if (!externalPackages) { + // Remove localize polyfill when i18n inline transformation have been applied to all the packages. + polyfills = polyfills.filter((path) => !path.startsWith('@angular/localize')); + } // Add locale data for all active locales // TODO: Inject each individually within the inlining process itself