Replaced async.queue with async.cargo
Cargo in fact, bundles up subsequent tasks in to an array, so any tasks that are not immediately run get bundled in to another run later. This helps when lots of changes have been made in a short period of time.
This commit is contained in:
parent
e788b7d3d4
commit
7c9d90090a
|
@ -108,9 +108,9 @@ class Engine {
|
|||
this.registerModule('pipeline', {
|
||||
webpackConfigName: this.webpackConfigName
|
||||
});
|
||||
this.events.on('code-generator-ready', function (modifiedAsset) {
|
||||
this.events.on('code-generator-ready', function (modifiedAssets) {
|
||||
self.events.request('code', function (abi, contractsJSON) {
|
||||
self.events.request('pipeline:build', {abi, contractsJSON, modifiedAsset}, () => {
|
||||
self.events.request('pipeline:build', {abi, contractsJSON, modifiedAssets}, () => {
|
||||
self.events.emit('outputDone');
|
||||
});
|
||||
});
|
||||
|
@ -162,15 +162,16 @@ class Engine {
|
|||
|
||||
this.registerModule('code_generator', {plugins: self.plugins, env: self.env});
|
||||
|
||||
const generateCode = function (modifiedAsset) {
|
||||
const generateCode = function (modifiedAssets) {
|
||||
self.events.request("code-generator:embarkjs:build", () => {
|
||||
self.events.emit('code-generator-ready', modifiedAsset);
|
||||
self.events.emit('code-generator-ready', modifiedAssets);
|
||||
});
|
||||
};
|
||||
const cargo = async.queue((task, callback) => {
|
||||
generateCode(task.modifiedAsset);
|
||||
const cargo = async.cargo((tasks, callback) => {
|
||||
const modifiedAssets = tasks.map(task => task.modifiedAsset);
|
||||
generateCode(modifiedAssets);
|
||||
self.events.once('outputDone', callback);
|
||||
}, 3);
|
||||
});
|
||||
const addToCargo = function (modifiedAsset) {
|
||||
cargo.push({modifiedAsset});
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ class Pipeline {
|
|||
fs.removeSync(this.buildDir);
|
||||
}
|
||||
|
||||
build({modifiedAsset}, callback) {
|
||||
build({modifiedAssets}, callback) {
|
||||
let self = this;
|
||||
const importsList = {};
|
||||
let placeholderPage;
|
||||
|
@ -86,7 +86,7 @@ class Pipeline {
|
|||
function shouldRunWebpack(next){
|
||||
// assuming we got here because an asset was changed, let's check our webpack config
|
||||
// to see if the changed asset requires webpack to run
|
||||
if(modifiedAsset){
|
||||
if(modifiedAssets){
|
||||
const configReader = new WebpackConfigReader({webpackConfigName: self.webpackConfigName});
|
||||
return configReader.readConfig((err, config) => {
|
||||
if(err) return next(err);
|
||||
|
@ -95,7 +95,7 @@ class Pipeline {
|
|||
return next(__('bad webpack config, the resolved config was null or not an object'));
|
||||
}
|
||||
|
||||
const shouldRun = config.module.rules.some(rule => rule.test.test(modifiedAsset));
|
||||
const shouldRun = modifiedAssets.some(modifiedAsset => config.module.rules.some(rule => rule.test.test(modifiedAsset)));
|
||||
return next(null, !shouldRun);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue