We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
optionalDependencies
1 parent c6ab80f commit 7ea080bCopy full SHA for 7ea080b
packages/@vue/cli-service/lib/Service.js
@@ -159,7 +159,23 @@ module.exports = class Service {
159
const projectPlugins = Object.keys(this.pkg.devDependencies || {})
160
.concat(Object.keys(this.pkg.dependencies || {}))
161
.filter(isPlugin)
162
- .map(idToPlugin)
+ .map(id => {
163
+ if (
164
+ this.pkg.optionalDependencies &&
165
+ id in this.pkg.optionalDependencies
166
+ ) {
167
+ let apply = () => {}
168
+ try {
169
+ apply = require(id)
170
+ } catch (e) {
171
+ warn(`Optional dependency ${id} is not installed.`)
172
+ }
173
+
174
+ return { id, apply }
175
+ } else {
176
+ return idToPlugin(id)
177
178
+ })
179
plugins = builtInPlugins.concat(projectPlugins)
180
}
181
0 commit comments