Skip to content

Commit 955bc22

Browse files
committed
feat: always call environment.logger
1 parent 131a4c6 commit 955bc22

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

packages/vite/src/node/__tests__/build.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,15 +809,14 @@ describe('onRollupLog', () => {
809809
level: LogLevel,
810810
log: RollupLog,
811811
) => {
812-
const defaultLogHandler = vi.fn(() => {})
813812
const config = await resolveConfig(
814813
{ customLogger: logger },
815814
'build',
816815
'production',
817816
'production',
818817
)
819818
const buildEnvironment = new BuildEnvironment('client', config)
820-
onRollupLog(level, log, defaultLogHandler, buildEnvironment)
819+
onRollupLog(level, log, buildEnvironment)
821820
}
822821

823822
afterEach(() => {

packages/vite/src/node/build.ts

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ async function buildEnvironment(
600600
input,
601601
plugins,
602602
external: options.rollupOptions.external,
603-
onLog(level, log, defaultHandler) {
604-
onRollupLog(level, log, defaultHandler, environment)
603+
onLog(level, log) {
604+
onRollupLog(level, log, environment)
605605
},
606606
}
607607

@@ -1008,7 +1008,6 @@ function clearLine() {
10081008
export function onRollupLog(
10091009
level: LogLevel,
10101010
log: RollupLog,
1011-
logHandler: LogOrStringHandler,
10121011
environment: BuildEnvironment,
10131012
): void {
10141013
const debugLogger = createDebugger('vite:build')
@@ -1045,33 +1044,25 @@ export function onRollupLog(
10451044
}
10461045
}
10471046

1048-
if (
1049-
logging.code === 'PLUGIN_LOG' ||
1050-
logging.code === 'PLUGIN_WARNING' ||
1051-
logging.code === 'PLUGIN_ERROR'
1052-
) {
1053-
switch (logLeveling) {
1054-
case 'info':
1055-
environment.logger.info(logging.message)
1056-
return
1057-
case 'warn':
1058-
environment.logger.warn(colors.yellow(logging.message))
1059-
return
1060-
case 'error':
1061-
environment.logger.error(colors.red(logging.message))
1062-
return
1063-
case 'debug':
1064-
debugLogger?.(logging.message)
1065-
return
1066-
default:
1067-
logLeveling satisfies never
1068-
// fallback to info if a unknown log level is passed
1069-
environment.logger.info(logging.message)
1070-
return
1071-
}
1047+
switch (logLeveling) {
1048+
case 'info':
1049+
environment.logger.info(logging.message)
1050+
return
1051+
case 'warn':
1052+
environment.logger.warn(colors.yellow(logging.message))
1053+
return
1054+
case 'error':
1055+
environment.logger.error(colors.red(logging.message))
1056+
return
1057+
case 'debug':
1058+
debugLogger?.(logging.message)
1059+
return
1060+
default:
1061+
logLeveling satisfies never
1062+
// fallback to info if a unknown log level is passed
1063+
environment.logger.info(logging.message)
1064+
return
10721065
}
1073-
1074-
logHandler(logLeveling, logging)
10751066
}
10761067

10771068
clearLine()

packages/vite/src/node/plugins/worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ async function bundleWorkerEntry(
8585
plugins: workerEnvironment.plugins.map((p) =>
8686
injectEnvironmentToHooks(workerEnvironment, p),
8787
),
88-
onLog(level, log, defaultHandler) {
89-
onRollupLog(level, log, defaultHandler, workerEnvironment)
88+
onLog(level, log) {
89+
onRollupLog(level, log, workerEnvironment)
9090
},
9191
preserveEntrySignatures: false,
9292
})

0 commit comments

Comments
 (0)