add the option to emit build events when running microbundle programmatically

This commit is contained in:
Frank Wilkerson 2018-01-25 20:46:36 -07:00
parent 99746d8280
commit f08a7237f9

View File

@ -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`);