diff --git a/build-system/tasks/extension-helpers.js b/build-system/tasks/extension-helpers.js index 37ab77068632..ae77011efe21 100644 --- a/build-system/tasks/extension-helpers.js +++ b/build-system/tasks/extension-helpers.js @@ -356,22 +356,28 @@ function buildExtension( if (options.compileOnlyCss && !hasCss) { return Promise.resolve(); } + const path = 'extensions/' + name + '/' + version; + // Use a separate watcher for extensions to copy / inline CSS and compile JS // instead of relying on the watcher used by compileUnminifiedJs, which only // recompiles JS. - const path = 'extensions/' + name + '/' + version; - const optionsCopy = Object.create(options); if (options.watch) { - optionsCopy.watch = false; + options.watch = false; watch(path + '/*', function() { - buildExtension(name, version, latestVersion, hasCss, optionsCopy); + buildExtension( + name, + version, + latestVersion, + hasCss, + Object.assign({}, options, {continueOnError: true}) + ); }); } const promises = []; if (hasCss) { mkdirSync('build'); mkdirSync('build/css'); - const buildCssPromise = buildExtensionCss(path, name, version, optionsCopy); + const buildCssPromise = buildExtensionCss(path, name, version, options); if (options.compileOnlyCss) { return buildCssPromise; } @@ -388,7 +394,7 @@ function buildExtension( if (argv.single_pass) { return Promise.resolve(); } else { - return buildExtensionJs(path, name, version, latestVersion, optionsCopy); + return buildExtensionJs(path, name, version, latestVersion, options); } }); } diff --git a/build-system/tasks/helpers.js b/build-system/tasks/helpers.js index 8e212b5a1313..ca8ff0095509 100644 --- a/build-system/tasks/helpers.js +++ b/build-system/tasks/helpers.js @@ -370,21 +370,20 @@ function compileMinifiedJs(srcDir, srcFilename, destDir, options) { /** * Handles a browserify bundling error * @param {Error} err - * @param {boolean} failOnError - * @param {string} srcFilename - * @param {string} startTime + * @param {boolean} continueOnError + * @param {string} destFilename */ -function handleBundleError(err, failOnError, srcFilename, startTime) { +function handleBundleError(err, continueOnError, destFilename) { let message = err; if (err.stack) { // Drop the node_modules call stack, which begins with ' at'. message = err.stack.replace(/ at[^]*/, '').trim(); } console.error(red(message)); - if (failOnError) { - process.exit(1); + if (continueOnError) { + log('Error while compiling', cyan(destFilename)); } else { - endBuildStep('Error while compiling', srcFilename, startTime); + process.exit(1); } } @@ -452,21 +451,21 @@ function compileUnminifiedJs(srcDir, srcFilename, destDir, options) { if (options.watch) { bundler = watchify(bundler); - bundler.on('update', () => performBundle(/* failOnError */ false)); + bundler.on('update', () => performBundle(/* continueOnError */ true)); } /** - * @param {boolean} failOnError + * @param {boolean} continueOnError * @return {Promise} */ - function performBundle(failOnError) { + function performBundle(continueOnError) { let startTime; return toPromise( bundler .bundle() .once('readable', () => (startTime = Date.now())) .on('error', err => - handleBundleError(err, failOnError, srcFilename, startTime) + handleBundleError(err, continueOnError, destFilename) ) .pipe(source(srcFilename)) .pipe(buffer()) @@ -501,7 +500,7 @@ function compileUnminifiedJs(srcDir, srcFilename, destDir, options) { }); } - return performBundle(/* failOnError */ true); + return performBundle(options.continueOnError); } /**