Skip to content

Commit dc3c14f

Browse files
authored
fix: cjs warning respect the logLevel flag (#17993)
1 parent 0ca53cf commit dc3c14f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: packages/vite/index.cjs

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ asyncFunctions.forEach((name) => {
2525

2626
function warnCjsUsage() {
2727
if (process.env.VITE_CJS_IGNORE_WARNING) return
28+
const logLevelIndex = process.argv.findIndex((arg) =>
29+
/^(?:-l|--logLevel)/.test(arg),
30+
)
31+
if (logLevelIndex > 0) {
32+
const logLevelValue = process.argv[logLevelIndex + 1]
33+
if (logLevelValue === 'silent' || logLevelValue === 'error') {
34+
return
35+
}
36+
if (/silent|error/.test(process.argv[logLevelIndex])) {
37+
return
38+
}
39+
}
2840
const yellow = (str) => `\u001b[33m${str}\u001b[39m`
2941
const log = process.env.VITE_CJS_TRACE ? console.trace : console.warn
3042
log(

0 commit comments

Comments
 (0)