Skip to content

Commit

Permalink
fix: typechecking with Vue 2.7+
Browse files Browse the repository at this point in the history
Fixes #7213
  • Loading branch information
haoqunjiang committed Jun 27, 2022
1 parent 9245eb2 commit 5b57792
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/@vue/cli-plugin-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,24 @@ module.exports = (api, projectOptions) => {
// this plugin does not play well with jest + cypress setup (tsPluginE2e.spec.js) somehow
// so temporarily disabled for vue-cli tests
if (!process.env.VUE_CLI_TEST) {
let compilerPath
let compilerPath; let useCompilerSFC = false
try {
// Vue 2.7+
compilerPath = require.resolve('vue/compiler-sfc')
useCompilerSFC = true
} catch (e) {
if (isVue3) {
// Vue 3.0.0-3.2.12
compilerPath = require.resolve('@vue/compiler-sfc')
useCompilerSFC = true
} else {
// Vue <= 2.6
compilerPath = require.resolve('vue-template-compiler')
}
}

if (isVue3) {
if (useCompilerSFC) {
// only v5 supports the compiler-sfc API
config
.plugin('fork-ts-checker')
.use(require('fork-ts-checker-webpack-plugin-v5'), [{
Expand All @@ -116,6 +119,7 @@ module.exports = (api, projectOptions) => {
}
}])
} else {
// fallback to v3, in order to not introduce breaking changes to legacy projects
config
.plugin('fork-ts-checker')
.use(require('fork-ts-checker-webpack-plugin'), [{
Expand Down

0 comments on commit 5b57792

Please sign in to comment.