Skip to content

Commit

Permalink
feat: show all prebundle deps when debug (#6726)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Mar 4, 2022
1 parent a4927c5 commit e626055
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/vite/src/node/optimizer/index.ts
@@ -1,5 +1,6 @@
import fs from 'fs'
import path from 'path'
import _debug from 'debug'
import colors from 'picocolors'
import { createHash } from 'crypto'
import type { BuildOptions as EsbuildBuildOptions } from 'esbuild'
Expand All @@ -21,6 +22,7 @@ import { transformWithEsbuild } from '../plugins/esbuild'
import { performance } from 'perf_hooks'

const debug = createDebugger('vite:deps')
const isDebugEnabled = _debug('vite:deps').enabled

export type ExportsData = ReturnType<typeof parse> & {
// es-module-lexer has a facade detection but isn't always accurate for our
Expand Down Expand Up @@ -339,14 +341,20 @@ export async function createOptimizeDepsRun(
return
}

const total = qualifiedIds.length
const maxListed = 5
const listed = Math.min(total, maxListed)
const extra = Math.max(0, total - maxListed)
const depsString = colors.yellow(
qualifiedIds.slice(0, listed).join(`\n `) +
(extra > 0 ? `\n (...and ${extra} more)` : ``)
)
let depsString: string
if (isDebugEnabled) {
depsString = colors.yellow(qualifiedIds.join(`\n `))
} else {
const total = qualifiedIds.length
const maxListed = 5
const listed = Math.min(total, maxListed)
const extra = Math.max(0, total - maxListed)
depsString = colors.yellow(
qualifiedIds.slice(0, listed).join(`\n `) +
(extra > 0 ? `\n (...and ${extra} more)` : ``)
)
}

if (!asCommand) {
if (!newDeps) {
// This is auto run on server start - let the user know that we are
Expand Down

0 comments on commit e626055

Please sign in to comment.