Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vue-template-compiler can be optional if @vue/compiler-sfc presents #5123

Merged
merged 1 commit into from Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions packages/@vue/cli-service/lib/config/base.js
Expand Up @@ -73,12 +73,21 @@ module.exports = (api, options) => {
// js is handled by cli-plugin-babel ---------------------------------------

// vue-loader --------------------------------------------------------------
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
'vue-loader': require('vue-loader/package.json').version,
/* eslint-disable-next-line node/no-extraneous-require */
'@vue/component-compiler-utils': require('@vue/component-compiler-utils/package.json').version,
'vue-template-compiler': require('vue-template-compiler/package.json').version
})
const vueLoaderCacheIdentifier = {
'vue-loader': require('vue-loader/package.json').version
}

// The following 2 deps are sure to exist in Vue 2 projects.
// But once we switch to Vue 3, they're no longer mandatory.
// (In Vue 3 they are replaced by @vue/compiler-sfc)
// So wrap them in a try catch block.
try {
vueLoaderCacheIdentifier['@vue/component-compiler-utils'] =
require('@vue/component-compiler-utils/package.json').version
vueLoaderCacheIdentifier['vue-template-compiler'] =
require('vue-template-compiler/package.json').version
} catch (e) {}
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', vueLoaderCacheIdentifier)

webpackConfig.module
.rule('vue')
Expand Down
3 changes: 3 additions & 0 deletions packages/@vue/cli-service/package.json
Expand Up @@ -94,6 +94,9 @@
},
"stylus-loader": {
"optional": true
},
"vue-template-compiler": {
"optional": true
}
},
"devDependencies": {
Expand Down