Skip to content

Commit f82b77e

Browse files
roma-claudioalan-agius4
authored andcommitted
fix(@angular/build): do not remove @angular/localize when having external packages (#31721)
The current bundle logic removes the `@angular/localize` polyfill if i18n inline is active. However, i18n inlining is not applied on external packages (e.g. during `ng serve` for prebundled dependencies) This causes an issue at runtime execution of the packages which are external and depend on localization. With this change the `@angular/localize` polyfill is retained when external packages is truthy. (cherry picked from commit 38c2200)
1 parent 4a5495b commit f82b77e

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)