Skip to content

Commit

Permalink
Merge pull request #5084 from timse/remove-duplicate-code
Browse files Browse the repository at this point in the history
Remove duplicate code
  • Loading branch information
sokra committed Jun 18, 2017
2 parents ab636b0 + ae18552 commit 316d4b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 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 = [].concat.apply([], modules.map(m => m.dependencies.filter(dep => !modulesSet.has(dep.module))));
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
4 changes: 2 additions & 2 deletions test/statsCases/scope-hoisting-multi/expected.txt
@@ -1,4 +1,4 @@
Hash: 731069e082cf620521ced84ccc10b5c4fc7695db
Hash: 731069e082cf620521ce1e4286719458d8076cfc
Child
Hash: 731069e082cf620521ce
Time: Xms
Expand All @@ -14,7 +14,7 @@ Child
[9] (webpack)/test/statsCases/scope-hoisting-multi/second.js 177 bytes {4} [built]
[10] (webpack)/test/statsCases/scope-hoisting-multi/lazy_second.js 55 bytes {1} [built]
Child
Hash: d84ccc10b5c4fc7695db
Hash: 1e4286719458d8076cfc
Time: Xms
[0] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built]
[1] (webpack)/test/statsCases/scope-hoisting-multi/vendor.js 25 bytes {5} [built]
Expand Down

0 comments on commit 316d4b9

Please sign in to comment.