Skip to content

Commit

Permalink
fix: cjs warning respect the logLevel flag (#17993)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Sep 2, 2024
1 parent 0ca53cf commit dc3c14f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/vite/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ asyncFunctions.forEach((name) => {

function warnCjsUsage() {
if (process.env.VITE_CJS_IGNORE_WARNING) return
const logLevelIndex = process.argv.findIndex((arg) =>
/^(?:-l|--logLevel)/.test(arg),
)
if (logLevelIndex > 0) {
const logLevelValue = process.argv[logLevelIndex + 1]
if (logLevelValue === 'silent' || logLevelValue === 'error') {
return
}
if (/silent|error/.test(process.argv[logLevelIndex])) {
return
}
}
const yellow = (str) => `\u001b[33m${str}\u001b[39m`
const log = process.env.VITE_CJS_TRACE ? console.trace : console.warn
log(
Expand Down

0 comments on commit dc3c14f

Please sign in to comment.