Repository navigation
Description
Describe the bug
With resolve.tsconfigPaths: true, the dev server fails to resolve every module when a tsconfig.json in a parent directory, outside the project, cannot be loaded (for example, its extends package is not installed there):
Error: Tsconfig not found missing-package/tsconfig.json
The project's own tsconfig.json is valid. The file being resolved is matched by its include.
The trigger is the importer that the dev plugin container uses when the caller passes none:
// packages/vite/src/node/server/pluginContainer.ts (EnvironmentPluginContainer)
async resolveId(
rawId: string,
importer: string | undefined = join(
this.environment.config.root,
'index.html',
),oxc-resolver then runs tsconfig auto-discovery for that importer, <root>/index.html. No tsconfig include can match an .html file. So discovery walks past the project's tsconfig.json to the ancestor directories, as designed since #23459. It loads the parent's tsconfig.json, whose extends fails, and the error stops the resolve.
This is not the case from #23459. There, a real source file outside every include legitimately needed an ancestor tsconfig. Here, the only path that no tsconfig matches is the synthetic default importer. The parent tsconfig.json has nothing to do with the project.
Where this happens in practice
- Git worktrees nested inside another checkout, e.g.
<repo>/.claude/worktrees/<name>/(Claude Code), or<repo>/worktrees/<name>/. The parent checkout has the same tsconfig.json withextends: "@tsconfig/strictest/tsconfig.json", but it has nonode_modulesof its own, so the parent'sextendscannot resolve. - React Router framework mode. Its child compiler is a
createServer()instance that callstransformRequest()on route modules without an importer. Soreact-router buildfails as well asreact-router dev:[plugin react-router:build-client-route] … Error: Tsconfig not found @tsconfig/strictest/tsconfig.jsonfor every route.
rolldown/rolldown#11086 is the same pattern in Rolldown. There, the synthetic importer \0rolldown/runtime.js starts the walk.
Reproduction
Self-contained, see the steps below.
Steps to reproduce
parent/
├── tsconfig.json { "extends": "missing-package/tsconfig.json" }
└── app/
├── package.json { "type": "module", "devDependencies": { "vite": "8.3.2" } }
├── tsconfig.json { "include": ["src"] }
├── src/main.ts export const answer = 42;
└── repro.mjs
repro.mjs:
import { createServer } from "vite";
const server = await createServer({
configFile: false,
logLevel: "silent",
resolve: { tsconfigPaths: true },
server: { watch: null, hmr: false },
});
const root = server.config.root;
const { pluginContainer } = server.environments.client;
for (const importer of [undefined, `${root}/index.html`, `${root}/src/main.ts`]) {
const label = importer ? importer.replace(root, "<root>") : "(none)";
try {
const r = await pluginContainer.resolveId("/src/main.ts", importer);
console.log(`ok importer=${label} -> ${r?.id.replace(root, "<root>")}`);
} catch (e) {
console.log(`fail importer=${label} -> ${e.message.split("\n")[0]}`);
}
}
await server.close();cd parent/app && npm install && node repro.mjsActual:
fail importer=(none) -> Tsconfig not found missing-package/tsconfig.json
fail importer=<root>/index.html -> Tsconfig not found missing-package/tsconfig.json
ok importer=<root>/src/main.ts -> <root>/src/main.ts
server.transformRequest("/src/main.ts") fails the same way.
Expected: all three resolve to <root>/src/main.ts, as they do when parent/tsconfig.json is removed.
- Removing
parent/tsconfig.json→ allok. - Setting the top-level
tsconfig: "./tsconfig.json"option (feat: add top-leveltsconfigoption #23310) → allok. This is our current workaround. vite buildwith a lib entry on the same tree succeeds. Only the dev plugin container path is affected.
A possible fix is to skip tsconfig discovery for the default importer, or for importers that cannot be TS/JS sources such as .html. Another is to discover the tsconfig from root instead of from <root>/index.html.
System Info
System: macOS 26.6 (Darwin 25.6.0), arm64
Node: 24.18.0
npm: 11.16.0
vite: 8.3.2 (rolldown 1.2.12, oxc_resolver 11.24.3)Used Package Manager
npm
Logs
No response
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
fix: build a worktree checked out under .worktrees