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

packages/vite/index.cjs

Lines changed: 12 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy