refactor(@angular/build): avoid secondary import wrapper in Vitest unless coverage is enabled#32360
Merged
alan-agius4 merged 2 commits intoangular:mainfrom Jan 27, 2026
Merged
Conversation
…less coverage is enabled This commit optimizes the Vitest test runner by removing the secondary import wrapper for test entry points when code coverage is not enabled. The wrapper is only necessary to support coverage exclusion of the test files themselves. By capturing the resolved Vitest configuration within the `configureVitest` hook, the plugin can now determine if coverage is enabled and conditionally apply the wrapper. This simplifies the module graph for standard test runs.
fb5e52e to
5c4cd1f
Compare
…bypassed When code coverage is disabled, the Vitest builder bypasses the secondary import wrapper and serves the compiled output directly as the test file. This caused sourcemaps to be incorrect because the `sources` field in the map (relative to the build root) was being resolved relative to the test file's location. This commit adjusts the `sources` in the sourcemap to be relative to the test file's directory, ensuring correct source mapping in debuggers.
5c4cd1f to
318dd47
Compare
alan-agius4
approved these changes
Jan 27, 2026
Collaborator
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit optimizes the Vitest test runner by removing the secondary import wrapper for test entry points when code coverage is not enabled. The wrapper is only necessary to support coverage exclusion of the test files themselves.
By capturing the resolved Vitest configuration within the
configureVitesthook, the plugin can now determine if coverage is enabled and conditionally apply the wrapper. This simplifies the module graph for standard test runs.