From 115a001c83af14a1f6e47d4164f495043552fffe Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 29 Jan 2020 20:35:32 +0100 Subject: [PATCH] Change writeBundle signature to match generateBundle --- src/rollup/rollup.ts | 2 +- src/rollup/types.d.ts | 6 +++++- test/hooks/index.js | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rollup/rollup.ts b/src/rollup/rollup.ts index cf965527798..0dde7ee009b 100644 --- a/src/rollup/rollup.ts +++ b/src/rollup/rollup.ts @@ -316,7 +316,7 @@ export async function rollupInternal( await Promise.all( Object.keys(bundle).map(chunkId => writeOutputFile(bundle[chunkId], outputOptions)) ); - await outputPluginDriver.hookParallel('writeBundle', [bundle]); + await outputPluginDriver.hookParallel('writeBundle', [outputOptions, bundle]); return createOutput(bundle); }); } diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index df1e4c9468c..e1d9dcb42af 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -332,7 +332,11 @@ interface OutputPluginHooks { resolveAssetUrl: ResolveAssetUrlHook; resolveDynamicImport: ResolveDynamicImportHook; resolveFileUrl: ResolveFileUrlHook; - writeBundle: (this: PluginContext, bundle: OutputBundle) => void | Promise; + writeBundle: ( + this: PluginContext, + options: OutputOptions, + bundle: OutputBundle + ) => void | Promise; } export interface PluginHooks extends OutputPluginHooks { diff --git a/test/hooks/index.js b/test/hooks/index.js index 873a9a1906c..2429dae5192 100644 --- a/test/hooks/index.js +++ b/test/hooks/index.js @@ -620,7 +620,8 @@ describe('hooks', () => { } }, { - writeBundle(outputBundle) { + writeBundle(options, outputBundle) { + assert.deepStrictEqual(options.file, file); assert.deepStrictEqual(outputBundle, bundle); callCount++; }