Skip to content

fix(@angular/build): ensure @angular/compiler is loaded for Vitest TestBed initialization - #34202

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/vitest-compiler-init
Open

clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/vitest-compiler-init

Conversation

@clydin

@clydin clydin commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Provide a dedicated setup file to import '@angular/compiler' prior to TestBed initialization. This ensures the compiler facade is published before 'init-testbed.js' or any shared code-split chunks (such as those configured via 'providersFile') are evaluated, avoiding JIT compilation errors when injectable dependencies are resolved during test initialization.

Closes #31993

@clydin clydin added the target: patch This PR is targeted for the next patch release label Sep 29, 2026
@clydin
clydin force-pushed the fix/vitest-compiler-init branch from ff9ce8c to 31b4ad1 Compare September 29, 2026 16:49
@clydin
clydin marked this pull request as ready for review September 29, 2026 17:10

@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 adds an initialization step for the Angular compiler (@angular/compiler) in the Vitest unit test runner by registering a new virtual file and entry point (init-compiler.js) that imports @angular/compiler and prepends it to the Vitest setup files. Additionally, a new integration test has been added to verify that providers injecting services requiring JIT compilation function correctly. No review comments were provided, so there is no feedback to address.

@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 29, 2026
@clydin
clydin requested a review from alan-agius4 September 29, 2026 17:18
…stBed initialization

Provide a dedicated setup file to import '@angular/compiler' prior to TestBed initialization. This ensures the compiler facade is published before 'init-testbed.js' or any shared code-split chunks (such as those configured via 'providersFile') are evaluated, avoiding JIT compilation errors when injectable dependencies are resolved during test initialization.
@clydin
clydin force-pushed the fix/vitest-compiler-init branch from 31b4ad1 to 6aa8648 Compare September 29, 2026 18:05
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.

@angular/build:unit-test with Vitest test runner throws Failed to import test file error

1 participant