Skip to content

fix(@angular/build): auto-inject localize/init in library unit tests#33453

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-vitest-localize-libraries
Open

fix(@angular/build): auto-inject localize/init in library unit tests#33453
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-vitest-localize-libraries

Conversation

@clydin

@clydin clydin commented Jun 24, 2026

Copy link
Copy Markdown
Member

Injects '@angular/localize/init' at the top of the internal virtual initialization file (angular:test-bed-init) if '@angular/localize' is installed in the workspace. This prevents ReferenceErrors when testing libraries that consume localization APIs.

Also updates the warning plugin to skip internal imports originating from the 'angular:' namespace.

@clydin clydin added the target: patch This PR is targeted for the next patch release label Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request conditionally imports @angular/localize/init in virtual test bed initialization files for both Karma and Vitest builders if @angular/localize is installed in the project. It also updates the Angular localize init warning plugin to skip files with an angular: namespace. Feedback was provided to use optional chaining when checking args.namespace to prevent potential runtime errors if the namespace is undefined.

Comment thread packages/angular/build/src/tools/esbuild/angular-localize-init-warning-plugin.ts Outdated
Injects '@angular/localize/init' at the top of the internal virtual initialization file (angular:test-bed-init) if '@angular/localize' is installed in the workspace. This prevents ReferenceErrors when testing libraries that consume localization APIs.

Also updates the warning plugin to skip internal imports originating from the 'angular:' namespace.
@clydin clydin force-pushed the fix-vitest-localize-libraries branch from 5016561 to 95c6426 Compare June 24, 2026 20:48
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant