Skip to content

Commit 0ccc037

Browse files
committed
upgrade tapable for MultiCompiler
1 parent 31e9625 commit 0ccc037

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

lib/MultiCompiler.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
*/
55
"use strict";
66

7-
const Tapable = require("tapable-old");
7+
const Tapable = require("tapable").Tapable;
8+
const SyncHook = require("tapable").SyncHook;
89
const asyncLib = require("async");
910
const MultiWatching = require("./MultiWatching");
1011
const MultiStats = require("./MultiStats");
1112

1213
module.exports = class MultiCompiler extends Tapable {
1314
constructor(compilers) {
1415
super();
16+
this.hooks = {
17+
done: new SyncHook(["stats"]),
18+
invalid: new SyncHook([])
19+
};
1520
if(!Array.isArray(compilers)) {
1621
compilers = Object.keys(compilers).map((name) => {
1722
compilers[name].name = name;
@@ -30,15 +35,15 @@ module.exports = class MultiCompiler extends Tapable {
3035
}
3136
compilerStats[idx] = stats;
3237
if(doneCompilers === this.compilers.length) {
33-
this.applyPlugins("done", new MultiStats(compilerStats));
38+
this.hooks.done.call(new MultiStats(compilerStats));
3439
}
3540
});
3641
compiler.plugin("invalid", () => {
3742
if(compilerDone) {
3843
compilerDone = false;
3944
doneCompilers--;
4045
}
41-
this.applyPlugins("invalid");
46+
this.hooks.invalid.call();
4247
});
4348
});
4449
}

test/MultiCompiler.unittest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ describe("MultiCompiler", () => {
277277
});
278278

279279
it("returns a multi-watching object", () => {
280-
const result = JSON.stringify(env.result);
281-
result.should.be.exactly("{\"watchings\":[\"compiler1\",\"compiler2\"],\"compiler\":{\"_plugins\":{},\"compilers\":[{\"name\":\"compiler1\"},{\"name\":\"compiler2\"}]}}");
280+
const result = env.result;
281+
result.constructor.name.should.be.exactly("MultiWatching");
282282
});
283283

284284
it("calls watch on each compiler with original options", () => {

0 commit comments

Comments
 (0)