diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index aeeb213daf7..3dcd8ab0223 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -15,8 +15,6 @@ export interface RollupError extends RollupLog { watchFiles?: string[]; } -export type RollupWarning = RollupLog; - export interface RollupLog { binding?: string; cause?: unknown; @@ -598,7 +596,6 @@ export interface NormalizedInputOptions { maxParallelFileOps: number; moduleContext: (id: string) => string; onLog: LogHandler; - onwarn: (warning: RollupLog) => void; perf: boolean; plugins: Plugin[]; preserveEntrySignatures: PreserveEntrySignaturesOption; diff --git a/src/utils/options/mergeOptions.ts b/src/utils/options/mergeOptions.ts index a77e3ad937a..9e5448880ac 100644 --- a/src/utils/options/mergeOptions.ts +++ b/src/utils/options/mergeOptions.ts @@ -53,7 +53,7 @@ export async function mergeOptions( const logLevel = config.logLevel || LOGLEVEL_INFO; const onLog = getOnLog(config, logLevel, printLog); const log = getLogger(plugins, onLog, watchMode, logLevel); - const inputOptions = await mergeInputOptions(config, command, plugins, log, onLog); + const inputOptions = mergeInputOptions(config, command, plugins, log, onLog); if (command.output) { Object.assign(command, command.output); } @@ -75,14 +75,14 @@ export async function mergeOptions( ...Object.keys(commandAliases), 'bundleConfigAsCjs', 'config', + 'configPlugin', 'environment', + 'failAfterWarnings', 'filterLogs', 'plugin', 'silent', - 'failAfterWarnings', 'stdin', - 'waitForBundleInput', - 'configPlugin' + 'waitForBundleInput' ], 'CLI flags', log, diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index 18b9b59fa25..9ba2c640b79 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -8,7 +8,7 @@ import type { import { EMPTY_ARRAY } from '../blank'; import { ensureArray } from '../ensureArray'; import { getLogger } from '../logger'; -import { LOGLEVEL_INFO, LOGLEVEL_WARN } from '../logging'; +import { LOGLEVEL_INFO } from '../logging'; import { error, logInvalidOption } from '../logs'; import { resolve } from '../path'; import { URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS } from '../urls'; @@ -55,7 +55,6 @@ export async function normalizeInputOptions( maxParallelFileOps, moduleContext: getModuleContext(config, context), onLog, - onwarn: warning => onLog(LOGLEVEL_WARN, warning), perf: config.perf || false, plugins, preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only', @@ -67,7 +66,7 @@ export async function normalizeInputOptions( warnUnknownOptions( config, - [...Object.keys(options), 'watch'], + [...Object.keys(options), 'onwarn', 'watch'], 'input options', onLog, /^(output)$/ diff --git a/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js b/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js index d52c011648f..7e1762a9a42 100644 --- a/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js +++ b/test/function/samples/logging/log-from-plugin-options-onlog-onwarn/_config.js @@ -36,18 +36,7 @@ module.exports = defineTest({ ['onLog', 'info', { message: 'infoLog' }], ['info', 'infoLog'], ['onLog', 'debug', { message: 'debugLog' }], - ['debug', 'debugLog'], - ['onLog', 'warn', { message: 'warnWarn' }], - ['onwarn', { message: 'warnWarn' }], - ['warn', 'warnWarn'], - ['onLog', 'warn', { message: 'warnWarn=' }], - ['onwarn', { message: 'warnWarn=' }], - ['onLog', 'warn', { message: 'warnWarn+=' }], - ['onwarn', { message: 'warnWarn+=' }], - ['warn', 'log was replaced'], - ['onLog', 'warn', { message: 'warnWarn-' }], - ['onLog', 'warn', { message: 'warnWarn+-' }], - ['info', 'log was replaced'] + ['debug', 'debugLog'] ]); assert.strictEqual(logs[0][2].toString(), 'warnLog'); assert.strictEqual(logs[1][1].toString(), 'warnLog'); @@ -88,11 +77,6 @@ module.exports = defineTest({ options.onLog('warn', { message: 'warnLog+-' }); options.onLog('info', { message: 'infoLog' }); options.onLog('debug', { message: 'debugLog' }); - options.onwarn({ message: 'warnWarn' }); - options.onwarn({ message: 'warnWarn=' }); - options.onwarn({ message: 'warnWarn+=' }); - options.onwarn({ message: 'warnWarn-' }); - options.onwarn({ message: 'warnWarn+-' }); } } ] diff --git a/test/function/samples/logging/log-from-plugin-options-onlog/_config.js b/test/function/samples/logging/log-from-plugin-options-onlog/_config.js index 5afdcc30220..c133d591664 100644 --- a/test/function/samples/logging/log-from-plugin-options-onlog/_config.js +++ b/test/function/samples/logging/log-from-plugin-options-onlog/_config.js @@ -28,14 +28,7 @@ module.exports = defineTest({ ['onLog', 'info', { message: 'infoLog' }], ['info', 'infoLog'], ['onLog', 'debug', { message: 'debugLog' }], - ['debug', 'debugLog'], - ['onLog', 'warn', { message: 'warnWarn' }], - ['warn', 'warnWarn'], - ['onLog', 'warn', { message: 'warnWarn-' }], - ['onLog', 'warn', { message: 'warnWarn+-' }], - ['debug', 'log was replaced'], - ['onLog', 'warn', { message: 'warnWarn*-' }], - ['info', 'log was replaced with string'] + ['debug', 'debugLog'] ]); assert.strictEqual(logs[0][2].toString(), 'warnLog'); assert.strictEqual(logs[2][2].toString(), '(fooPlugin plugin) fooFile (1:2) warnLog'); @@ -68,10 +61,6 @@ module.exports = defineTest({ options.onLog('warn', { message: 'warnLog*-' }); options.onLog('info', { message: 'infoLog' }); options.onLog('debug', { message: 'debugLog' }); - options.onwarn({ message: 'warnWarn' }); - options.onwarn({ message: 'warnWarn-' }); - options.onwarn({ message: 'warnWarn+-' }); - options.onwarn({ message: 'warnWarn*-' }); } } ] diff --git a/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js b/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js index d06b2fc8995..7e7c98bf7c2 100644 --- a/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js +++ b/test/function/samples/logging/log-from-plugin-options-onwarn/_config.js @@ -25,14 +25,7 @@ module.exports = defineTest({ ['onwarn', { message: 'warnLog*-' }], ['warn', 'log was replaced with string'], ['info', 'infoLog'], - ['debug', 'debugLog'], - ['onwarn', { message: 'warnWarn' }], - ['warn', 'warnWarn'], - ['onwarn', { message: 'warnWarn-' }], - ['onwarn', { message: 'warnWarn+-' }], - ['warn', 'log was replaced'], - ['onwarn', { message: 'warnWarn*-' }], - ['warn', 'log was replaced with string'] + ['debug', 'debugLog'] ]); assert.strictEqual(logs[0][1].toString(), 'warnLog'); assert.strictEqual(logs[2][1].toString(), '(fooPlugin plugin) fooFile (1:2) warnLog'); @@ -65,10 +58,6 @@ module.exports = defineTest({ options.onLog('warn', { message: 'warnLog*-' }); options.onLog('info', { message: 'infoLog' }); options.onLog('debug', { message: 'debugLog' }); - options.onwarn({ message: 'warnWarn' }); - options.onwarn({ message: 'warnWarn-' }); - options.onwarn({ message: 'warnWarn+-' }); - options.onwarn({ message: 'warnWarn*-' }); } } ] diff --git a/test/function/samples/logging/log-from-plugin-options-simple/_config.js b/test/function/samples/logging/log-from-plugin-options-simple/_config.js index 434e571dce2..607548a57aa 100644 --- a/test/function/samples/logging/log-from-plugin-options-simple/_config.js +++ b/test/function/samples/logging/log-from-plugin-options-simple/_config.js @@ -15,14 +15,12 @@ module.exports = defineTest({ assert.deepStrictEqual(logs, [ ['warn', 'warnLog'], ['info', 'infoLog'], - ['debug', 'debugLog'], - ['warn', 'warnWarn'] + ['debug', 'debugLog'] ]); assert.deepStrictEqual(pluginLogs, [ ['warn', { message: 'warnLog' }], ['info', { message: 'infoLog' }], - ['debug', { message: 'debugLog' }], - ['warn', { message: 'warnWarn' }] + ['debug', { message: 'debugLog' }] ]); }, options: { @@ -36,7 +34,6 @@ module.exports = defineTest({ options.onLog('warn', { message: 'warnLog' }); options.onLog('info', { message: 'infoLog' }); options.onLog('debug', { message: 'debugLog' }); - options.onwarn({ message: 'warnWarn' }); }, onLog(level, log) { pluginLogs.push([level, log]);