1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getPluginHooks = void 0;
|
4 | const tapable_1 = require("tapable");
|
5 | const compilerHookMap = new WeakMap();
|
6 | function createPluginHooks() {
|
7 | return {
|
8 | start: new tapable_1.AsyncSeriesWaterfallHook([
|
9 | 'change',
|
10 | 'compilation',
|
11 | ]),
|
12 | waiting: new tapable_1.SyncHook(['compilation']),
|
13 | canceled: new tapable_1.SyncHook(['compilation']),
|
14 | error: new tapable_1.SyncHook(['error', 'compilation']),
|
15 | issues: new tapable_1.SyncWaterfallHook([
|
16 | 'issues',
|
17 | 'compilation',
|
18 | ]),
|
19 | };
|
20 | }
|
21 | function forwardPluginHooks(source, target) {
|
22 | source.start.tapPromise('ForkTsCheckerWebpackPlugin', target.start.promise);
|
23 | source.waiting.tap('ForkTsCheckerWebpackPlugin', target.waiting.call);
|
24 | source.canceled.tap('ForkTsCheckerWebpackPlugin', target.canceled.call);
|
25 | source.error.tap('ForkTsCheckerWebpackPlugin', target.error.call);
|
26 | source.issues.tap('ForkTsCheckerWebpackPlugin', target.issues.call);
|
27 | }
|
28 | function getPluginHooks(compiler) {
|
29 | let hooks = compilerHookMap.get(compiler);
|
30 | if (hooks === undefined) {
|
31 | hooks = createPluginHooks();
|
32 | compilerHookMap.set(compiler, hooks);
|
33 |
|
34 | if ('compilers' in compiler) {
|
35 | compiler.compilers.forEach((childCompiler) => {
|
36 | const childHooks = getPluginHooks(childCompiler);
|
37 | if (hooks) {
|
38 | forwardPluginHooks(childHooks, hooks);
|
39 | }
|
40 | });
|
41 | }
|
42 | }
|
43 | return hooks;
|
44 | }
|
45 | exports.getPluginHooks = getPluginHooks;
|