vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.79k stars 390 forks source link

Version v2.0.28 can't resolve .vue files #4632

Closed scandar closed 1 month ago

scandar commented 2 months ago

Vue - Official extension or vue-tsc version

v2.0.26

VSCode version

Version: 1.91.1 (Universal)

Vue version

3.3.13

TypeScript version

5.4.5

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 186.03 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.15.1/bin/npm
    pnpm: 9.4.0 - ~/.nvm/versions/node/v20.15.1/bin/pnpm
  Browsers:
    Safari: 17.5

Steps to reproduce

in a pnpm monorepo with this structure apps |_foo packages |_ui

packages/ui includes vue components, when a component is imported from packages/ui in apps/foo vscode shows this error.

Cannot find module "path to component" or its corresponding type declarations

reverting to a previous version doesn't show the error

What is expected?

The component should be resolved properly

What is actually happening?

Cannot find module "path to component" or its corresponding type declarations

Link to minimal reproduction

No response

Any additional comments?

No response

arpadgabor commented 1 month ago

Seeing the same issue here. Reverted to 2.0.26 and all is fine now. We have a similar project structure with components in another package in a monorepo. We also have the vscode file watcher disabled.

davidmatter commented 1 month ago

Can't reproduce. Please provide a minimal example repo

arpadgabor commented 1 month ago

Here you go (check in app/src/App.vue):

https://github.com/arpadgabor/vue-volar-bug-repro

And here are a couple of screenshot with the behaviour in VSCode in v2.0.28 vs v2.0.26:

2.0.28 2.0.26

davidmatter commented 1 month ago

Workaround for now:

app/tsconfig.json:

image
bosens-China commented 1 month ago

follow with interest

bosens-China commented 1 month ago

Workaround for now:

app/tsconfig.json: image

This solution is ineffective

image

KazariEX commented 1 month ago

Please try updating all dependencies to the latest version.

davidmatter commented 1 month ago

Confirmed, pnpm update -r solves this

Update: Only until you reload the window. We need to look into this

scandar commented 1 month ago

@davidmatter it would be better to identify the exact dependency that I should update.

dbarjs commented 1 month ago

This issue is affecting external component libraries.

Here is an example of the use of the nuxt-mapbox Nuxt module installed with version v2.0.28: Screenshot from 2024-08-08 13-17-36

It only happens with .vue components using the script setup.

Example 1: This component from the @nuxt/content module works correctly (the .d.ts file is available in the dist): https://github.com/nuxt/content/blob/main/docs/components/content/Example/ExampleTitle.vue

Example 2: This component from nuxt-mapbox doesn't work (it does not have a .d.ts file in the dist): https://github.com/AlexLavoie42/Nuxt-Mapbox/blob/main/src/runtime/components/Map.vue

Both examples above work correctly with version v2.0.26 installed on VSCode.

Gehbt commented 1 month ago

Script block is don't matter. If restart the server, it will degrade to any, too. Only at new files or renamed files could be correctly get the type.

codethief commented 1 month ago

For anyone else coming here who like me thought the ticket might be about project references (i.e. similar to https://github.com/vuejs/language-tools/issues/4711): OP's example code does involve project references but it uses separate pnpm workspaces for their folders /app and /ui (each with its own solution-style tsconfig.json) and then they include the /ui workspace in their /app/package.json:

  "dependencies": {
    "ui":"workspace:*",

so as to make it available in their app's node_modules. So the issue seems to be not so much about project references (https://github.com/vuejs/language-tools/issues/4711) but more similar in nature to https://github.com/vuejs/language-tools/issues/4611 and https://github.com/vuejs/language-tools/issues/4607 (though of course maybe those issues are all the same under the hood – I have no idea).