File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/@vue/cli-plugin-typescript Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff 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' ) , [ {
You can’t perform that action at this time.
0 commit comments