MCPcopy
hub / github.com/vitejs/vite / onRollupLog

Function onRollupLog

packages/vite/src/node/build.ts:1098–1180  ·  view source on GitHub ↗
(
  level: LogLevel,
  log: RollupLog,
  environment: Environment,
)

Source from the content-addressed store, hash-verified

1096}
1097
1098export function onRollupLog(
1099 level: LogLevel,
1100 log: RollupLog,
1101 environment: Environment,
1102): void {
1103 const debugLogger = createDebugger('vite:build')
1104 const viteLog: LogOrStringHandler = (logLeveling, rawLogging) => {
1105 const logging =
1106 typeof rawLogging === 'object' ? rawLogging : { message: rawLogging }
1107
1108 if (logging.code === 'UNRESOLVED_IMPORT') {
1109 const id = logging.id
1110 const exporter = logging.exporter
1111 // throw unless it's commonjs external...
1112 if (!id || !id.endsWith('?commonjs-external')) {
1113 throw new Error(
1114 `[vite]: Rolldown failed to resolve import "${exporter}" from "${id}".\n` +
1115 `This is most likely unintended because it can break your application at runtime.\n` +
1116 `If you do want to externalize this module explicitly add it to\n` +
1117 `\`build.rolldownOptions.external\``,
1118 )
1119 }
1120 }
1121
1122 if (logLeveling === 'warn') {
1123 if (
1124 logging.plugin === 'rollup-plugin-dynamic-import-variables' &&
1125 dynamicImportWarningIgnoreList.some((msg) =>
1126 logging.message.includes(msg),
1127 )
1128 ) {
1129 return
1130 }
1131
1132 if (warningIgnoreList.includes(logging.code!)) {
1133 return
1134 }
1135 }
1136
1137 // append plugin name to align with Rollup's behavior
1138 let message = logging.message
1139 if (logging.plugin) {
1140 message = `[plugin ${logging.plugin}] ${message}`
1141 }
1142
1143 switch (logLeveling) {
1144 case 'info':
1145 environment.logger.info(message)
1146 return
1147 case 'warn':
1148 environment.logger.warn(colors.yellow(message))
1149 return
1150 case 'error':
1151 environment.logger.error(colors.red(message))
1152 return
1153 case 'debug':
1154 debugLogger?.(message)
1155 return

Callers 3

onLogFunction · 0.90
callOnRollupLogFunction · 0.90
onLogFunction · 0.85

Calls 4

createDebuggerFunction · 0.90
clearLineFunction · 0.85
normalizeUserOnWarnFunction · 0.85
viteLogFunction · 0.85

Tested by 1

callOnRollupLogFunction · 0.72