Skip to content

Commit

Permalink
unite iteration through modules into one loop
Browse files Browse the repository at this point in the history
  • Loading branch information
timse committed Jun 18, 2017
1 parent 083843e commit fc20348
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -143,20 +143,29 @@ class ConcatenatedModule extends Module {
this.cacheable = modules.every(m => m.cacheable);
const modulesSet = new Set(modules);
this.reasons = rootModule.reasons.filter(reason => !modulesSet.has(reason.module));
this.dependencies = [];
this.meta = rootModule.meta;
this.dependenciesWarnings = modules.reduce((w, m) => m.dependenciesWarnings.forEach(x => w.push(x)), []);
this.dependenciesErrors = modules.reduce((w, m) => m.dependenciesErrors.forEach(x => w.push(x)), []);
this.warnings = modules.reduce((w, m) => m.warnings.forEach(x => w.push(x)), []);
this.errors = modules.reduce((w, m) => m.errors.forEach(x => w.push(x)), []);
this.moduleArgument = rootModule.moduleArgument;
this.exportsArgument = rootModule.exportsArgument;
this.strict = true;
modules.forEach((m, idx) => {
for(const dep of m.dependencies.filter(dep => !modulesSet.has(dep.module))) {
this.dependencies.push(dep);
}
});

this.dependencies = [];
this.dependenciesWarnings = [];
this.dependenciesErrors = [];
this.warnings = [];
this.errors = [];
for(const m of modules) {
// populate dependencies
m.dependencies.filter(dep => !modulesSet.has(dep.module))
.forEach(d => this.dependencies.push(d));
// populate dep warning
m.dependenciesWarnings.forEach(depWarning => this.dependenciesWarnings.push(depWarning));
// populate dep errors
m.dependenciesErrors.forEach(depError => this.dependenciesErrors.push(depError));
// populate warnings
m.warnings.forEach(warning => this.warnings.push(warning));
// populate errors
m.errors.forEach(error => this.errors.push(error));
}
}

identifier() {
Expand Down

0 comments on commit fc20348

Please sign in to comment.