Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1015 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
---|
| 9 | const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
---|
| 10 |
|
---|
| 11 | /** @typedef {import("./Compiler")} Compiler */
|
---|
| 12 |
|
---|
| 13 | class DelegatedPlugin {
|
---|
| 14 | constructor(options) {
|
---|
| 15 | this.options = options;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | /**
|
---|
| 19 | * Apply the plugin
|
---|
| 20 | * @param {Compiler} compiler the compiler instance
|
---|
| 21 | * @returns {void}
|
---|
| 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;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.