From 4ffe9451e97a946980a9bf1fbb070483dc9bf4ce Mon Sep 17 00:00:00 2001 From: Frank Wilkerson Date: Fri, 26 Jan 2018 17:55:55 -0700 Subject: [PATCH] a more specific api than just emit --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 4e8036a..16b519b 100644 --- a/src/index.js +++ b/src/index.js @@ -99,7 +99,7 @@ export default async function microbundle(options) { } if (options.watch) { - const emit = options.emit; + const onBuild = options.onBuild; return new Promise( (resolve, reject) => { process.stdout.write(chalk.blue(`Watching source, compiling to ${relative(cwd, dirname(options.output))}:\n`)); steps.map( options => { @@ -107,9 +107,6 @@ export default async function microbundle(options) { output: options.outputOptions, watch: WATCH_OPTS }, options.inputOptions)).on('event', e => { - if (emit) { - process.emit('event', e); - } if (e.code==='ERROR' || e.code==='FATAL') { return reject(e); } @@ -117,6 +114,9 @@ export default async function microbundle(options) { getSizeInfo(options._code, options.outputOptions.file).then( text => { process.stdout.write(`Wrote ${text.trim()}\n`); }); + if (typeof onBuild=='function') { + onBuild(e); + } } }); });