vuejs / language-tools

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

v2.0.29-v2.1.2 incompatibility of vite-plugin-checker with vuejs/language-tools #4755

Closed os-tohe closed 2 months ago

os-tohe commented 2 months ago

Vue - Official extension or vue-tsc version

v2.0.29

VSCode version

1.92.2

Vue version

3.4.38

TypeScript version

5.5.4

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
    Memory: 4.32 GB / 14.83 GB
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.7.0 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.19041.4355

Steps to reproduce

Install version any version between v2.0.29-v2.1.2 and start the Vue 3 vite project.

What is expected?

Vue 3 project should start.

What is actually happening?

Throws this error and fails starting:

node:internal/event_target:1100
  process.nextTick(() => { throw err; });
                           ^
TypeError [Error]: pluginContext.vueCompilerOptions.plugins is not iterable
    at createPlugins (C:\path\node_modules\@vue\language-core\lib\plugins.js:48:45)
    at Object.createVueLanguagePlugin (C:\path\node_modules\@vue\language-core\lib\languagePlugin.js:52:49)
    at exports.getLanguagePlugins (C:\path\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\languagePlugins.cjs:30:33)
    at Object.apply (C:\path\node_modules\@volar\typescript\lib\node\proxyCreateProgram.js:50:33)
    at getBuilderCreationParameters (C:\path\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\typescript-vue-tsc\lib\typescript.js:128533:18)
    at createSemanticDiagnosticsBuilderProgram (C:\path\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\typescript-vue-tsc\lib\typescript.js:129027:74)
    at synchronizeProgram (C:\path\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\typescript-vue-tsc\lib\typescript.js:131054:7)
    at Object.createWatchProgram (C:\path\node_modules\vite-plugin-checker\dist\esm\checkers\vueTsc\typescript-vue-tsc\lib\typescript.js:130960:3)
    at Object.configureServer (file:///C:/path/node_modules/vite-plugin-checker/dist/esm/checkers/vueTsc/main.js:103:13)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:326:10)
    at MessagePort.<anonymous> (node:internal/worker:232:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

Node.js v20.11.0

Link to minimal reproduction

No response

Any additional comments?

No response

KazariEX commented 2 months ago

Does the tsconfig.json exist?

os-tohe commented 2 months ago

Yes it looks like this:

{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "compilerOptions": {
    "lib": ["ES2021", "DOM", "DOM.Iterable"],
    "paths": {
      "@/*": [
        "./src/*"
      ]
    },
    "types": [
      "node", "vitest/globals"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.d.ts",
    "src/**/*.tsx",
    "src/**/*.vue"
  ],
  "references": [
    {
      "path": "./tsconfig.node.json"
    }
  ]
}

And tsconfig.node.json looks like this:

{
  "compilerOptions": {
    "composite": true,
    "module": "esnext",
    "moduleResolution": "node"
  },
  "include": ["vite.config.ts"]
}
KazariEX commented 2 months ago

Try adding this and check again:

{
  "vueCompilerOptions": {
    "plugins": []
  }
}

And it would be best to provide a minimal repro.

os-tohe commented 2 months ago

That does not seem to help, but I noticed a strange thing about this version. If I install the version like this: "vue-tsc": "2.0.29" it does not throw any errors. But if I install it with the ^ prefix like this: "vue-tsc": "^2.0.29" it throws the error. The version 2.1.2 throws the error with or without ^ prefix. I'll provide a minimal repro when I have more time available.

Paxton0222 commented 2 months ago

I encountered this error when enabling vue-tsc with vite-plugin-checker.

I traced the issue to possibly being caused by this: https://github.com/vuejs/language-tools/blob/v2.1.2/packages/language-core/lib/languagePlugin.ts#L51.

It appears to be an issue caused by incorrect parameter injection.

davidmatter commented 2 months ago

Spot-on: https://github.com/fi3ework/vite-plugin-checker/blob/b2c32367cf2e410154194d7730d8830aace898d9/packages/vite-plugin-checker/src/checkers/vueTsc/languagePlugins.cjs#L30

Would you please open an issue with them? It seems they're not compatible anymore.

ohchi commented 2 months ago

I have the same issue: vue-tsc@2.1.2 vue@3.4.38 vite-plugin-checker@0.7.2 typescript@5.5.4 Actually pluginContext.vueCompilerOptions.plugins is not iterable because it's undefined.

davidmatter commented 2 months ago

I've opened a PR with them https://github.com/fi3ework/vite-plugin-checker/pull/395

nielsvh2103 commented 2 months ago

Same issue here, still happens on 2.1.4 using vite plugin checker 0.7.2, works as long as you pin vue-tsc at 2.0.29 for now

This issue only happens when you are between 2.1.0 - 2.1.4

andrija-menuapp commented 2 months ago

Same issue here

jiikoosol commented 2 months ago

I have the same issue

daniluk4000 commented 2 months ago

Opened another PR to resolve this on checker level

https://github.com/fi3ework/vite-plugin-checker/pull/398

gaomingzhao666 commented 2 months ago

same issue in vue-tsc@2.1.6

nielsvh2103 commented 2 months ago

same issue in vue-tsc@2.1.6

it was merged this morning, if you update to vue-tsc@2.1.6 with vite-plugin-checker 0.8.0 it should work. Or if you dont use vite plugin checker, it should also work on latest vue version running on vue-tsc@2.1.6

if this doesnt work after updating i suggest opening a new issue

andrija-menuapp commented 2 months ago

Does not work on "vue": "^3.5.3", "vue-tsc": "^2.1.6", "nuxt": "^3.13.1"

KazariEX commented 2 months ago

Please open a new issue if the problem still occurs on your end!

daniluk4000 commented 2 months ago

Hey folks. Since plugin checker released this as "major" (in terms of 0.x versioining) version, Nuxt has to update dependency on their side first - and they did that, fix will be available in next patch.

For now, you can pin resolution in any way you like, fix example:

 "resolutions": {
    "vite-plugin-checker": "^0.8.0"
  },
yansiegers commented 2 months ago

Next patch of Nuxt is available: https://github.com/nuxt/nuxt/releases/tag/v3.13.2

andrija-menuapp commented 2 months ago

Next patch of Nuxt is available: https://github.com/nuxt/nuxt/releases/tag/v3.13.2

Can confirm that the error is fixed for me Thanks