GeezerVison is showing github.com — LSP loads vite.config.ts with the server's cwd as root · Issue #3217 · voidzero-dev/vite-plus
LSP loads vite.config.ts with the server's cwd as root #3217DescriptionDescribe the bug
oxlint/oxfmt load vite.config.ts without a root (apps/shared/src-js/vite_plus_config.ts):
resolveConfig({ configFile: path }, "build")
Vite falls back to process.cwd(). In a multi-root workspace (oxc-project/oxc-vscode#418) that's another repo, so plugins resolve against it. TanStack Start fails:
Could not resolve entry for router entry: router in app-a/src
The failing project is plain Vite (no vite-plus), so lazyPlugins() from #1756 isn't available.
Fix: resolveConfig({ root: dirname(path), configFile: path }, "build").
Reproduction
No repo. Steps below.
Steps to reproduce
- Workspace with a Vite+ repo first, then a Vite + TanStack Start repo.
- Open in VS Code with the Oxc extension.
- Loading the second repo's config fails.
System Info
vp v1.3.0 (vite 8.3.4, oxlint 1.88.0, oxfmt 0.73.0)
Node 24.22.1, bun 1.4.4, macOS 27.0.1
Oxc VS Code 1.64.1
Used Package Manager
bun
Logs
Failed to load config: app-c/vite.config.ts
Error: Could not resolve entry for router entry: router in app-a/src
at resolveEntry (@tanstack/start-plugin-core/dist/esm/resolve-entries.js:30:45)
at BasicMinimalPluginContext.config (@tanstack/start-plugin-core/dist/esm/vite/plugin.js:55:29)
at runConfigHook (app-a/.../@voidzero-dev/vite-plus-core/dist/vite/node/chunks/...)
Validations
Activityleaysgur commented on Oct 27, 2026 I looked into this and there are 2 separate problems here.
1. Why a plain Vite project is evaluated in Vite+ mode
- In a multi-root workspace, the LSP uses the first binary found, and its mode, for every folder.
- So a plain Vite project in another folder happens to be evaluated in Vite+ mode.
This is the trigger of the reported case, and known limitation already tracked in: oxc-project/oxc-vscode#145, oxc-project/oxc-vscode#418
2. Vite+ projects fail in the same way
The same error happens for only Vite+ projects too, if their plugins are not wrapped with lazyPlugins.
- In Vite+ mode, oxlint/oxfmt discover
vite.config.* on the Rust side, then evaluate it with resolveConfig({ configFile: path }, "build").
configFile only selects the file to load.
- Then, Vite resolves
root as config.root ?? process.cwd().
- Plugin hooks run with that
root.
- TanStack Start resolves its entries (e.g.
router.tsx) from viteConfig.root || process.cwd().
- Whether
.lint/.fmt exists is checked after resolution, so a config without these fields still fails if a plugin throws.
- With the CLI,
cwd is usually the config's directory.
- With the LSP,
cwd is up to the editor, and is not the project for the second and later folders in a multi-root workspace.
(Suggested fix) Passing root: dirname(path) is not enough
Inline root overrides root set in the user's config.
// <dir>/vite.config.ts, with sources in <dir>/app/src
export default {
root: "app",
plugins: [tanstackStart()],
};
With inline root: dirname(path), TanStack Start looks for entries in <dir>/src, even from the CLI.
resolveViteConfig() in vite-plus already fails in this case, since it passes root: cwd.
|
return resolveConfig({ root: cwd }, 'build'); |
I verified this with @tanstack/react-start 1.169.4 and the oxlint LSP in Vite+ mode (workspace folders [other, project]):
|
no root, cwd=project |
no root, cwd=other |
root: "app", cwd=project |
root: "app", cwd=other |
| Current |
ok |
fails |
ok |
fails |
Inline root: dirname(path) |
ok |
ok |
fails |
fails |
So...
Proposal
Add a vite-plus API that loads a config file for tools, and use it from both Vite+ and Oxapps.
export async function resolveConfigFile(configFile: string) {
return withConfigMetadataResolution(async () => {
const configEnv = { command: "build", mode: "development", isSsrBuild: false, isPreview: false };
const loaded = await loadConfigFromFile(configEnv, configFile);
// Resolve the user's `root` from the config's directory, instead of `cwd`
const root = path.resolve(path.dirname(configFile), loaded.config.root ?? "");
const config = await resolveConfig({ ...loaded.config, root, configFile: false }, "build");
// Restore what `configFile: false` drops (used by `vp pack` watch, etc.)
config.configFile = loaded.path;
config.configFileDependencies = loaded.dependencies;
return config;
});
}
root no longer depends on cwd, and the user's root is kept.
- The config is evaluated once, and
lazyPlugins is skipped as before.
- Known differences from the current behavior:
configEnv.isSsrBuild in plugin hooks follows build.ssr in the user config.
resolved.inlineConfig contains the user config.
- If these matter, we can load the config twice instead: once to read
root, then resolveConfig({ root, configFile }).
- oxlint/oxfmt call this instead of
resolveConfig().
Plugins still run with side effects while reading .lint/.fmt, unless wrapped with lazyPlugins.
e.g. TanStack Start's router generator scans src/routes.
TL;DR: In short, what we need to do is:
- lock the
root to the configDir,
- while still letting the user override it if they specify one
@fengmk2 Thoughts...? Reacted by Daniel Costrasel Reacted by JongKyung Lee fengmk2 commented on Oct 27, 2026 It seems that Vite+'s default root is incomplete.
@leaysgur LGTM 👍, and I can help to testing it after your pr submit. Reacted by Yuji Sugiura Reacted by Daniel Costrasel fengmk2 commented on Nov 20, 2026 @ohkimur The config root fix shipped in Vite+ 1.6.0. I verified it on 1.7.0 without patches using the reproduction repo.
I started both language servers from another workspace folder. Oxlint and Oxfmt loaded the TanStack Start config with both the default root and root: 'app'. I also confirmed that Oxlint reported no-console and Oxfmt respected semi: false from the project config.
The VS Code extension’s choice of server binary in a multi-root workspace is tracked separately in oxc-vscode#418.
Could you try 1.7.0 in your original workspace and confirm whether the router entry error is gone?
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|