Skip to content

Commit

Permalink
fix: warn on missing optional peer deps during build
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Jan 29, 2024
1 parent 997a695 commit c9d03eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,13 @@ export default new Proxy({}, {
}
}
if (id.startsWith(optionalPeerDepId)) {
const [, peerDep, parentDep] = id.split(':')
if (isProduction) {
this.warn(
`Could not resolve "${peerDep}" imported by "${parentDep}". Is it installed?`,
)
return `export default {}`
} else {
const [, peerDep, parentDep] = id.split(':')
return `throw new Error(\`Could not resolve "${peerDep}" imported by "${parentDep}". Is it installed?\`)`
}
}
Expand Down

0 comments on commit c9d03eb

Please sign in to comment.