Skip to content
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 project reference didn't support folder #10907

Open
cyrilluce opened this issue May 11, 2024 · 0 comments · May be fixed by #10908
Open

tsconfig project reference didn't support folder #10907

cyrilluce opened this issue May 11, 2024 · 0 comments · May be fixed by #10908
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: sfc

Comments

@cyrilluce
Copy link

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?

image

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.
    which included is undefined in resolveWithTS
    image
    image

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 deps b, b deps c
  • 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 to packages/b, same as b to c

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)

cyrilluce pushed a commit to cyrilluce/vuejs-core that referenced this issue May 11, 2024
@sodatea sodatea added scope: sfc 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: sfc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants