Skip to content

Commit

Permalink
fix: require vue-tsc >= 1.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Apr 30, 2023
1 parent 6d3887d commit 69a73a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/vite-plugin-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"vite": ">=2.0.0",
"vls": "*",
"vti": "*",
"vue-tsc": "*"
"vue-tsc": ">=1.3.9"
},
"peerDependenciesMeta": {
"eslint": {
Expand Down
17 changes: 2 additions & 15 deletions packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 69a73a9

Please sign in to comment.