You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running Vite-related tools (e.g. Vitest) in a monorepo may mess up SvelteKit's generated.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.
More context from a previous discovery is available in this issue.
Running e.g. vitest or vite build from within packages/my-app will generate .svelte-kit/tsconfig.json as expected.
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.
Notable repro logs:
When running e.g. vitest, you'll see the Vite plugin log different values for process.cmd() vs 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).
The text was updated successfully, but these errors were encountered:
Describe the bug
Running Vite-related tools (e.g. Vitest) in a monorepo may mess up SvelteKit's generated
.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 thatprocess.cwd()
still points to SvelteKit's package dir by the time theconfigureServer
Vite plugin hook is invoked.More context from a previous discovery is available in this issue.
Reproduction
https://stackblitz.com/edit/sveltekit-vitest-tsconfig-hijack?file=README.md
Running e.g.
vitest
orvite build
from withinpackages/my-app
will generate.svelte-kit/tsconfig.json
as expected.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 SvelteKitdev
is running at the same time, that'll also bust the dev preview.Notable repro logs:
When running e.g.
vitest
, you'll see the Vite plugin log different values forprocess.cmd()
vsconfig.root
:Afterwards,
.sveltekit/tsconfig.json
is still expected to contain:However, the actual contents are:
(This is just a stub; other paths in
"include"
and"exclude"
are also affected.)System Info
(should be irrelevant - below from the Stackblitz repro)
Severity
serious, but I can work around it
Current workarounds:
dev
(also disable the Vitest VSCode extension!)or
vitest.workspace.js
file for nowAdditional Information
A Vitest contributor suggested to use
vite_config.root
instead ofprocess.cmd()
The Vite config root is available e.g. via
server.config.root
in theconfigureServer
Vite plugin hook, which could then be passed down as an argument (or some kind of context object).The text was updated successfully, but these errors were encountered: