Skip to content

Commit

Permalink
Remove onwarn from normalized input options
Browse files Browse the repository at this point in the history
Also remove the RollupWarning type
  • Loading branch information
lukastaegert committed Sep 21, 2023
1 parent 9e42f62 commit b984007
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 56 deletions.
3 changes: 0 additions & 3 deletions src/rollup/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export interface RollupError extends RollupLog {
watchFiles?: string[];
}

export type RollupWarning = RollupLog;

export interface RollupLog {
binding?: string;
cause?: unknown;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/utils/options/mergeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/utils/options/normalizeInputOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
Expand All @@ -67,7 +66,7 @@ export async function normalizeInputOptions(

warnUnknownOptions(
config,
[...Object.keys(options), 'watch'],
[...Object.keys(options), 'onwarn', 'watch'],
'input options',
onLog,
/^(output)$/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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+-' });
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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*-' });
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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*-' });
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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]);
Expand Down

0 comments on commit b984007

Please sign in to comment.