From 139e3769dc3e191284ff119cbf596a674bff097f Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Thu, 16 Nov 2017 02:30:49 +0100 Subject: [PATCH] Generate returns a promise https://github.com/rollup/rollup/blob/master/src/rollup/index.js#L157-L188 "map" will be null if GenerateOptions.sourceMap is false --- types/rollup/index.d.ts | 2 +- types/rollup/rollup-tests.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/rollup/index.d.ts b/types/rollup/index.d.ts index 19dcb12f27..f4afd2c804 100644 --- a/types/rollup/index.d.ts +++ b/types/rollup/index.d.ts @@ -84,7 +84,7 @@ export interface WriteOptions extends BundleOptions { export interface Bundle { /** Generate bundled code as an object */ - generate(options: GenerateOptions): { code: string, map: SourceMap } + generate(options: GenerateOptions): Promise<{ code: string, map: SourceMap | null }> /** writes the file (and accompanying sourcemap file, if appropriate) to the file system. */ write(options: WriteOptions): Promise } diff --git a/types/rollup/rollup-tests.ts b/types/rollup/rollup-tests.ts index 4c0e95a1a6..b3306ef7f3 100644 --- a/types/rollup/rollup-tests.ts +++ b/types/rollup/rollup-tests.ts @@ -29,12 +29,14 @@ async function main() { plugins: plugin }) - const result = bundle.generate({ + const { code, map } = await bundle.generate({ format: 'cjs', indent: false, sourcemap: true, }) + console.log(code, map) + cache = bundle await bundle.write({