1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
9 | const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
10 |
|
11 |
|
12 |
|
13 | class DelegatedPlugin {
|
14 | constructor(options) {
|
15 | this.options = options;
|
16 | }
|
17 |
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 | apply(compiler) {
|
24 | compiler.hooks.compilation.tap(
|
25 | "DelegatedPlugin",
|
26 | (compilation, { normalModuleFactory }) => {
|
27 | compilation.dependencyFactories.set(
|
28 | DelegatedSourceDependency,
|
29 | normalModuleFactory
|
30 | );
|
31 | }
|
32 | );
|
33 |
|
34 | compiler.hooks.compile.tap("DelegatedPlugin", ({ normalModuleFactory }) => {
|
35 | new DelegatedModuleFactoryPlugin({
|
36 | associatedObjectForCache: compiler.root,
|
37 | ...this.options
|
38 | }).apply(normalModuleFactory);
|
39 | });
|
40 | }
|
41 | }
|
42 |
|
43 | module.exports = DelegatedPlugin;
|