From f08a7237f9fff154ce48301aa4e4129bd862caff Mon Sep 17 00:00:00 2001 From: Frank Wilkerson Date: Thu, 25 Jan 2018 20:46:36 -0700 Subject: [PATCH] add the option to emit build events when running microbundle programmatically --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index a93edc0..968e288 100644 --- a/src/index.js +++ b/src/index.js @@ -99,6 +99,7 @@ export default async function microbundle(options) { } if (options.watch) { + const emitEvents = options.emit; return new Promise( (resolve, reject) => { process.stdout.write(chalk.blue(`Watching source, compiling to ${relative(cwd, dirname(options.output))}:\n`)); steps.map( options => { @@ -109,6 +110,9 @@ export default async function microbundle(options) { if (e.code==='ERROR' || e.code==='FATAL') { return reject(e); } + if (emitEvents) { + process.emit('event', e); + } if (e.code==='END') { getSizeInfo(options._code, options.outputOptions.file).then( text => { process.stdout.write(`Wrote ${text.trim()}\n`);