MCPcopy
hub / github.com/webpack/webpack / apply

Method apply

lib/IgnorePlugin.js:67–106  ·  lib/IgnorePlugin.js::IgnorePlugin.apply

* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

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
109module.exports = IgnorePlugin;

Callers

nothing calls this directly

Calls 4

checkIgnoreMethod · 0.95
tapMethod · 0.80
validateMethod · 0.80
requireFunction · 0.50

Tested by

no test coverage detected