mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-15 22:05:22 -05:00
fix: should not throw when a plugin listed in optionalDependencies is not installed
This bug is due to `normalize-package-data` (required by `read-pkg`) adding `optionalDependencies` to `dependencies`.
This commit is contained in:
@@ -159,7 +159,23 @@ module.exports = class Service {
|
||||
const projectPlugins = Object.keys(this.pkg.devDependencies || {})
|
||||
.concat(Object.keys(this.pkg.dependencies || {}))
|
||||
.filter(isPlugin)
|
||||
.map(idToPlugin)
|
||||
.map(id => {
|
||||
if (
|
||||
this.pkg.optionalDependencies &&
|
||||
id in this.pkg.optionalDependencies
|
||||
) {
|
||||
let apply = () => {}
|
||||
try {
|
||||
apply = require(id)
|
||||
} catch (e) {
|
||||
warn(`Optional dependency ${id} is not installed.`)
|
||||
}
|
||||
|
||||
return { id, apply }
|
||||
} else {
|
||||
return idToPlugin(id)
|
||||
}
|
||||
})
|
||||
plugins = builtInPlugins.concat(projectPlugins)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user