Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate code #5084

Merged
merged 3 commits into from
Jun 18, 2017
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
29 changes: 19 additions & 10 deletions lib/optimize/ConcatenatedModule.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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