MCPcopy Create free account
hub / github.com/webpack/webpack / apply

Method apply

lib/IgnorePlugin.js:67–106  ·  view source on GitHub ↗

* 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("../schemas/plugins/IgnorePlugin.json")),
72 this.options,
73 {
74 name: "Ignore Plugin",
75 baseDataPath: "options"
76 },
77 (options) => require("../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 "",
92 "ignored-entry-module",
93 "(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