Skip to content

fix(native-federation): resolve @angular/common/locales/global/<code>…#1107

Open
ValentinBossi wants to merge 1 commit into
angular-architects:mainfrom
ValentinBossi:claude/fix-angular-locale-resolution-bGWgw
Open

fix(native-federation): resolve @angular/common/locales/global/<code>…#1107
ValentinBossi wants to merge 1 commit into
angular-architects:mainfrom
ValentinBossi:claude/fix-angular-locale-resolution-bGWgw

Conversation

@ValentinBossi
Copy link
Copy Markdown
Contributor

… bare specifier

Angular's @angular/build:application builder injects a polyfill angular:locale/data:<sourceLocale> whenever i18n.sourceLocale is explicitly defined and not en/en-US. In dev-server mode with packages: 'external', the i18n-locale-plugin leaves the resulting @angular/common/locales/global/<code> import as a bare specifier so vite's dep-prebundling can resolve it at runtime.

Native Federation replaces vite's externals/prebundling with its own importmap (via es-module-shims), but did not surface the locale data file there. The browser therefore failed to resolve the bare specifier with "Failed to resolve module specifier
'@angular/common/locales/global/'".

Inject the matching locale data files as shared chunks into the federation config after normalization (so filterShared does not strip them again), so the bundler emits the files and writeImportMap lists them. Mirrors Angular's progressive locale-tag fallback (de-XYZ -> de).

Also covers the dev-server case where a single inline locale is served via the --localize filter.

https://claude.ai/code/session_01R6oaYzTRcwyo5JUWGqWZHv

… bare specifier

Angular's @angular/build:application builder injects a polyfill
`angular:locale/data:<sourceLocale>` whenever `i18n.sourceLocale` is
explicitly defined and not en/en-US. In dev-server mode with
`packages: 'external'`, the i18n-locale-plugin leaves the resulting
`@angular/common/locales/global/<code>` import as a bare specifier so
vite's dep-prebundling can resolve it at runtime.

Native Federation replaces vite's externals/prebundling with its own
importmap (via es-module-shims), but did not surface the locale data
file there. The browser therefore failed to resolve the bare specifier
with "Failed to resolve module specifier
'@angular/common/locales/global/<code>'".

Inject the matching locale data files as shared chunks into the
federation config after normalization (so filterShared does not strip
them again), so the bundler emits the files and writeImportMap lists
them. Mirrors Angular's progressive locale-tag fallback (de-XYZ -> de).

Also covers the dev-server case where a single inline locale is served
via the --localize filter.

https://claude.ai/code/session_01R6oaYzTRcwyo5JUWGqWZHv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants