-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
91 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import debug from 'debug' | ||
|
||
// set in bin/vite.js | ||
const filter = process.env.VITE_DEBUG_FILTER | ||
|
||
const DEBUG = process.env.DEBUG | ||
|
||
interface DebuggerOptions { | ||
onlyWhenFocused?: boolean | string | ||
} | ||
|
||
export type ViteDebugScope = `vite:${string}` | ||
|
||
export function createDebugger( | ||
ns: string, | ||
options: DebuggerOptions = {} | ||
): debug.Debugger['log'] { | ||
const log = debug(ns) | ||
const { onlyWhenFocused } = options | ||
const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : ns | ||
return (msg: string, ...args: any[]) => { | ||
if (filter && !msg.includes(filter)) { | ||
return | ||
} | ||
if (onlyWhenFocused && !DEBUG?.includes(focus)) { | ||
return | ||
} | ||
log(msg, ...args) | ||
} | ||
} | ||
|
||
export const DebugScopes: Record<string, ViteDebugScope> = Object.freeze({ | ||
CACHE: 'vite:cache', | ||
CONFIG: 'vite:config', | ||
DEPS: 'vite:deps', | ||
ESBUILD: 'vite:esbuild', | ||
HMR: 'vite:hmr', | ||
LOAD: 'vite:load', | ||
PLUGIN_RESOLVE: 'vite:plugin-resolve', | ||
PLUGIN_TRANSFORM: 'vite:plugin-transform', | ||
PROXY: 'vite:proxy', | ||
RESOLVE: 'vite:resolve', | ||
RESOLVE_DETAILS: 'vite:resolve-details', | ||
REWRITE: 'vite:rewrite', | ||
SOURCEMAP: 'vite:sourcemap', | ||
SPA_FALLBACK: 'vite:spa-fallback', | ||
TIME: 'vite:time', | ||
TRANSFORM: 'vite:transform' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.