Skip to content

Commit

Permalink
chore: don't warn for noExternal not being resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jul 4, 2022
1 parent 3adbf05 commit 7e15cd7
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,15 @@ export async function addManuallyIncludedOptimizeDeps(
const optimizeDeps = getDepOptimizationConfig(config, ssr)
const optimizeDepsInclude = optimizeDeps?.include ?? []
if (optimizeDepsInclude.length || extra.length) {
const unableToOptimize = (id: string, msg: string) => {
if (optimizeDepsInclude.includes(id)) {
logger.warn(
`${msg}: ${colors.cyan(id)}, present in '${
ssr ? 'ssr.' : ''
}optimizeDeps.include'`
)
}
}
const resolve = config.createResolver({ asSrc: false, scan: true })
for (const id of [...optimizeDepsInclude, ...extra]) {
// normalize 'foo >bar` as 'foo > bar' to prevent same id being added
Expand All @@ -706,22 +715,11 @@ export async function addManuallyIncludedOptimizeDeps(
if (entry) {
if (isOptimizable(entry, optimizeDeps)) {
deps[normalizedId] = entry
} else if (optimizeDepsInclude.includes(id)) {
logger.warn(
`Cannot optimize dependency: ${colors.cyan(
id
)}, present in 'include'`
)
} else {
unableToOptimize(entry, 'Cannot optimize dependency')
}
} else {
const configOptionName = optimizeDepsInclude.includes(id)
? 'include'
: 'noExternal'
logger.warn(
`Failed to resolve dependency: ${colors.cyan(
id
)}, present in '${configOptionName}'`
)
unableToOptimize(id, 'Failed to resolve dependency')
}
}
}
Expand Down

0 comments on commit 7e15cd7

Please sign in to comment.