Skip to content

Commit

Permalink
fix: compatibility with Vue 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Jun 16, 2022
1 parent 98c66c9 commit a648958
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/@vue/cli-plugin-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,23 @@ 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 vueCompilerPath
try {
// Vue 2.7+
vueCompilerPath = require.resolve('vue/compiler-sfc')
} catch (e) {
// Vue 2.6 and lower versions
vueCompilerPath = require.resolve('vue-template-compiler')
}

config
.plugin('fork-ts-checker')
.use(require('fork-ts-checker-webpack-plugin'), [{
typescript: {
extensions: {
vue: {
enabled: true,
compiler: isVue3 ? require.resolve('vue/compiler-sfc') : require.resolve('vue-template-compiler')
compiler: vueCompilerPath
}
},
diagnosticOptions: {
Expand Down
7 changes: 6 additions & 1 deletion packages/@vue/cli-service/lib/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ module.exports = (api, options) => {
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
'vue-loader': require('@vue/vue-loader-v15/package.json').version,
'@vue/component-compiler-utils': require('@vue/component-compiler-utils/package.json').version,
'vue-template-compiler': require('vue-template-compiler/package.json').version
})

try {
vueLoaderCacheConfig['vue-template-compiler'] = require('vue-template-compiler/package.json').version
} catch (e) {
// For Vue 2.7 projects, `vue-template-compiler` is not required
}

webpackConfig.resolve
.alias
.set(
Expand Down

0 comments on commit a648958

Please sign in to comment.