-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Description
Vue version
3.4.27
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-akygzo?file=tsconfig.json
Steps to reproduce
Check the stackblitz, if tsconfig project reference to file is ok, but folder will fail
What is expected?

What is actually happening?
[plugin:vite:vue] [@vue/compiler-sfc] Failed to resolve import source "@/types".
System Info
No response
Any additional comments?
Actually there are two problems:
- Project reference didn't support folder
- For empty tsconfig or non-exists tsconfig, resolve absolute path will throw error.
whichincluded
is undefined inresolveWithTS
Why there are non-exists reference?
My project is a monorepo, use pnpm workspace, has packages a
, b
and c
, and there npm package name is @xx/xx-a
, @xx/xx-b
and @xx/xx-c
a
depsb
,b
depsc
- There are same
tsconfig.json
project reference to get better ts dev experience (e.g.a/tsconfig.json
ref to../b/tsconfig.json
) - pnpm will link
packages/a/node_modules/@xx/xx-b
topackages/b
, same asb
toc
In this case, tsconfig.json
in node_modules
will get wrong relative path, packages/a/node_modules/@xx/xx-b/tsconfig.json
ref to ../b/tsconfig.json
, which should be ../xx-b/tsconfig.json
Only make monorepo package dir name sync to package name could prevent this. (e.g. package @xx/xx-a
should use xx-a
directory)