File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
packages/@vue/cli-service Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -73,12 +73,21 @@ module.exports = (api, options) => {
73
73
// js is handled by cli-plugin-babel ---------------------------------------
74
74
75
75
// vue-loader --------------------------------------------------------------
76
- const vueLoaderCacheConfig = api . genCacheConfig ( 'vue-loader' , {
77
- 'vue-loader' : require ( 'vue-loader/package.json' ) . version ,
78
- /* eslint-disable-next-line node/no-extraneous-require */
79
- '@vue/component-compiler-utils' : require ( '@vue/component-compiler-utils/package.json' ) . version ,
80
- 'vue-template-compiler' : require ( 'vue-template-compiler/package.json' ) . version
81
- } )
76
+ const vueLoaderCacheIdentifier = {
77
+ 'vue-loader' : require ( 'vue-loader/package.json' ) . version
78
+ }
79
+
80
+ // The following 2 deps are sure to exist in Vue 2 projects.
81
+ // But once we switch to Vue 3, they're no longer mandatory.
82
+ // (In Vue 3 they are replaced by @vue/compiler-sfc)
83
+ // So wrap them in a try catch block.
84
+ try {
85
+ vueLoaderCacheIdentifier [ '@vue/component-compiler-utils' ] =
86
+ require ( '@vue/component-compiler-utils/package.json' ) . version
87
+ vueLoaderCacheIdentifier [ 'vue-template-compiler' ] =
88
+ require ( 'vue-template-compiler/package.json' ) . version
89
+ } catch ( e ) { }
90
+ const vueLoaderCacheConfig = api . genCacheConfig ( 'vue-loader' , vueLoaderCacheIdentifier )
82
91
83
92
webpackConfig . module
84
93
. rule ( 'vue' )
Original file line number Diff line number Diff line change 94
94
},
95
95
"stylus-loader" : {
96
96
"optional" : true
97
+ },
98
+ "vue-template-compiler" : {
99
+ "optional" : true
97
100
}
98
101
},
99
102
"devDependencies" : {
You can’t perform that action at this time.
0 commit comments