From 69a73a994eb22e5d116f6e69ad7c4d6d9d5949e1 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Mon, 1 May 2023 00:14:40 +0800 Subject: [PATCH] fix: require vue-tsc >= 1.3.9 --- packages/vite-plugin-checker/package.json | 2 +- .../src/checkers/vueTsc/prepareVueTsc.ts | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/packages/vite-plugin-checker/package.json b/packages/vite-plugin-checker/package.json index 3be3473f..f989bf16 100644 --- a/packages/vite-plugin-checker/package.json +++ b/packages/vite-plugin-checker/package.json @@ -68,7 +68,7 @@ "vite": ">=2.0.0", "vls": "*", "vti": "*", - "vue-tsc": "*" + "vue-tsc": ">=1.3.9" }, "peerDependenciesMeta": { "eslint": { diff --git a/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts b/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts index 7cabaa8f..dc046230 100644 --- a/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts +++ b/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts @@ -11,20 +11,7 @@ const _require = createRequire(import.meta.url) // isomorphic __dirname https://antfu.me/posts/isomorphic-dirname const _filename = fileURLToPath(import.meta.url) const _dirname = dirname(_filename) - -let proxyApiPath: string -let createProgramFunction: string -try { - // vue-tsc exposes the proxy in vue-tsc/out/index after v1.0.14 - proxyApiPath = _require.resolve('vue-tsc/out/index') - createProgramFunction = 'createProgram' -} catch (e) { - // @deprecated - // will be removed in 0.6.0 - // vue-tsc exposes the proxy in vue-tsc/out/proxy before v1.0.14 - proxyApiPath = _require.resolve('vue-tsc/out/proxy') - createProgramFunction = 'createProgramProxy' -} +const proxyApiPath = _require.resolve('vue-tsc/out/index') export async function prepareVueTsc() { // 1. copy typescript to folder @@ -76,7 +63,7 @@ async function overrideTscJs(tscJsPath: string, version: string) { tryReplace( /function createProgram\(.+\) {/, (s: string) => - s + ` return require(${JSON.stringify(proxyApiPath)}).${createProgramFunction}(...arguments);` + s + ` return require(${JSON.stringify(proxyApiPath)}).createProgram(...arguments);` ) // patches logic for checking root file extension in build program for incremental builds