diff --git a/bin/src/run/batchWarnings.ts b/bin/src/run/batchWarnings.ts index 98f9c91d350..aba89a69368 100644 --- a/bin/src/run/batchWarnings.ts +++ b/bin/src/run/batchWarnings.ts @@ -87,14 +87,6 @@ const immediateHandlers: { stderr(warning.message); }, - DEPRECATED_OPTIONS: warning => { - title(`Some options have been renamed`); - info(`https://gist.github.com/Rich-Harris/d472c50732dab03efeb37472b08a3f32`); - warning.deprecations.forEach(option => { - stderr(`${tc.bold(option.old)} is now ${option.new}`); - }); - }, - MISSING_NODE_BUILTINS: warning => { title(`Missing shims for Node.js built-ins`); @@ -103,7 +95,7 @@ const immediateHandlers: { ? `'${warning.modules[0]}'` : `${warning.modules .slice(0, -1) - .map(name => `'${name}'`) + .map((name: string) => `'${name}'`) .join(', ')} and '${warning.modules.slice(-1)}'`; stderr( `Creating a browser bundle that depends on ${detail}. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins` diff --git a/bin/src/run/index.ts b/bin/src/run/index.ts index 93937e16e39..2eff0bdcac7 100644 --- a/bin/src/run/index.ts +++ b/bin/src/run/index.ts @@ -97,22 +97,12 @@ function execute(configFile: string, configs: InputOptions[], command: any) { for (const config of configs) { promise = promise.then(() => { const warnings = batchWarnings(); - const { inputOptions, outputOptions, deprecations, optionError } = mergeOptions({ + const { inputOptions, outputOptions, optionError } = mergeOptions({ config, command, defaultOnWarnHandler: warnings.add }); - if (deprecations.length) { - inputOptions.onwarn({ - code: 'DEPRECATED_OPTIONS', - message: `The following options have been renamed — please update your config: ${deprecations - .map(option => `${option.old} -> ${option.new}`) - .join(', ')}`, - deprecations - }); - } - if (optionError) inputOptions.onwarn({ code: 'UNKNOWN_OPTION', message: optionError }); return build(inputOptions, outputOptions, warnings, command.silent); }); diff --git a/rollup.config.js b/rollup.config.js index 416ea56c760..4b203eab67d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -31,6 +31,8 @@ const banner = `/* */`; const onwarn = warning => { + if (warning.pluginCode === 'ONWRITE_HOOK_DEPRECATED') + return; // eslint-disable-next-line no-console console.error( 'Building Rollup produced warnings that need to be resolved. ' + diff --git a/src/rollup/index.ts b/src/rollup/index.ts index d294d7ce4da..134d99727dc 100644 --- a/src/rollup/index.ts +++ b/src/rollup/index.ts @@ -5,7 +5,6 @@ import { createAddons } from '../utils/addons'; import { createAssetPluginHooks, finaliseAsset } from '../utils/assetHooks'; import { assignChunkIds } from '../utils/assignChunkIds'; import commondir from '../utils/commondir'; -import { Deprecation } from '../utils/deprecateOptions'; import { error } from '../utils/error'; import { writeFile } from '../utils/fs'; import getExportMode from '../utils/getExportMode'; @@ -22,29 +21,9 @@ import { Plugin, RollupBuild, RollupOutput, - RollupWatcher, - WarningHandler + RollupWatcher } from './types'; -function addDeprecations(deprecations: Deprecation[], warn: WarningHandler) { - const message = `The following options have been renamed — please update your config: ${deprecations - .map(option => `${option.old} -> ${option.new}`) - .join(', ')}`; - warn({ - code: 'DEPRECATED_OPTIONS', - message, - deprecations - }); -} - -function checkInputOptions(options: InputOptions) { - if (options.transform || options.load || options.resolveId || options.resolveExternal) { - throw new Error( - 'The `transform`, `load`, `resolveId` and `resolveExternal` options are deprecated in favour of a unified plugin API. See "https://rollupjs.org/guide/en#plugins" for details' - ); - } -} - function checkOutputOptions(options: OutputOptions) { if (options.format === 'es6') { error({ @@ -59,10 +38,6 @@ function checkOutputOptions(options: OutputOptions) { url: `https://rollupjs.org/guide/en#output-format-f-format` }); } - - if (options.moduleId) { - if (options.amd) throw new Error('Cannot have both output.amd and output.moduleId'); - } } function getAbsoluteEntryModulePaths(chunks: Chunk[]): string[] { @@ -93,15 +68,12 @@ function getInputOptions(rawInputOptions: GenericConfigObject): any { if (!rawInputOptions) { throw new Error('You must supply an options object to rollup'); } - let { inputOptions, deprecations, optionError } = mergeOptions({ - config: rawInputOptions, - deprecateConfig: { input: true } + let { inputOptions, optionError } = mergeOptions({ + config: rawInputOptions }); if (optionError) inputOptions.onwarn({ message: optionError, code: 'UNKNOWN_OPTION' }); - if (deprecations.length) addDeprecations(deprecations, inputOptions.onwarn); - checkInputOptions(inputOptions); const plugins = inputOptions.plugins; inputOptions.plugins = Array.isArray(plugins) ? plugins.filter(Boolean) @@ -442,25 +414,17 @@ function normalizeOutputOptions( if (!rawOutputOptions) { throw new Error('You must supply an options object'); } - // since deprecateOptions, adds the output properties - // to `inputOptions` so adding that lastly - const consolidatedOutputOptions = { - output: { ...rawOutputOptions, ...rawOutputOptions.output, ...inputOptions.output } - }; const mergedOptions = mergeOptions({ - // just for backward compatiblity to fallback on root - // if the option isn't present in `output` - config: consolidatedOutputOptions, - deprecateConfig: { output: true } + config: { + output: { ...rawOutputOptions, ...rawOutputOptions.output, ...inputOptions.output } + } }); if (mergedOptions.optionError) throw new Error(mergedOptions.optionError); // now outputOptions is an array, but rollup.rollup API doesn't support arrays const outputOptions = mergedOptions.outputOptions[0]; - const deprecations = mergedOptions.deprecations; - if (deprecations.length) addDeprecations(deprecations, inputOptions.onwarn); checkOutputOptions(outputOptions); if (typeof outputOptions.file === 'string') { diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index dd5190006cf..e0cc9d40d07 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -7,23 +7,28 @@ export interface IdMap { [key: string]: string; } -export interface RollupError { - message: string; +export interface RollupError extends RollupLogProps { + message?: string; + stack?: string; +} + +export interface RollupWarning extends RollupLogProps { + message?: string; +} + +export interface RollupLogProps { code?: string; - name?: string; url?: string; - id?: string; + plugin?: string; + pluginCode?: string; + hook?: string; loc?: { file?: string; line: number; column: number; }; - stack?: string; frame?: string; - pos?: number; - plugin?: string; - pluginCode?: string; - hook?: string; + [key: string]: any; } export interface ExistingRawSourceMap { @@ -89,7 +94,7 @@ export interface PluginCache { } export interface PluginContext { - // TODO deprecate: + /** @deprecated */ watcher: EventEmitter; addWatchFile: (id: string) => void; cache: PluginCache; @@ -193,6 +198,7 @@ export interface Plugin { transform?: TransformHook; /** @deprecated */ transformBundle?: TransformChunkHook; + /** @deprecated */ transformChunk?: TransformChunkHook; renderChunk?: RenderChunkHook; buildStart?: (this: PluginContext, options: InputOptions) => Promise | void; @@ -242,6 +248,7 @@ export interface InputOptions { onwarn?: WarningHandler; cache?: false | RollupCache; + perf?: boolean; experimentalCacheExpiry?: number; acorn?: {}; @@ -251,27 +258,12 @@ export interface InputOptions { moduleContext?: string | ((id: string) => string) | { [id: string]: string }; watch?: WatcherOptions; inlineDynamicImports?: boolean; + preferConst?: boolean; preserveSymlinks?: boolean; preserveModules?: boolean; experimentalOptimizeChunks?: boolean; chunkGroupingSize?: number; shimMissingExports?: boolean; - - // undocumented? - pureExternalModules?: boolean; - preferConst?: boolean; - perf?: boolean; - - /** @deprecated */ - entry?: string; - /** @deprecated */ - transform?: TransformHook; - /** @deprecated */ - load?: LoadHook; - /** @deprecated */ - resolveId?: ResolveIdHook; - /** @deprecated */ - resolveExternal?: any; } export type ModuleFormat = 'amd' | 'cjs' | 'system' | 'es' | 'esm' | 'iife' | 'umd'; @@ -316,41 +308,7 @@ export interface OutputOptions { namespaceToStringTag?: boolean; compact?: boolean; - /** @deprecated */ noConflict?: boolean; - /** @deprecated */ - dest?: string; - /** @deprecated */ - moduleId?: string; -} - -export interface RollupWarning { - message?: string; - code?: string; - loc?: { - file: string; - line: number; - column: number; - }; - deprecations?: { old: string; new: string }[]; - modules?: string[]; - names?: string[]; - source?: string; - importer?: string; - frame?: any; - missing?: string; - exporter?: string; - exportName?: string; - name?: string; - sources?: string[]; - reexporter?: string; - guess?: string; - url?: string; - id?: string; - plugin?: string; - pos?: number; - pluginCode?: string; - hook?: string; } export type WarningHandler = (warning: string | RollupWarning) => void; @@ -423,7 +381,6 @@ export interface RollupOptions extends InputOptions { } export function rollup(options: RollupOptions): Promise; - // chokidar watch options export interface WatchOptions { persistent?: boolean; diff --git a/src/utils/deprecateOptions.ts b/src/utils/deprecateOptions.ts deleted file mode 100644 index 1046038627a..00000000000 --- a/src/utils/deprecateOptions.ts +++ /dev/null @@ -1,108 +0,0 @@ -// second argument is required because rollup's Node API -// passes inputOptions first and then output options -// unlike the config file which passes whole options in one go -import { GenericConfigObject } from './mergeOptions'; - -export interface Deprecation { - old: string; - new: string; -} - -export default function deprecateOptions( - options: GenericConfigObject, - deprecateConfig: GenericConfigObject -): Deprecation[] { - const deprecations: Deprecation[] = []; - if (deprecateConfig.input) deprecateInputOptions(); - if (deprecateConfig.output) deprecateOutputOptions(); - - return deprecations; - - function deprecateInputOptions() { - if (!options.input && options.entry) deprecate('entry', 'input'); - if (options.dest) deprecateToOutputOption('dest', 'file'); - if (options.moduleName) deprecateToOutputOption('moduleName', 'name'); - if (options.name) deprecateToOutputOption('name', 'name'); - if (options.extend) deprecateToOutputOption('extend', 'extend'); - if (options.globals) deprecateToOutputOption('globals', 'globals'); - if (options.indent) deprecateToOutputOption('indent', 'indent'); - if (options.noConflict) deprecateToOutputOption('noConflict', 'noConflict'); - if (options.paths) deprecateToOutputOption('paths', 'paths'); - if (options.sourcemap) deprecateToOutputOption('sourcemap', 'sourcemap'); - if (options.sourceMap) deprecateToOutputOption('sourceMap', 'sourcemap'); - if (options.sourceMapFile) deprecateToOutputOption('sourceMapFile', 'sourcemapFile'); - if (options.useStrict) deprecateToOutputOption('useStrict', 'strict'); - if (options.strict) deprecateToOutputOption('strict', 'strict'); - if (options.format) deprecateToOutputOption('format', 'format'); - if (options.banner) deprecateToOutputOption('banner', 'banner'); - if (options.footer) deprecateToOutputOption('footer', 'footer'); - if (options.intro) deprecateToOutputOption('intro', 'intro'); - if (options.outro) deprecateToOutputOption('outro', 'outro'); - if (options.interop) deprecateToOutputOption('interop', 'interop'); - if (options.freeze) deprecateToOutputOption('freeze', 'freeze'); - if (options.exports) deprecateToOutputOption('exports', 'exports'); - - if (options.targets) { - deprecations.push({ old: 'targets', new: 'output' }); - - // as targets is an array and we need to merge other output options - // like sourcemap etc. - options.output = options.targets.map((target: GenericConfigObject) => ({ - ...target, - ...options.output - })); - delete options.targets; - - let deprecatedDest = false; - options.output.forEach((outputEntry: GenericConfigObject) => { - if (outputEntry.dest) { - if (!deprecatedDest) { - deprecations.push({ old: 'targets.dest', new: 'output.file' }); - deprecatedDest = true; - } - outputEntry.file = outputEntry.dest; - delete outputEntry.dest; - } - }); - } - - if (options.pureExternalModules) { - deprecations.push({ - old: 'pureExternalModules', - new: 'treeshake.pureExternalModules' - }); - if (options.treeshake === undefined) { - options.treeshake = {}; - } - if (options.treeshake) { - options.treeshake.pureExternalModules = options.pureExternalModules; - } - delete options.pureExternalModules; - } - } - - function deprecateOutputOptions() { - if (options.output && options.output.moduleId) { - options.output.amd = { id: options.moduleId }; - deprecations.push({ old: 'moduleId', new: 'amd' }); - delete options.output.moduleId; - } - } - - function deprecate(oldOption: string, newOption: string) { - deprecations.push({ new: newOption, old: oldOption }); - if (!(newOption in options)) { - options[newOption] = options[oldOption]; - } - delete options[oldOption]; - } - - function deprecateToOutputOption(oldOption: string, newOption: string) { - deprecations.push({ new: `output.${newOption}`, old: oldOption }); - options.output = options.output || {}; - if (!(newOption in options.output)) { - options.output[newOption] = options[oldOption]; - } - delete options[oldOption]; - } -} diff --git a/src/utils/mergeOptions.ts b/src/utils/mergeOptions.ts index bea23efa219..45ed716a563 100644 --- a/src/utils/mergeOptions.ts +++ b/src/utils/mergeOptions.ts @@ -1,5 +1,4 @@ import { InputOptions, OutputOptions, WarningHandler } from '../rollup/types'; -import deprecateOptions, { Deprecation } from './deprecateOptions'; export interface GenericConfigObject { [key: string]: any; @@ -82,20 +81,16 @@ export const commandAliases: { [key: string]: string } = { export default function mergeOptions({ config = {}, command: rawCommandOptions = {}, - deprecateConfig, defaultOnWarnHandler }: { config: GenericConfigObject; command?: GenericConfigObject; - deprecateConfig?: GenericConfigObject; defaultOnWarnHandler?: WarningHandler; }): { inputOptions: any; outputOptions: any; - deprecations: Deprecation[]; optionError: string | null; } { - const deprecations = deprecate(config, rawCommandOptions, deprecateConfig); const command = getCommandOptions(rawCommandOptions); const inputOptions = getInputOptions(config, command, defaultOnWarnHandler); @@ -148,7 +143,6 @@ export default function mergeOptions({ return { inputOptions, outputOptions, - deprecations, optionError: unknownOptionErrors.length > 0 ? unknownOptionErrors.join('\n') : null }; } @@ -227,18 +221,6 @@ function getInputOptions( if (inputOptions.cache && (inputOptions.cache).cache) inputOptions.cache = (inputOptions.cache).cache; - // legacy to make sure certain plugins still work - if (Array.isArray(inputOptions.input)) { - inputOptions.entry = inputOptions.input[0]; - } else if (typeof inputOptions.input === 'object') { - for (const name in inputOptions.input) { - inputOptions.entry = inputOptions.input[name]; - break; - } - } else { - inputOptions.entry = inputOptions.input; - } - return inputOptions; } @@ -280,40 +262,3 @@ function getOutputOptions( strict: getOption('strict', true) }; } - -function deprecate( - config: GenericConfigObject, - command: GenericConfigObject = {}, - deprecateConfig: GenericConfigObject = { input: true, output: true } -): Deprecation[] { - const deprecations = []; - - // CLI - if (command.id) { - deprecations.push({ - old: '-u/--id', - new: '--amd.id' - }); - (command.amd || (command.amd = {})).id = command.id; - } - - if (typeof command.output === 'string') { - deprecations.push({ - old: '--output', - new: '--file' - }); - command.output = { file: command.output }; - } - - if (command.d) { - deprecations.push({ - old: '-d', - new: '--indent' - }); - command.indent = command.d; - } - - // config file - deprecations.push(...deprecateOptions(config, deprecateConfig)); - return deprecations; -} diff --git a/src/utils/pluginDriver.ts b/src/utils/pluginDriver.ts index 86c4e566399..e04d655805f 100644 --- a/src/utils/pluginDriver.ts +++ b/src/utils/pluginDriver.ts @@ -1,3 +1,4 @@ +import { EventEmitter } from 'events'; import { version as rollupVersion } from 'package.json'; import Graph from '../Graph'; import Module from '../Module'; @@ -41,6 +42,13 @@ export interface PluginDriver { export type Reduce = (reduction: T, result: R, plugin: Plugin) => T; export type HookContext = (context: PluginContext, plugin?: Plugin) => PluginContext; +const deprecatedHookNames: Record = { + transformBundle: 'renderChunk', + transformChunk: 'renderChunk', + ongenerate: 'generateBundle', + onwrite: 'generateBundle' +}; + export function createPluginDriver( graph: Graph, options: InputOptions, @@ -53,7 +61,7 @@ export function createPluginDriver( let hasLoadersOrTransforms = false; - const pluginContexts: PluginContext[] = plugins.map(plugin => { + const pluginContexts: PluginContext[] = plugins.map((plugin, pidx) => { let cacheable = true; if (typeof plugin.cacheKey !== 'string') { if (typeof plugin.name !== 'string') { @@ -82,7 +90,18 @@ export function createPluginDriver( cacheInstance = uncacheablePlugin(plugin.name); } - return { + const firstWatchHandler = true; + + function deprecatedWatchListener(event: string, handler: () => void): EventEmitter { + if (firstWatchHandler) + context.warn({ + code: 'PLUGIN_WATCHER_DEPRECATED', + message: `this.watcher usage is deprecated in plugins. Use the watchChange plugin hook instead.` + }); + return watcher.on(event, handler); + } + + const context: PluginContext = { addWatchFile(id: string) { if (graph.finished) this.error('addWatchFile can only be called during the build.'); graph.watchFiles[id] = true; @@ -93,7 +112,7 @@ export function createPluginDriver( if (typeof err === 'string') err = { message: err }; if (err.code) err.pluginCode = err.code; err.code = 'PLUGIN_ERROR'; - err.plugin = plugin.name || '(anonymous plugin)'; + err.plugin = plugin.name || `Plugin at position ${pidx + 1}`; error(err); }, isExternal(id: string, parentId: string, isResolved = false) { @@ -112,7 +131,7 @@ export function createPluginDriver( if (typeof warning === 'string') warning = { message: warning }; if (warning.code) warning.pluginCode = warning.code; warning.code = 'PLUGIN_WARNING'; - warning.plugin = plugin.name || '(anonymous plugin)'; + warning.plugin = plugin.name || `Plugin at position ${pidx + 1}`; graph.warn(warning); }, moduleIds: graph.moduleById.keys(), @@ -130,8 +149,15 @@ export function createPluginDriver( : (foundModule as Module).sources.map(id => (foundModule as Module).resolvedIds[id]) }; }, - watcher + watcher: watcher + ? { + ...(watcher), + on: deprecatedWatchListener, + addListener: deprecatedWatchListener + } + : undefined }; + return context; }); function runHookSync( @@ -145,6 +171,11 @@ export function createPluginDriver( let context = pluginContexts[pidx]; const hook = (plugin)[hookName]; if (!hook) return; + + const deprecatedHookNewName = deprecatedHookNames[hookName]; + if (deprecatedHookNewName) + context.warn(hookDeprecationWarning(hookName, deprecatedHookNewName, plugin, pidx)); + if (hookContext) { context = hookContext(context, plugin); if (!context || context === pluginContexts[pidx]) @@ -157,7 +188,7 @@ export function createPluginDriver( error({ code: 'INVALID_PLUGIN_HOOK', message: `Error running plugin hook ${hookName} for ${plugin.name || - `Plugin at pos ${pidx + 1}`}, expected a function hook.` + `Plugin at position ${pidx + 1}`}, expected a function hook.` }); } return hook.apply(context, args); @@ -167,7 +198,7 @@ export function createPluginDriver( if (err.code) err.pluginCode = err.code; err.code = 'PLUGIN_ERROR'; } - err.plugin = plugin.name || `Plugin at pos ${pidx}`; + err.plugin = plugin.name || `Plugin at position ${pidx + 1}`; err.hook = hookName; error(err); } @@ -184,6 +215,11 @@ export function createPluginDriver( let context = pluginContexts[pidx]; const hook = (plugin)[hookName]; if (!hook) return; + + const deprecatedHookNewName = deprecatedHookNames[hookName]; + if (deprecatedHookNewName) + context.warn(hookDeprecationWarning(hookName, deprecatedHookNewName, plugin, pidx)); + if (hookContext) { context = hookContext(context, plugin); if (!context || context === pluginContexts[pidx]) @@ -197,7 +233,7 @@ export function createPluginDriver( error({ code: 'INVALID_PLUGIN_HOOK', message: `Error running plugin hook ${hookName} for ${plugin.name || - `Plugin at pos ${pidx + 1}`}, expected a function hook.` + `Plugin at position ${pidx + 1}`}, expected a function hook.` }); } return hook.apply(context, args); @@ -208,7 +244,7 @@ export function createPluginDriver( if (err.code) err.pluginCode = err.code; err.code = 'PLUGIN_ERROR'; } - err.plugin = plugin.name || `Plugin at pos ${pidx}`; + err.plugin = plugin.name || `Plugin at position ${pidx + 1}`; err.hook = hookName; error(err); }); @@ -263,7 +299,7 @@ export function createPluginDriver( const hookPromise = runHook(name, [arg0, ...args], i, false, hookContext); if (!hookPromise) return arg0; return hookPromise.then((result: any) => { - return reduce(arg0, result, plugins[i]); + return reduce.call(pluginContexts[i], arg0, result, plugins[i]); }); }); } @@ -277,7 +313,7 @@ export function createPluginDriver( const hookPromise = runHook(name, args, i, true, hookContext); if (!hookPromise) return value; return hookPromise.then((result: any) => { - return reduce(value, result, plugins[i]); + return reduce.call(pluginContexts[i], value, result, plugins[i]); }); }); } @@ -378,3 +414,11 @@ const uncacheablePlugin: (pluginName: string) => PluginCache = pluginName => ({ return false; } }); + +function hookDeprecationWarning(name: string, newName: string, plugin: Plugin, pidx: number) { + return { + code: name.toUpperCase() + '_HOOK_DEPRECATED', + message: `The ${name} hook used by plugin ${plugin.name || + `at position ${pidx + 1}`} is deprecated. The ${newName} hook should be used instead.` + }; +} diff --git a/src/utils/transform.ts b/src/utils/transform.ts index 45c20c8f6c1..890fe180022 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -7,6 +7,7 @@ import { Asset, Plugin, PluginCache, + PluginContext, RawSourceMap, RollupError, RollupWarning, @@ -39,9 +40,10 @@ export default function transform( let assets: Asset[]; let customTransformCache = false; let trackedPluginCache: { used: boolean; cache: PluginCache }; + let curPlugin: Plugin; const curSource: string = source.code; - function transformReducer(code: string, result: any, plugin: Plugin) { + function transformReducer(this: PluginContext, code: string, result: any, plugin: Plugin) { // track which plugins use the custom this.cache to opt-out of transform caching if (!customTransformCache && trackedPluginCache.used) customTransformCache = true; if (customTransformCache) { @@ -56,6 +58,13 @@ export default function transform( if (assets.length) module.transformAssets = assets; if (result && Array.isArray(result.dependencies)) { + // not great, but a useful way to track this without assuming WeakMap + if (!(curPlugin).warnedTransformDependencies) + this.warn({ + code: 'TRANSFORM_DEPENDENCIES_DEPRECATED', + message: `Returning "dependencies" from plugin transform hook is deprecated for using this.addWatchFile() instead.` + }); + (curPlugin).warnedTransformDependencies = true; if (!transformDependencies) transformDependencies = []; for (const dep of result.dependencies) transformDependencies.push(resolve(dirname(id), dep)); @@ -97,6 +106,7 @@ export default function transform( [curSource, id], transformReducer, (pluginContext, plugin) => { + curPlugin = plugin; if (plugin.cacheKey) customTransformCache = true; else trackedPluginCache = trackPluginCache(pluginContext.cache); diff --git a/test/cli/samples/config-deprecations/_config.js b/test/cli/samples/config-deprecations/_config.js deleted file mode 100644 index 104e78cb12f..00000000000 --- a/test/cli/samples/config-deprecations/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - description: 'throws proper deprecations', - command: 'rollup --config rollup.config.js', - execute: true -}; diff --git a/test/cli/samples/config-deprecations/main.js b/test/cli/samples/config-deprecations/main.js deleted file mode 100644 index df16c1b06b9..00000000000 --- a/test/cli/samples/config-deprecations/main.js +++ /dev/null @@ -1 +0,0 @@ -assert.equal( ANSWER, 42 ); diff --git a/test/cli/samples/config-deprecations/rollup.config.js b/test/cli/samples/config-deprecations/rollup.config.js deleted file mode 100644 index 671116d9984..00000000000 --- a/test/cli/samples/config-deprecations/rollup.config.js +++ /dev/null @@ -1,40 +0,0 @@ -var replace = require( 'rollup-plugin-replace' ); -var assert = require( 'assert' ); - -let warnings = []; - -module.exports = { - entry: 'main.js', - format: 'cjs', - abc: 1, - plugins: [ - replace( { 'ANSWER': 42 } ) - ], - onwarn (warning) { - // this is called twice, 1st time from CLI and - // then again from rollup's main method. - // the tests are different because some deprecations are - // fixed the first time only - warnings.push(warning); - - const deprecationTest = () => assert.deepEqual( - warnings[0].deprecations, - [{new: 'input', old: 'entry'}, {new: 'output.format', old: 'format'}] - ); - - if (warnings.length === 1) { - deprecationTest(); - } else if (warnings.length === 2) { - deprecationTest(); - assert.deepEqual( - warnings[1], - { - code: 'UNKNOWN_OPTION', - message: `Unknown input option: abc. Allowed options: ${require('../../../misc/optionList').input}` - } - ); - } else { - throw new Error('Unwanted warnings'); - } - } -}; diff --git a/test/cli/samples/multiple-targets-shared-config/rollup.config.js b/test/cli/samples/multiple-targets-shared-config/rollup.config.js index a18d87f52e4..d4c4495e68b 100644 --- a/test/cli/samples/multiple-targets-shared-config/rollup.config.js +++ b/test/cli/samples/multiple-targets-shared-config/rollup.config.js @@ -1,6 +1,6 @@ export default { input: 'main.js', - targets: [ + output: [ { format: 'cjs', file: '_actual/cjs.js', diff --git a/test/cli/samples/no-conflict/rollup.config.js b/test/cli/samples/no-conflict/rollup.config.js index e5d161e4609..f716a0d9d64 100644 --- a/test/cli/samples/no-conflict/rollup.config.js +++ b/test/cli/samples/no-conflict/rollup.config.js @@ -2,7 +2,7 @@ module.exports = { input: 'main.js', output: { format: 'umd', - noConflict: true - }, - name: 'conflictyName' + noConflict: true, + name: 'conflictyName' + } }; diff --git a/test/cli/samples/warn-unknown-options/rollup.config.js b/test/cli/samples/warn-unknown-options/rollup.config.js index 1b9e119dbdc..3636de1b0ba 100644 --- a/test/cli/samples/warn-unknown-options/rollup.config.js +++ b/test/cli/samples/warn-unknown-options/rollup.config.js @@ -8,7 +8,7 @@ module.exports = commands => ({ plugins: [ { ongenerate() { - assert.equal(warnings, 1); + assert.equal(warnings, 2); } }, replace({ 'ANSWER': commands.configAnswer }), @@ -16,8 +16,15 @@ module.exports = commands => ({ onwarn(warning) { console.error(warning.message) warnings++; - assert.equal(warning.code, 'UNKNOWN_OPTION'); - assert.equal(warning.message, - `Unknown CLI flag: unknownOption. Allowed options: ${require('../../../misc/optionList').flags}`); + if (warnings === 1) { + assert.equal(warning.code, 'UNKNOWN_OPTION'); + assert.equal(warning.message, + `Unknown CLI flag: unknownOption. Allowed options: ${require('../../../misc/optionList').flags}`); + } + else { + assert.equal(warning.code, 'PLUGIN_WARNING'); + assert.equal(warning.message, + `The ongenerate hook used by plugin at position 1 is deprecated. The generateBundle hook should be used instead.`); + } } }); diff --git a/test/function/samples/banner-and-footer/_config.js b/test/function/samples/banner-and-footer/_config.js index 1f3cafcf45d..78508fd8503 100644 --- a/test/function/samples/banner-and-footer/_config.js +++ b/test/function/samples/banner-and-footer/_config.js @@ -27,6 +27,6 @@ module.exports = { generateError: { code: 'ADDON_ERROR', message: - 'Could not retrieve banner. Check configuration of Plugin at pos 2.\n\tError Message: Could not generate banner.' + 'Could not retrieve banner. Check configuration of Plugin at position 3.\n\tError Message: Could not generate banner.' } }; diff --git a/test/function/samples/bundle-transformer-async/_config.js b/test/function/samples/bundle-transformer-async/_config.js index 88a77a8889a..a4953e89cde 100644 --- a/test/function/samples/bundle-transformer-async/_config.js +++ b/test/function/samples/bundle-transformer-async/_config.js @@ -18,5 +18,21 @@ module.exports = { } } ] - } + }, + warnings: [{ + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin at position 1 is deprecated. The renderChunk hook should be used instead.', + plugin: 'Plugin at position 1', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }, { + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin at position 2 is deprecated. The renderChunk hook should be used instead.', + plugin: 'Plugin at position 2', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }, { + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin at position 3 is deprecated. The renderChunk hook should be used instead.', + plugin: 'Plugin at position 3', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }] }; diff --git a/test/function/samples/custom-path-resolver-plural-b/_config.js b/test/function/samples/custom-path-resolver-plural-b/_config.js index b063e5bc618..83e18ba0c6a 100644 --- a/test/function/samples/custom-path-resolver-plural-b/_config.js +++ b/test/function/samples/custom-path-resolver-plural-b/_config.js @@ -21,6 +21,6 @@ module.exports = { code: 'PLUGIN_ERROR', hook: 'resolveId', message: 'nope', - plugin: 'Plugin at pos 0' + plugin: 'Plugin at position 1' } }; diff --git a/test/function/samples/duplicate-input-entry-fails/_config.js b/test/function/samples/duplicate-input-entry-fails/_config.js index dc44ba1a1a2..aa1b1b2e67f 100644 --- a/test/function/samples/duplicate-input-entry-fails/_config.js +++ b/test/function/samples/duplicate-input-entry-fails/_config.js @@ -7,6 +7,9 @@ module.exports = { }, error: { code: 'DUPLICATE_ENTRY_POINTS', - message: `Duplicate entry points detected. The input entries main and main both point to the same module, ${path.resolve(__dirname, 'main.js')}` + message: `Duplicate entry points detected. The input entries main and main both point to the same module, ${path.resolve( + __dirname, + 'main.js' + )}` } }; diff --git a/test/function/samples/plugin-module-information-early-access/_config.js b/test/function/samples/plugin-module-information-early-access/_config.js index 5912ca83478..eec5071380b 100644 --- a/test/function/samples/plugin-module-information-early-access/_config.js +++ b/test/function/samples/plugin-module-information-early-access/_config.js @@ -21,6 +21,6 @@ module.exports = { code: 'PLUGIN_ERROR', hook: 'buildStart', message: `Unable to find module ${ID_MAIN}`, - plugin: 'Plugin at pos 0' + plugin: 'Plugin at position 1' } }; diff --git a/test/hooks/index.js b/test/hooks/index.js index b8e75af10e2..90fb2874ab1 100644 --- a/test/hooks/index.js +++ b/test/hooks/index.js @@ -156,12 +156,30 @@ describe('hooks', () => { }); }); - it('passes bundle & output object to ongenerate & onwrite hooks', () => { + it('passes bundle & output object to ongenerate & onwrite hooks, with deprecation warnings', () => { const file = path.join(__dirname, 'tmp/bundle.js'); + let deprecationCnt = 0; + return rollup .rollup({ input: 'input', + onwarn(warning) { + deprecationCnt++; + if (deprecationCnt === 1) { + assert.equal(warning.pluginCode, 'ONGENERATE_HOOK_DEPRECATED'); + assert.equal( + warning.message, + 'The ongenerate hook used by plugin at position 2 is deprecated. The generateBundle hook should be used instead.' + ); + } else { + assert.equal(warning.pluginCode, 'ONWRITE_HOOK_DEPRECATED'); + assert.equal( + warning.message, + 'The onwrite hook used by plugin at position 2 is deprecated. The generateBundle hook should be used instead.' + ); + } + }, plugins: [ loader({ input: `alert('hello')` }), { @@ -182,6 +200,7 @@ describe('hooks', () => { }); }) .then(() => { + assert.equal(deprecationCnt, 2); return sander.unlink(file); }); }); @@ -301,31 +320,36 @@ describe('hooks', () => { return bundle.generate({ format: 'es' }); }) .then(({ output }) => { - assert.equal(output[0].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`); + assert.equal( + output[0].code, + `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n` + ); assert.equal(output[1].fileName, 'assets/test-19916f7d.ext'); assert.equal(output[1].source, 'hello world'); assert.equal(output[1].fileName, 'assets/test-19916f7d.ext'); assert.equal(output[1].source, 'hello world'); - return rollup - .rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '' }), - { - transform() { - assert.fail('Should cache transform'); - } + return rollup.rollup({ + cache, + input: 'input', + plugins: [ + loader({ input: '' }), + { + transform() { + assert.fail('Should cache transform'); } - ] - }); + } + ] + }); }) .then(bundle => { return bundle.generate({ format: 'es' }); }) .then(({ output }) => { - assert.equal(output[0].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`); + assert.equal( + output[0].code, + `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n` + ); assert.equal(output[1].fileName, 'assets/test-19916f7d.ext'); assert.equal(output[1].source, 'hello world'); assert.equal(output[1].fileName, 'assets/test-19916f7d.ext'); @@ -357,27 +381,29 @@ describe('hooks', () => { return bundle.generate({ format: 'es' }); }) .then(({ output }) => { - assert.equal(output[0].code, `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`); + assert.equal( + output[0].code, + `var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n` + ); assert.equal(output[1].fileName, 'assets/test-19916f7d.ext'); assert.equal(output[1].source, 'hello world'); assert.equal(output[1].fileName, 'assets/test-19916f7d.ext'); assert.equal(output[1].source, 'hello world'); - return rollup - .rollup({ - cache, - input: 'input', - plugins: [ - loader({ input: '' }), - { - name: 'x', - transform() { - runs++; - return `alert('hello world')`; - } + return rollup.rollup({ + cache, + input: 'input', + plugins: [ + loader({ input: '' }), + { + name: 'x', + transform() { + runs++; + return `alert('hello world')`; } - ] - }); + } + ] + }); }) .then(bundle => { return bundle.generate({ format: 'es' }); @@ -554,11 +580,20 @@ module.exports = input; }); }); - it('supports transformChunk in place of transformBundle', () => { + it('supports transformChunk in place of transformBundle, with deprecation warning', () => { let calledHook = false; + let deprecationCnt = 0; return rollup .rollup({ input: 'input', + onwarn(warning) { + deprecationCnt++; + assert.equal(warning.pluginCode, 'TRANSFORMCHUNK_HOOK_DEPRECATED'); + assert.equal( + warning.message, + 'The transformChunk hook used by plugin at position 2 is deprecated. The renderChunk hook should be used instead.' + ); + }, plugins: [ loader({ input: `alert('hello')` }), { @@ -579,6 +614,41 @@ module.exports = input; assetFileNames: '[name][extname]' }); }) + .then(() => { + assert.equal(deprecationCnt, 1); + assert.equal(calledHook, true); + }); + }); + + it('supports renderChunk in place of transformBundle and transformChunk', () => { + let calledHook = false; + return rollup + .rollup({ + input: 'input', + plugins: [ + loader({ input: `alert('hello')` }), + { + renderChunk(code, chunk, options) { + calledHook = true; + assert.equal(chunk.fileName, 'input.js'); + assert.equal(chunk.isEntry, true); + assert.equal(chunk.exports.length, 0); + assert.ok(chunk.modules['input']); + try { + this.emitAsset('test.ext', 'hello world'); + } catch (e) { + assert.equal(e.code, 'ASSETS_ALREADY_FINALISED'); + } + } + } + ] + }) + .then(bundle => { + return bundle.generate({ + format: 'es', + assetFileNames: '[name][extname]' + }); + }) .then(() => { assert.equal(calledHook, true); }); @@ -1059,6 +1129,80 @@ module.exports = input; }); }); + it('Warns when using deprecated this.watcher in plugins', () => { + let warned = false; + const watcher = rollup.watch({ + input: 'input', + onwarn(warning) { + warned = true; + assert.equal(warning.code, 'PLUGIN_WARNING'); + assert.equal(warning.pluginCode, 'PLUGIN_WATCHER_DEPRECATED'); + assert.equal( + warning.message, + 'this.watcher usage is deprecated in plugins. Use the watchChange plugin hook instead.' + ); + }, + plugins: [ + loader({ input: `alert('hello')` }), + { + name: 'x', + buildStart() { + this.watcher.on('change', () => {}); + } + } + ] + }); + return new Promise((resolve, reject) => { + watcher.on('event', evt => { + if (evt.code === 'BUNDLE_END') resolve(); + else if (evt.code === 'ERROR' || evt.code === 'FATAL') reject(evt.error); + }); + }).catch(err => { + assert.equal(err.message, 'You must specify output.file or output.dir for the build.'); + assert.equal(warned, true); + }); + }); + + it('Warns when using deprecated transform dependencies in plugins', () => { + let warned = false; + const watcher = rollup.watch({ + input: 'input', + output: { + file: 'asdf', + format: 'es' + }, + onwarn(warning) { + warned = true; + assert.equal(warning.code, 'PLUGIN_WARNING'); + assert.equal(warning.pluginCode, 'TRANSFORM_DEPENDENCIES_DEPRECATED'); + assert.equal( + warning.message, + 'Returning "dependencies" from plugin transform hook is deprecated for using this.addWatchFile() instead.' + ); + // throw here to stop file system write + throw new Error('STOP'); + }, + plugins: [ + loader({ input: `alert('hello')` }), + { + name: 'x', + transform(code) { + return { code, dependencies: [] }; + } + } + ] + }); + return new Promise((resolve, reject) => { + watcher.on('event', evt => { + if (evt.code === 'END') resolve(); + else if (evt.code === 'ERROR' || evt.code === 'FATAL') reject(evt.error); + }); + }).catch(err => { + assert.equal(err.message, 'STOP'); + assert.equal(warned, true); + }); + }); + it('assigns chunk IDs before creating outputBundle chunks', () => { const chunks = []; return rollup diff --git a/test/incremental/index.js b/test/incremental/index.js index 91221bfa0ad..7d0e6adf77b 100644 --- a/test/incremental/index.js +++ b/test/incremental/index.js @@ -200,7 +200,6 @@ describe('incremental', () => { plugins: [plugin] }) .then(bundle => { - assert.equal(bundle.cache.modules[1].id, 'foo'); assert.equal(bundle.cache.modules[0].id, 'entry'); diff --git a/test/misc/deprecations.js b/test/misc/deprecations.js index 9790a6e70b7..d09dce716ba 100644 --- a/test/misc/deprecations.js +++ b/test/misc/deprecations.js @@ -1,63 +1,8 @@ const assert = require('assert'); const rollup = require('../../dist/rollup'); -const { executeBundle, loader } = require('../utils.js'); +const { loader } = require('../utils.js'); describe('deprecations', () => { - it('warns on options.entry, but handles', () => { - const warnings = []; - return rollup - .rollup({ - entry: 'x', - plugins: [loader({ x: `export default 42` })], - onwarn: warning => { - warnings.push(warning); - } - }) - .then(executeBundle) - .then(result => { - assert.equal(result, 42); - assert.deepEqual(warnings, [ - { - code: 'DEPRECATED_OPTIONS', - deprecations: [ - { - new: 'input', - old: 'entry' - } - ], - message: `The following options have been renamed — please update your config: entry -> input` - } - ]); - }); - }); - - it('adds deprecations correctly for rollup', () => { - const warnings = []; - return rollup - .rollup({ - entry: 'x', - format: 'cjs', - indent: true, - sourceMap: true, - plugins: [loader({ x: `export default 42` })], - onwarn: warning => { - warnings.push(warning); - } - }) - .then(executeBundle) - .then(result => { - assert.equal(result, 42); - const deprecations = warnings[0].deprecations; - assert.equal(deprecations.length, 4); - assert.deepEqual(deprecations, [ - { new: 'input', old: 'entry' }, - { new: 'output.indent', old: 'indent' }, - { new: 'output.sourcemap', old: 'sourceMap' }, - { new: 'output.format', old: 'format' } - ]); - }); - }); - it('throws a useful error on accessing code/map properties of bundle.generate promise', () => { return rollup .rollup({ diff --git a/test/misc/optionList.js b/test/misc/optionList.js index b536e16db49..87169db70b2 100644 --- a/test/misc/optionList.js +++ b/test/misc/optionList.js @@ -1,3 +1,3 @@ -exports.input = 'acorn, acornInjectPlugins, cache, chunkGroupingSize, context, entry, experimentalCacheExpiry, experimentalOptimizeChunks, experimentalTopLevelAwait, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preferConst, preserveModules, preserveSymlinks, shimMissingExports, treeshake, watch'; -exports.flags = 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, chunkGroupingSize, compact, config, context, dir, e, entry, entryFileNames, environment, esModule, experimentalCacheExpiry, experimentalOptimizeChunks, experimentalTopLevelAwait, exports, extend, external, f, file, footer, format, freeze, g, globals, h, i, indent, inlineDynamicImports, input, interop, intro, m, manualChunks, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, paths, perf, plugins, preferConst, preserveModules, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, strict, treeshake, v, w, watch'; +exports.input = 'acorn, acornInjectPlugins, cache, chunkGroupingSize, context, experimentalCacheExpiry, experimentalOptimizeChunks, experimentalTopLevelAwait, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preferConst, preserveModules, preserveSymlinks, shimMissingExports, treeshake, watch'; +exports.flags = 'acorn, acornInjectPlugins, amd, assetFileNames, banner, c, cache, chunkFileNames, chunkGroupingSize, compact, config, context, dir, e, entryFileNames, environment, esModule, experimentalCacheExpiry, experimentalOptimizeChunks, experimentalTopLevelAwait, exports, extend, external, f, file, footer, format, freeze, g, globals, h, i, indent, inlineDynamicImports, input, interop, intro, m, manualChunks, moduleContext, n, name, namespaceToStringTag, noConflict, o, onwarn, outro, paths, perf, plugins, preferConst, preserveModules, preserveSymlinks, shimMissingExports, silent, sourcemap, sourcemapExcludeSources, sourcemapFile, strict, treeshake, v, w, watch'; exports.output = 'amd, assetFileNames, banner, dir, chunkFileNames, compact, entryFileNames, esModule, exports, extend, file, footer, format, freeze, globals, indent, interop, intro, name, namespaceToStringTag, noConflict, outro, paths, sourcemap, sourcemapExcludeSources, sourcemapFile, sourcemapPathTransform, strict'; diff --git a/test/misc/sanity-checks.js b/test/misc/sanity-checks.js index f4685db7edc..9a89f4e52d0 100644 --- a/test/misc/sanity-checks.js +++ b/test/misc/sanity-checks.js @@ -23,26 +23,25 @@ describe('sanity checks', () => { }); it('node API passes warning and default handler to custom onwarn function', () => { - let args = []; + let args; return rollup .rollup({ - entry: 'x', - plugins: [loader({ x: `console.log( 42 );` })], + input: 'x', + plugins: [loader({ x: `console.log( 42 );` }), { ongenerate() {} }], onwarn(warning, onwarn) { args = [warning, onwarn]; } }) + .then(bundle => { + return bundle.generate({ format: 'es' }); + }) .then(() => { - assert.deepEqual(args[0], { - code: 'DEPRECATED_OPTIONS', - deprecations: [ - { - new: 'input', - old: 'entry' - } - ], - message: `The following options have been renamed — please update your config: entry -> input` - }); + assert.equal(args[0].code, 'PLUGIN_WARNING'); + assert.equal(args[0].pluginCode, 'ONGENERATE_HOOK_DEPRECATED'); + assert.equal( + args[0].message, + 'The ongenerate hook used by plugin at position 2 is deprecated. The generateBundle hook should be used instead.' + ); assert.equal(typeof args[1], 'function'); }); }); diff --git a/test/sourcemaps/samples/names-transformed/_config.js b/test/sourcemaps/samples/names-transformed/_config.js index 082174d79a3..a5ea19c906d 100644 --- a/test/sourcemaps/samples/names-transformed/_config.js +++ b/test/sourcemaps/samples/names-transformed/_config.js @@ -36,6 +36,12 @@ module.exports = { } ] }, + warnings: [{ + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin at position 1 is deprecated. The renderChunk hook should be used instead.', + plugin: 'Plugin at position 1', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }], test(code, map) { const smc = new SourceMapConsumer(map); diff --git a/test/sourcemaps/samples/transform-bundle-babili/_config.js b/test/sourcemaps/samples/transform-bundle-babili/_config.js index 181a5422b8c..8b17f8481cf 100644 --- a/test/sourcemaps/samples/transform-bundle-babili/_config.js +++ b/test/sourcemaps/samples/transform-bundle-babili/_config.js @@ -17,6 +17,12 @@ module.exports = { ], output: { indent: false } }, + warnings: [{ + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin at position 1 is deprecated. The renderChunk hook should be used instead.', + plugin: 'Plugin at position 1', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }], test(code, map) { const smc = new SourceMapConsumer(map); diff --git a/test/sourcemaps/samples/transform-bundle/_config.js b/test/sourcemaps/samples/transform-bundle/_config.js index 5303c9aad6d..1b503d3d1c6 100644 --- a/test/sourcemaps/samples/transform-bundle/_config.js +++ b/test/sourcemaps/samples/transform-bundle/_config.js @@ -20,6 +20,12 @@ module.exports = { } ] }, + warnings: [{ + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin at position 1 is deprecated. The renderChunk hook should be used instead.', + plugin: 'Plugin at position 1', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }], test(code, map) { const smc = new SourceMapConsumer(map); diff --git a/test/sourcemaps/samples/transform-without-sourcemap/_config.js b/test/sourcemaps/samples/transform-without-sourcemap/_config.js index 62f1b3ac8c8..bff5555cd7b 100644 --- a/test/sourcemaps/samples/transform-without-sourcemap/_config.js +++ b/test/sourcemaps/samples/transform-without-sourcemap/_config.js @@ -20,6 +20,12 @@ module.exports = { ] }, warnings: [ + { + code: 'PLUGIN_WARNING', + message: 'The transformBundle hook used by plugin fake plugin 2 is deprecated. The renderChunk hook should be used instead.', + plugin: 'fake plugin 2', + pluginCode: 'TRANSFORMBUNDLE_HOOK_DEPRECATED' + }, { code: `SOURCEMAP_BROKEN`, plugin: 'fake plugin 1', diff --git a/test/utils.js b/test/utils.js index e609479f3c9..bd9ab7b32bc 100644 --- a/test/utils.js +++ b/test/utils.js @@ -108,6 +108,7 @@ function removeOldOutput(dir) { } function removeOldTest(dir) { + removeOldOutput(dir); console.warn( `Test configuration in ${dir} not found.\nTrying to clean up no longer existing test...` );