Skip to content

Commit 5b57792

Browse files
committed
fix: typechecking with Vue 2.7+
Fixes #7213
1 parent 9245eb2 commit 5b57792

File tree

1 file changed

+6
-2
lines changed
  • packages/@vue/cli-plugin-typescript

1 file changed

+6
-2
lines changed

packages/@vue/cli-plugin-typescript/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,24 @@ module.exports = (api, projectOptions) => {
8383
// this plugin does not play well with jest + cypress setup (tsPluginE2e.spec.js) somehow
8484
// so temporarily disabled for vue-cli tests
8585
if (!process.env.VUE_CLI_TEST) {
86-
let compilerPath
86+
let compilerPath; let useCompilerSFC = false
8787
try {
8888
// Vue 2.7+
8989
compilerPath = require.resolve('vue/compiler-sfc')
90+
useCompilerSFC = true
9091
} catch (e) {
9192
if (isVue3) {
9293
// Vue 3.0.0-3.2.12
9394
compilerPath = require.resolve('@vue/compiler-sfc')
95+
useCompilerSFC = true
9496
} else {
9597
// Vue <= 2.6
9698
compilerPath = require.resolve('vue-template-compiler')
9799
}
98100
}
99101

100-
if (isVue3) {
102+
if (useCompilerSFC) {
103+
// only v5 supports the compiler-sfc API
101104
config
102105
.plugin('fork-ts-checker')
103106
.use(require('fork-ts-checker-webpack-plugin-v5'), [{
@@ -116,6 +119,7 @@ module.exports = (api, projectOptions) => {
116119
}
117120
}])
118121
} else {
122+
// fallback to v3, in order to not introduce breaking changes to legacy projects
119123
config
120124
.plugin('fork-ts-checker')
121125
.use(require('fork-ts-checker-webpack-plugin'), [{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy