Skip to content

Commit

Permalink
chore: better instruction for deps requiring deep import
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 30, 2020
1 parent a0272f0 commit f1cfee2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/node/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,14 @@ export function resolveBareModuleRequest(
if (resolveOptimizedModule(root, depId)) {
console.error(
chalk.yellow(
`\n[vite] Avoid deep import "${id}" since "${depId}" is a ` +
`pre-optimized dependency.\n` +
`Prefer importing from the module directly.\n` +
`Importer: ${importer}\n`
`\n[vite] Avoid deep import "${id}" (imported by ${importer})\n` +
`because "${depId}" has been pre-optimized by vite into a single file.\n` +
`Prefer importing directly from the module entry:\n` +
chalk.cyan(`\n import { ... } from "${depId}" \n\n`) +
`If the dependency requires deep import to function properly, \n` +
`add it to ${chalk.cyan(
`optimizeDeps.exclude`
)} in vite.config.js.\n`
)
)
}
Expand Down

0 comments on commit f1cfee2

Please sign in to comment.