Repository navigation
Description
Describe the bug
When resolve.tsconfigPaths: true is used and tsconfig.json contains references, path aliases fail to resolve when the importer is a virtual module (i.e., its module ID contains a query string, such as file.tsx?tsr-split=component generated by TanStack Router).
The resolution works correctly when:
- The importer is a regular file (no query string)
- All compiler options (including
paths) are merged into the roottsconfig.jsonwith noreferences - The
pathsare duplicated directly in the roottsconfig.jsonalongside thereferences
It fails when:
tsconfig.jsonhasreferencespointing to other configs- The
pathsare defined in a referenced tsconfig (e.g.,tsconfig.app.json) - The importer is a virtual module with a query string in its ID for example
This was confirmed by additional testing:
- Moving all content from
tsconfig.app.jsonintotsconfig.json(eliminatingreferences) fixes the issue - Adding
pathsdirectly to roottsconfig.jsonalongsidereferencesalso works — because Vite finds paths in root directly without needing to delegate to a referenced config. - Disabling TanStack Router's
autoCodeSplittingalso fixes the issue — because no virtual modules with query strings are generated, all importers are regular files, and path resolution works normally.
It looks to me, that the bug is exclusively triggered by virtual module importers (files with a query string in their ID).
Reproduction
Here is a reproduction repo : https://stackblitz.com/edit/vitejs-vite-zbpvcavb?file=src%2FApp.tsx
Steps to reproduce on your side :
- Create a Vite 8 + React + TypeScript project with the default project references setup
tsconfig.app.json (paths defined here, NOT in root):
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"]
}
},
"include": ["src"]
}vite.config.ts:
import tanstackRouter from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
// I use tanstack router because I encountred the issue with it.
plugins: [tanstackRouter(), react()],
resolve: { tsconfigPaths: true },
});- Use a path alias inside a route file (TanStack Router splits route files into virtual modules with
?tsr-split=componentin the ID):
// src/routes/index.tsx
import MyComponent from "@components/MyComponent.tsx";- Run
vite devorvite build.
Expected: @components/MyComponent.tsx resolves correctly.
Actual:
Rolldown failed to resolve import "@atoms/Button.tsx" from "/home/projects/vitejs-vite-zbpvcavb/src/routes/index.tsx?tsr-split=component".
This is most likely unintended because it can break your application at runtime.
The error always originates from a module ID containing a query string. Imports from regular files (without query strings) resolve correctly.
Workaround: See above when resolution works correctly.
System Info
System:
OS: macOS 26.3
CPU: (11) arm64 Apple M3 Pro
Memory: 87.88 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.13.0 - /home/.local/share/mise/installs/node/24.13.0/bin/node
npm: 11.6.2 - /home/.local/share/mise/installs/node/24.13.0/bin/npm
pnpm: 10.19.0 - /home/.local/share/mise/installs/node/24.13.0/bin/pnpm
Watchman: 2026.03.09.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 144.0.7559.60
Safari: 26.3
npmPackages:
@vitejs/plugin-react: ^6.0.1 => 6.0.1
vite: ^8.0.0 => 8.0.0Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines
- Read the docs
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate
- Make sure this is a Vite issue and not a framework-specific issue
- Check that this is a concrete bug
- The provided reproduction is a minimal reproducible example of the bug
Activity
psychobolt commentedon Mar 17, 2026
Some good use cases here. I originally left my issue comment in the rolldown project in case it's a upstream issue: rolldown/rolldown#8468 (comment)
yetdragon commentedon Mar 21, 2026
Related case:
Using Vite 8, Svelte, and
vite-plugin-svelte7 with the followingtsconfig.json:{ "compilerOptions": { "paths": { "$lib": ["./src/lib"], "$lib/*": ["./src/lib/*"] } } }and if you import a Svelte component with a
<style>block via the tsconfig path alias:vite buildfails with cryptic error, because the JS import resolves correctly, but the virtual CSS module thatvite-plugin-sveltegenerates fails to load.lightningcssthen receives the raw.sveltesource instead of compiled CSS:I see that, from #6828, relying on
tsconfig.jsonfor path aliasing is an anti-pattern, but I believe the error action should be more concrete than failing mysteriously.sapphi-red commentedon Mar 23, 2026
This will be fixed by oxc-project/oxc-resolver#1081.
Wassim24 commentedon Mar 25, 2026
Thank you @sapphi-red, this is great news !
chaotic-justice commentedon Apr 27, 2026
sharing a tanstack cf worker case which also build fails:
{ "extends": "@repo/typescript-config/vite-app.json", "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "incremental": true, "types": ["./worker-configuration.d.ts", "node", "vite/client"], "baseUrl": ".", "paths": { "@/*": ["./src/*"], "@monoshop/core": ["../../packages/core/src"], "@monoshop/ui": ["../../packages/ui/src"], "~ui/*": ["../../packages/ui/src/*"] } }, "include": ["src"], "exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"] }bennylii commentedon May 1, 2026
I can confirm this also affects Windows + Vue SFC with the same root cause.
On Windows 10,
vite devfails at the dependency scan phase when importing from@/aliases inside a.vuefile. Vue SFCs get a query string appended to their module ID (e.g.,App.vue?id=0), making them virtual modules just like the TanStack Router case.Error:
Minimal repro (same pattern, different trigger — Vue instead of TanStack Router):
https://github.com/bennylii/vite-tsconfig-repro
Affected versions: Vite 8.0.0 through 8.0.10 (all tested).
Note:
vite buildworks fine on Windows in this scenario — onlyvite devis affected. That differs slightly from the TanStack Router case where build also fails.mkarajohn commentedon May 8, 2026
We have the exact same issue with a tanstack router application, and it's a blocker for vite 8 adoption, right now.
the error we get:
The sometimes is different between failed build attempts
fix: temporary for fix alias imports on Vite
refactor: fixes on unified webapp structure (camunda#52822)