Skip to content

Commit 915c150

Browse files
committed
fix bug in MinChunkSizePlugin
fix #4532
1 parent 46dc08e commit 915c150

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

lib/optimize/MinChunkSizePlugin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class MinChunkSizePlugin {
3939
const a = pair[0].size(options);
4040
const b = pair[1].size(options);
4141
const ab = pair[0].integratedSize(pair[1], options);
42-
pair.unshift(a + b - ab, ab);
4342
return [a + b - ab, ab, pair[0], pair[1]];
4443
}).filter((pair) => {
4544
// filter pairs that do not have an integratedSize
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "a";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "b";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
it("should combine two chunk if too small", done => {
2+
// b should not yet available
3+
var bf = __webpack_modules__[require.resolveWeak("./b")];
4+
(typeof bf).should.be.eql("undefined");
5+
6+
// load a
7+
import("./a").then(a => {
8+
a.default.should.be.eql("a");
9+
// check if b is available too
10+
var bf = __webpack_modules__[require.resolveWeak("./b")];
11+
(typeof bf).should.be.eql("function");
12+
13+
// load b (just to check if it's ok)
14+
import("./b").then(b => {
15+
b.default.should.be.eql("b");
16+
done();
17+
}).catch(done);
18+
}).catch(done);
19+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var webpack = require("../../../../")
2+
3+
module.exports = {
4+
plugins: [
5+
new webpack.optimize.MinChunkSizePlugin({
6+
minChunkSize: 30
7+
})
8+
]
9+
}

0 commit comments

Comments
 (0)