Title: Vitest coverage issue `vite:import-analysis` error `Pre-transform error: Failed to resolve import "#/util" from "src/app/app.ts". Does the file exist?` · Issue #32891 · angular/angular-cli · GitHub
Open Graph Title: Vitest coverage issue `vite:import-analysis` error `Pre-transform error: Failed to resolve import "#/util" from "src/app/app.ts". Does the file exist?` · Issue #32891 · angular/angular-cli
X Title: Vitest coverage issue `vite:import-analysis` error `Pre-transform error: Failed to resolve import "#/util" from "src/app/app.ts". Does the file exist?` · Issue #32891 · angular/angular-cli
Description: Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was vitest@4.0.8 Description I'm not sure if this issue is an issue with Vitest, or the Ang...
Open Graph Description: Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was vitest@4.0.8 Description I'm not sure if this i...
X Description: Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was vitest@4.0.8 Description I'm not sure if th...
Opengraph URL: https://github.com/angular/angular-cli/issues/32891
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Vitest coverage issue `vite:import-analysis` error `Pre-transform error: Failed to resolve import \"#/util\" from \"src/app/app.ts\". Does the file exist?`","articleBody":"### Command\n\ntest\n\n### Is this a regression?\n\n- [x] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\nvitest@4.0.8\n\n### Description\n\nI'm not sure if this issue is an issue with Vitest, or the Angular CLI integration with Vitest. I put the issue here, because I have no idea how to reproduce this issue without Angular at the moment.\n\nThe issue is that when using `tsconfig.json` property `paths` and running browser tests with coverage, these `paths` will not used when Vitest tries to read coverage from source maps. The requirement seems to be that a shared chunk exists (`import './app'` in the repro steps).\n\nThis results in errors during coverage generation, but tests do not crash. The errors come from Vite's dev server pre transforming original `.ts` files referenced in source-maps.\n\n**Requirements**\n- Using `paths` in `tsconfig.json`\n- Angular CLI + `eslint` creates a shared chunk that has the `paths` in it's sourcemap\n- Vitest with `browsers` + `coverage` + `coverageInclude`\n- Vitest `v4.1.0+`\n\n\n### Minimal Reproduction\n\n\n1. Init Angular project \u0026 install vitest coverage \u0026 browser packages\n```\nnpx @angular/cli@21.1.5 new ng21.1.5 -s -t --style css --no-ssr --ai-config none\nnpm i -E -D vitest@4.1.0 @vitest/browser-playwright@4.1.0 @vitest/coverage-v8@4.1.0 playwright\n```\n2. Add `src/app/util.ts` file\n```ts\nexport const greet = 'Hello';\n```\n3. Add a path alias to util file\n```json\n{\n \"compilerOptions\": {\n \"paths\": {\n \"#/util\": [\"./src/app/util.ts\"]\n }\n }\n}\n```\n4. Make `App` (`app.ts`) use value from `util.ts`\n```ts\nimport { greet } from '#/util';\n// ...\nexport class App {\n protected readonly title = signal(greet);\n}\n```\n5. Add import to `app.ts` from `app.config.ts`\n```ts\nimport './app';\n```\n6. Run tests with browser, coverage \u0026 coverage include\n```\nnpx ng test --no-watch --browsers chromium --coverage --coverage-include src/app/**/*.ts\n```\n\n### Exception or Error\n\n```text\nThere's logged errors for every file that uses the path alias, which in our project is most of them (e.g. `import { shared } from '#/core';`).\n\n\n00:02:12 [vite] (client) Pre-transform error: Failed to resolve import \"#/util\" from \"src/app/app.ts\". Does the file exist?\n Plugin: vite:import-analysis\n File: C:/Users/foo/repro/src/app/app.ts:3:22\n 11 | import { Component, signal } from \"@angular/core\";\n 12 | import { RouterOutlet } from \"@angular/router\";\n 13 | import { greet } from \"#/util\";\n | ^\n 14 | export let App = class {\n 15 | title = signal(greet);\n```\n\n### Your Environment\n\n```text\nI've tried with `@angular/build` + `@angular/cli` at several versions, including `21.1.x` and `21.2.x`. Downgrading `vitest` to `4.0.8` fixes the issue, but `vitest@4.1.0` and `4.1.2` both failed.\n\n----------------------------------------\n\nAngular CLI : 21.2.5\nAngular : 21.2.6\nNode.js : 25.8.2 (Unsupported)\nPackage Manager : npm 11.11.1\nOperating System : win32 x64\n\n┌───────────────────────────┬───────────────────┬───────────────────┐\n│ Package │ Installed Version │ Requested Version │\n├───────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/build │ 21.2.5 │ ^21.1.5 │\n│ @angular/cli │ 21.2.5 │ ^21.1.5 │\n│ @angular/common │ 21.2.6 │ ^21.1.0 │\n│ @angular/compiler │ 21.2.6 │ ^21.1.0 │\n│ @angular/compiler-cli │ 21.2.6 │ ^21.1.0 │\n│ @angular/core │ 21.2.6 │ ^21.1.0 │\n│ @angular/forms │ 21.2.6 │ ^21.1.0 │\n│ @angular/platform-browser │ 21.2.6 │ ^21.1.0 │\n│ @angular/router │ 21.2.6 │ ^21.1.0 │\n│ rxjs │ 7.8.2 │ ~7.8.0 │\n│ typescript │ 5.9.3 │ ~5.9.2 │\n│ vitest │ 4.1.0 │ 4.1.0 │\n└───────────────────────────┴───────────────────┴───────────────────┘\n```\n\n### Anything else relevant?\n\nDoes not seem to be OS specific. The issue is on GitHub Actions on Ubuntu, and locally on Windows. ","author":{"url":"https://github.com/csvn","@type":"Person","name":"csvn"},"datePublished":"2026-03-27T23:30:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/32891/angular-cli/issues/32891"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a72d2af2-5f77-d1aa-97b9-25b7026c68bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8750:1793BD:2DA7399:3FA5AF9:6A633E99 |
| html-safe-nonce | e6b8c9fa1f35ad24ef2c5e1c070f9b46a916e0758454cb592d8c829c30595667 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzUwOjE3OTNCRDoyREE3Mzk5OjNGQTVBRjk6NkE2MzNFOTkiLCJ2aXNpdG9yX2lkIjoiNDg4Nzk0MzI5MDI2MzEyNTY1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6064d700a3e0ca8e53abf3d4f9dcf5c7143cef5e0a74b5b9cd9cb48120e7812d |
| hovercard-subject-tag | issue:4156467025 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/32891/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0146dad37ce05a72473d2951e2fff4600d6b339787e01bdc17f52600f7642b2a/angular/angular-cli/issues/32891 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0146dad37ce05a72473d2951e2fff4600d6b339787e01bdc17f52600f7642b2a/angular/angular-cli/issues/32891 |
| og:image:alt | Command test Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was vitest@4.0.8 Description I'm not sure if this i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | csvn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width