fi3ework/vite-plugin-checker

Stopped working with vue-tsc 2.0.1

azygis opened this issue ยท 36 comments

Describe the bug

Since file structuring changed in vue-tsc 2+, checker plugin no longer works as it expects file being in the exact location:

Error: Cannot find module 'vue-tsc/out/index'
Require stack:
- /home/runner/work/pikeo-web/pikeo-web/src/frontend/node_modules/vite-plugin-checker/dist/esm/checkers/vueTsc/prepareVueTsc.js
...

Reproduction

Install checker plugin, vue-tsc 2.0.1 and enable vueTsc checker.

Expected behavior

Plugin works.

System Info

N/A. Sorry, filling this issue on my phone since I've noticed the issue in my CI build after dependabot update.

Additional context

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

There's been a breaking change since vue-tsc@2. I took a look into the code and found that it's impossible to use the former method to integrate with vue-tsc ๐Ÿฅฒ.
Since vuejs/language-tools did a lot of great works, which makes the API is not easy to find. Friendly ping @johnsoncodehk, could you give some hint to helping integrate with vue-tsc@2 with vite-pluign-checker. Many thanks!

Some brief conditions:

  • The most important feature is to override sendDiagnostics so that the plugin could receive the diagnostics and render it to the browser.
  • The plugin could start a watcher with chokidar if needed.

Maybe pin this issue?

error when starting dev server:
Error: Cannot find module 'vue-tsc/out/index'
Require stack:
- /Users/www/frontend/admin/node_modules/vite-plugin-checker/dist/esm/checkers/vueTsc/prepareVueTsc.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at file:///Users/www/frontend/admin/node_modules/vite-plugin-checker/dist/esm/checkers/vueTsc/prepareVueTsc.js:11:31
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async createCheckers (file:///Users/www/frontend/admin/node_modules/vite-plugin-checker/dist/esm/main.js:30:37)
    at async config (file:///Users/www/frontend/admin/node_modules/vite-plugin-checker/dist/esm/main.js:63:18)
    at async runConfigHook (file:///Users/www/frontend/admin/node_modules/vite/dist/node/chunks/dep-G-px366b.js:68219:25)
    at async resolveConfig (file:///Users/www/frontend/admin/node_modules/vite/dist/node/chunks/dep-G-px366b.js:67678:14)
    at async _createServer (file:///Users/www/frontend/admin/node_modules/vite/dist/node/chunks/dep-G-px366b.js:64286:20)
    ```

@fi3ework I don't know exactly how vite-plugin-checker works, but I tried to replace some API changes that I know for your reference, please let me know if you need any other help.
johnsoncodehk/vite-plugin-dts@43b00de (I found this is vite-plugin-dts not vite-plugin-checker, will check vite-plugin-checker later.)

I used pnpm patch to patch dist/esm/checkers/vueTsc/prepareVueTsc.js, and changed _require.resolve("vue-tsc/out/index"); to _require.resolve("vue-tsc/index");. This seems to have fixed the issue for me.

@netroy define "fixed the issue"? If it builds, but doesn't actually report the problems anymore when there are some, it's not a fix. To me it did not report (at least all; if any) issues in the code.

If it builds, but doesn't actually report the problems anymore when there are some, it's not a fix

Seems to report the exact same set of errors for me as it did before the upgrade.

image

@netroy did you run pnpm patch-commit <tmp-folder-path> after modifying the file? did you update vue-tsc to version 2.0+ before patching it? Because that's what I also did and it didn't work either.

This is vite-plugin-checker@0.6.2.patch for reference:

index 4476f608f93257896c67e0fa525562433733a87c..aaea600badc20dc11cee87deac2f9554abf16fc9 100644
--- a/dist/cjs/checkers/vueTsc/prepareVueTsc.js
+++ b/dist/cjs/checkers/vueTsc/prepareVueTsc.js
@@ -42,7 +42,7 @@ const { copy, mkdir } = import_fs_extra.default;
 const _require = (0, import_module.createRequire)(importMetaUrl);
 const _filename = (0, import_url.fileURLToPath)(importMetaUrl);
 const _dirname = (0, import_path.dirname)(_filename);
-const proxyApiPath = _require.resolve("vue-tsc/out/index");
+const proxyApiPath = _require.resolve("vue-tsc/index");
 async function prepareVueTsc() {
   const targetTsDir = import_path.default.resolve(_dirname, "typescript-vue-tsc");
   const vueTscFlagFile = import_path.default.resolve(targetTsDir, "vue-tsc-resolve-path");
diff --git a/dist/esm/checkers/vueTsc/prepareVueTsc.js b/dist/esm/checkers/vueTsc/prepareVueTsc.js
index 94334b8862feddf28cf32cad5a67112eb3a58cec..f5693c9b8ec1b74e54cb18c9ba72bac3b761d231 100644
--- a/dist/esm/checkers/vueTsc/prepareVueTsc.js
+++ b/dist/esm/checkers/vueTsc/prepareVueTsc.js
@@ -8,7 +8,7 @@ const { copy, mkdir } = fsExtra;
 const _require = createRequire(import.meta.url);
 const _filename = fileURLToPath(import.meta.url);
 const _dirname = dirname(_filename);
-const proxyApiPath = _require.resolve("vue-tsc/out/index");
+const proxyApiPath = _require.resolve("vue-tsc/index");
 async function prepareVueTsc() {
   const targetTsDir = path.resolve(_dirname, "typescript-vue-tsc");
   const vueTscFlagFile = path.resolve(targetTsDir, "vue-tsc-resolve-path");

As the author said, there are breaking changes in vue-tsc@^2 which means the current integration won't work with it. We just have to patiently wait for him or @johnsoncodehk to save the day ๐Ÿ˜„ , in the meantime use vue-tsc@^1.8.27!

same error

@johnsoncodehk @fi3ework is there any chance this will be upgraded?