Skip to content

[v8] Dev server's default importer <root>/index.html sends tsconfig auto-discovery into a parent directory's tsconfig.json, failing every resolve #23672

Closed

Description

@tobigumo

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 with extends: "@tsconfig/strictest/tsconfig.json", but it has no node_modules of its own, so the parent's extends cannot resolve.
  • React Router framework mode. Its child compiler is a createServer() instance that calls transformRequest() on route modules without an importer. So react-router build fails as well as react-router dev: [plugin react-router:build-client-route] … Error: Tsconfig not found @tsconfig/strictest/tsconfig.json for 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.mjs

Actual:

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 → all ok.
  • Setting the top-level tsconfig: "./tsconfig.json" option (feat: add top-level tsconfig option #23310) → all ok. This is our current workaround.
  • vite build with 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

Activity

  1. locked and limited conversation to collaborators on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions