We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation .
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsconfig.json
Running Vite-related tools (e.g. Vitest) in a monorepo may mess up SvelteKit's generated .svelte-kit/tsconfig.json .
.svelte-kit/tsconfig.json
Looks like the Vite plugin currently uses process.cwd() in async functions. However, due to a race condition, it's not guaranteed that process.cwd() still points to SvelteKit's package dir by the time the configureServer Vite plugin hook is invoked.
process.cwd()
configureServer
More context from a previous discovery is available in this issue .
https://stackblitz.com/edit/sveltekit-vitest-tsconfig-hijack?file=README.md
Running e.g. vitest or vite build from within packages/my-app will generate .svelte-kit/tsconfig.json as expected.
vitest
vite build
packages/my-app
However, running vitest from the root monorepo dir can cause .svelte-kit/tsconfig.json to be generated with unexpected relative paths pointing to other packages. If SvelteKit dev is running at the same time, that'll also bust the dev preview.
dev
Notable repro logs:
When running e.g. vitest , you'll see the Vite plugin log different values for process.cmd() vs config.root :
process.cmd()
config.root
[cwd-vs-config-root] process.cwd: /home/projects/sveltekit-vitest-tsconfig-hijack/packages/z-another-app [cwd-vs-config-root] config.root: /home/projects/sveltekit-vitest-tsconfig-hijack/packages/my-app
Afterwards, .sveltekit/tsconfig.json is still expected to contain:
.sveltekit/tsconfig.json
{ "compilerOptions" : { "paths" : { "$myAlias" : [ "../src/myAlias" ] , "$myAlias/*" : [ "../src/myAlias/*" ] , // ... } , "rootDirs" : [ ".." , "./types" ] , // ... } }
However, the actual contents are:
{ "compilerOptions" : { "paths" : { "$myAlias" : [ "../../z-another-app/src/myAlias" ] , "$myAlias/*" : [ "../../z-another-app/src/myAlias/*" ] , // ... } , "rootDirs" : [ "../../z-another-app" , "./types" ] , // ... } }
(This is just a stub; other paths in "include" and "exclude" are also affected.)
"include"
"exclude"
(should be irrelevant - below from the Stackblitz repro)
System: OS: Linux 5.0 undefined CPU: (6) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.18.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.3 - /usr/local/bin/pnpm
serious, but I can work around it
Current workarounds:
vitest.workspace.js
A Vitest contributor suggested to use vite_config.root instead of process.cmd()
vite_config.root
The Vite config root is available e.g. via server.config.root in the configureServer Vite plugin hook, which could then be passed down as an argument (or some kind of context object).
server.config.root
The text was updated successfully, but these errors were encountered:
No branches or pull requests