Skip to content

Commit 48a21b7

Browse files
committed
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.
1 parent c3c9ac5 commit 48a21b7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/angular/build/src/tools/esbuild/application-code-bundle.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ function getEsBuildCommonPolyfillsOptions(
654654
tryToResolvePolyfillsAsRelative: boolean,
655655
loadResultCache: LoadResultCache | undefined,
656656
): BuildOptions | undefined {
657-
const { jit, workspaceRoot, i18nOptions } = options;
657+
const { jit, workspaceRoot, i18nOptions, externalPackages } = options;
658658

659659
const buildOptions = getEsBuildCommonOptions(options);
660660
buildOptions.splitting = false;
@@ -671,8 +671,10 @@ function getEsBuildCommonPolyfillsOptions(
671671
// Locale data should go first so that project provided polyfill code can augment if needed.
672672
let needLocaleDataPlugin = false;
673673
if (i18nOptions.shouldInline) {
674-
// Remove localize polyfill as this is not needed for build time i18n.
675-
polyfills = polyfills.filter((path) => !path.startsWith('@angular/localize'));
674+
if (!externalPackages) {
675+
// Remove localize polyfill when i18n inline transformation have been applied to all the packages.
676+
polyfills = polyfills.filter((path) => !path.startsWith('@angular/localize'));
677+
}
676678

677679
// Add locale data for all active locales
678680
// TODO: Inject each individually within the inlining process itself

0 commit comments

Comments
 (0)