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
This commit is contained in:
Christian Svensson
2017-11-16 02:30:49 +01:00
parent d97047d4f5
commit 139e3769dc
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -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<void>
}
+3 -1
View File
@@ -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({