Skip to content

Commit

Permalink
feat: log complete config in debug mode (#18289)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Oct 30, 2024
1 parent b9b01d5 commit 04f6736
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import { resolveSSROptions } from './ssr'
import { PartialEnvironment } from './baseEnvironment'
import { createIdResolver } from './idResolver'

const debug = createDebugger('vite:config')
const debug = createDebugger('vite:config', { depth: 10 })
const promisifiedRealpath = promisify(fs.realpath)

export interface ConfigEnv {
Expand Down
9 changes: 8 additions & 1 deletion packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const DEBUG = process.env.DEBUG

interface DebuggerOptions {
onlyWhenFocused?: boolean | string
depth?: number
}

export type ViteDebugScope = `vite:${string}`
Expand All @@ -165,7 +166,13 @@ export function createDebugger(
options: DebuggerOptions = {},
): debug.Debugger['log'] | undefined {
const log = debug(namespace)
const { onlyWhenFocused } = options
const { onlyWhenFocused, depth } = options

// @ts-expect-error - The log function is bound to inspectOpts, but the type is not reflected
if (depth && log.inspectOpts.depth == null) {
// @ts-expect-error - The log function is bound to inspectOpts, but the type is not reflected
log.inspectOpts.depth = options.depth
}

let enabled = log.enabled
if (enabled && onlyWhenFocused) {
Expand Down

0 comments on commit 04f6736

Please sign in to comment.