-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
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 files ignored when importing ts files from sibling directories #7932
Comments
Vite uses vite/packages/vite/src/node/plugins/esbuild.ts Lines 285 to 294 in 7f535ac
My guess is that since we only search from the root (which in this case the cc @dominikg |
I suppose adding { "workspaces": [] } |
@sapphi-red -- brilliant, yes, that fixes it for our use case! |
I mentioned the possibility of this happening in the PR that introduced it #7055 The suggestion to turn your setup into a monorepo/workspace is the correct one in my opinion. I'm not sure if importing source files from outside a workspace root should be a supported feature of vite. If vite wants to support this @bluwy suggestion to fall back to crawling for out of root files in tsconfck can be added. |
I would prefer to avoid adding more complexity. Maybe we could close this as there is an easy workaround. If later we see that more users are having issues we could also add a tip in the docs. |
Describe the bug
When importing a typescript file from a sibling directory to the vite directory, whether by relative imports or via an alias, neither the tsconfig.json settings of the vite directory nor of the sibling directory are applied.
To reproduce:
git clone https://github.com/gristow/vite-sibling-tsconfig.git
yarn
ornpm i
in thevite
subdirectoryyarn
ornpm i
in thesibling
directory.yarn dev
ornpm run dev
in thevite
subdirectory.In this demonstration, identical files (./vite/src/lib/mobxNonSiblingDemo and ./sibling/src/mobxSiblingDemo) are imported into App.svelte.
The tsconfig
compilerOptions.useDefineForClassFields
is respected and compiled correctly for the file in thevite/src/lib
directory, but not for the one in thesibling/src
directory. As a result, it becomes impossible to observe certain properties on mobx stores.Relevant Files:
Reproduction
https://github.com/gristow/vite-sibling-tsconfig
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: