Skip to content

Commit eb81e9b

Browse files
committed
WIP17
1 parent 8f1f5c6 commit eb81e9b

File tree

7 files changed

+19
-20
lines changed

7 files changed

+19
-20
lines changed

examples/source-map/webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var path = require("path");
2-
var webpack = require("../../");
32

43
module.exports = [
54
"cheap-eval-source-map",

lib/Stats.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class Stats {
147147
if(excluded)
148148
return false;
149149
}
150-
return i++ < maxModules;
150+
const result = i++ < maxModules;
151+
return result;
151152
};
152153
};
153154

lib/optimize/AggressiveMergingPlugin.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ class AggressiveMergingPlugin {
1616
const options = this.options;
1717
const minSizeReduce = options.minSizeReduce || 1.5;
1818

19-
const getParentsWeight = chunk => {
20-
return chunk.mapParents((p) => {
21-
return p.isInitial() ? options.entryChunkMultiplicator || 10 : 1;
22-
}).reduce((a, b) => {
23-
return a + b;
24-
}, 0);
25-
};
26-
2719
compiler.hooks.thisCompilation.tap("AggressiveMergingPlugin", (compilation) => {
2820
compilation.hooks.optimizeChunksAdvanced.tap("AggressiveMergingPlugin", (chunks) => {
2921
let combinations = [];

lib/optimize/AutomaticCommonsChunksPlugin.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const isOverlap = (a, b) => {
3333
if(b.has(item)) return true;
3434
}
3535
return false;
36-
}
36+
};
3737

3838
const compareEntries = (a, b) => {
3939
// 1. by total modules size
@@ -79,17 +79,20 @@ module.exports = class AutomaticCommonsChunksPlugin {
7979

8080
static normalizeName(option) {
8181
if(option === true) {
82-
return (module, chunks, cacheGroup) => {
82+
const fn = (module, chunks, cacheGroup) => {
8383
const names = chunks.map(c => c.name);
8484
if(!names.every(Boolean)) return;
8585
names.sort();
86-
return (cacheGroup ? cacheGroup + "~" : "") + names.join("~");
86+
const name = (cacheGroup ? cacheGroup + "~" : "") + names.join("~");
87+
return name;
8788
};
89+
return fn;
8890
}
8991
if(typeof option === "string") {
90-
return () => {
92+
const fn = () => {
9193
return option;
9294
};
95+
return fn;
9396
}
9497
if(typeof option === "function")
9598
return option;
@@ -105,7 +108,7 @@ module.exports = class AutomaticCommonsChunksPlugin {
105108
};
106109
}
107110
if(cacheGroups && typeof cacheGroups === "object") {
108-
return (module, chunks) => {
111+
const fn = (module, chunks) => {
109112
let results;
110113
for(const key of Object.keys(cacheGroups)) {
111114
let option = cacheGroups[key];
@@ -143,8 +146,10 @@ module.exports = class AutomaticCommonsChunksPlugin {
143146
}
144147
return results;
145148
};
149+
return fn;
146150
}
147-
return () => {};
151+
const fn = () => {};
152+
return fn;
148153
}
149154

150155
static checkTest(test, module, chunks) {

lib/optimize/RuntimeChunkPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ module.exports = class RuntimeChunkPlugin {
2222
});
2323
});
2424
}
25-
}
25+
};

lib/util/createHash.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ module.exports = algorithm => {
5959
return new BulkUpdateDecorator(new algorithm());
6060
}
6161
switch(algorithm) {
62-
case "debug": return new DebugHash();
6362
// TODO add non-cryptographic algorithm here
64-
default: return new BulkUpdateDecorator(require("crypto").createHash(algorithm));
63+
case "debug":
64+
return new DebugHash();
65+
default:
66+
return new BulkUpdateDecorator(require("crypto").createHash(algorithm));
6567
}
6668
};

test/configCases/async-commons-chunk/existing-name/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ it("should not have duplicate chunks in blocks", function(done) {
2828
// - a, a+b
2929
// - a, a+b, a+b+c
3030
chunkLoadingSpy.callCount.should.be.eql(6);
31-
chunkLoadingSpy.args.should.be.eql([["a"], ["a+b~a+b+c" /* == b */], ["a"], ["a+b~a+b+c" /* == b */], ["a"], ["a+b+c"]]);
31+
chunkLoadingSpy.args.should.be.eql([["a"], ["a"], ["a+b~a+b+c" /* == b */], ["a"], ["a+b~a+b+c" /* == b */], ["a+b+c"]]);
3232
done();
3333
});

0 commit comments

Comments
 (0)