Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions build-system/tasks/extension-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment thread
rsimha marked this conversation as resolved.
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;
}
Expand All @@ -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);
}
});
}
Expand Down
23 changes: 11 additions & 12 deletions build-system/tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,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);
}
}

Expand Down Expand Up @@ -448,21 +447,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())
Expand Down Expand Up @@ -497,7 +496,7 @@ function compileUnminifiedJs(srcDir, srcFilename, destDir, options) {
});
}

return performBundle(/* failOnError */ true);
return performBundle(options.continueOnError);
}

/**
Expand Down