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

Method apply

lib/rules/BasicMatcherRulePlugin.js:45–68  ·  view source on GitHub ↗

* Applies the plugin by registering its hooks on the compiler. * @param {RuleSetCompiler} ruleSetCompiler the rule set compiler * @returns {void}

(ruleSetCompiler)

Source from the content-addressed store, hash-verified

43 * @returns {void}
44 */
45 apply(ruleSetCompiler) {
46 ruleSetCompiler.hooks.rule.tap(
47 PLUGIN_NAME,
48 (path, rule, unhandledProperties, result) => {
49 if (unhandledProperties.has(this.ruleProperty)) {
50 unhandledProperties.delete(this.ruleProperty);
51 const value = rule[this.ruleProperty];
52 const condition = ruleSetCompiler.compileCondition(
53 `${path}.${this.ruleProperty}`,
54 /** @type {RuleSetConditionOrConditions | RuleSetConditionOrConditionsAbsolute} */
55 (value)
56 );
57 const fn = condition.fn;
58 result.conditions.push({
59 property: this.dataProperty,
60 matchWhenEmpty: this.invert
61 ? !condition.matchWhenEmpty
62 : condition.matchWhenEmpty,
63 fn: this.invert ? (v) => !fn(v) : fn
64 });
65 }
66 }
67 );
68 }
69}
70
71module.exports = BasicMatcherRulePlugin;

Callers

nothing calls this directly

Calls 6

tapMethod · 0.80
compileConditionMethod · 0.80
fnFunction · 0.50
hasMethod · 0.45
deleteMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected