Skip to content

Commit ae6c7a4

Browse files
authored
Merge pull request webpack#7279 from cokencode/progress-plugin-bug-fix
Fix a bug where ProgressPlugin is not working properly with MultiComp…
2 parents 4073814 + 9c0036b commit ae6c7a4

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

lib/ProgressPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class ProgressPlugin {
8383
const states = new Array(compiler.compilers.length);
8484
compiler.compilers.forEach((compiler, idx) => {
8585
new ProgressPlugin((p, msg, ...args) => {
86-
states[idx] = args;
86+
states[idx] = [p, msg, ...args];
8787
handler(
8888
states
8989
.map(state => (state && state[0]) || 0)

test/ProgressPlugin.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"use strict";
2+
3+
const path = require("path");
4+
const MemoryFs = require("memory-fs");
5+
const webpack = require("../");
6+
7+
const createMultiCompiler = () => {
8+
const compiler = webpack([
9+
{
10+
context: path.join(__dirname, "fixtures"),
11+
entry: "./a.js"
12+
},
13+
{
14+
context: path.join(__dirname, "fixtures"),
15+
entry: "./b.js"
16+
}
17+
]);
18+
compiler.outputFileSystem = new MemoryFs();
19+
return compiler;
20+
};
21+
22+
describe("ProgressPlugin", function() {
23+
it("should not contain NaN as a percentage when it is applied to MultiCompiler", function(done) {
24+
const compiler = createMultiCompiler();
25+
26+
let percentage = 0;
27+
new webpack.ProgressPlugin((p, msg, ...args) => {
28+
percentage += p;
29+
}).apply(compiler);
30+
31+
compiler.run(err => {
32+
if (err) {
33+
throw err;
34+
} else {
35+
expect(percentage).not.toBe(NaN);
36+
done();
37+
}
38+
});
39+
});
40+
});

0 commit comments

Comments
 (0)