* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 65 | * @returns {void} |
| 66 | */ |
| 67 | apply(compiler) { |
| 68 | compiler.hooks.validate.tap(PLUGIN_NAME, () => { |
| 69 | compiler.validate( |
| 70 | /** @type {EXPECTED_ANY} */ |
| 71 | (require(class="st">"../schemas/plugins/IgnorePlugin.json")), |
| 72 | this.options, |
| 73 | { |
| 74 | name: class="st">"Ignore Plugin", |
| 75 | baseDataPath: class="st">"options" |
| 76 | }, |
| 77 | (options) => require(class="st">"../schemas/plugins/IgnorePlugin.check")(options) |
| 78 | ); |
| 79 | }); |
| 80 | |
| 81 | compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, (nmf) => { |
| 82 | nmf.hooks.beforeResolve.tap(PLUGIN_NAME, (resolveData) => { |
| 83 | const result = this.checkIgnore(resolveData); |
| 84 | |
| 85 | if ( |
| 86 | result === false && |
| 87 | resolveData.dependencies.length > 0 && |
| 88 | resolveData.dependencies[0] instanceof EntryDependency |
| 89 | ) { |
| 90 | const module = new RawModule( |
| 91 | class="st">"", |
| 92 | class="st">"ignored-entry-module", |
| 93 | class="st">"(ignored-entry-module)" |
| 94 | ); |
| 95 | module.factoryMeta = { sideEffectFree: true }; |
| 96 | |
| 97 | resolveData.ignoredModule = module; |
| 98 | } |
| 99 | |
| 100 | return result; |
| 101 | }); |
| 102 | }); |
| 103 | compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, (cmf) => { |
| 104 | cmf.hooks.beforeResolve.tap(PLUGIN_NAME, this.checkIgnore); |
| 105 | }); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | module.exports = IgnorePlugin; |
nothing calls this directly
no test coverage detected