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

Method apply

lib/rules/ObjectMatcherRulePlugin.js:47–79  ·  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

45 * @returns {void}
46 */
47 apply(ruleSetCompiler) {
48 const { ruleProperty, dataProperty } = this;
49 ruleSetCompiler.hooks.rule.tap(
50 PLUGIN_NAME,
51 (path, rule, unhandledProperties, result) => {
52 if (unhandledProperties.has(ruleProperty)) {
53 unhandledProperties.delete(ruleProperty);
54 const value =
55 /** @type {Record<string, RuleSetConditionOrConditions>} */
56 (rule[ruleProperty]);
57 for (const property of Object.keys(value)) {
58 const nestedDataProperties = property.split(".");
59 const condition = ruleSetCompiler.compileCondition(
60 `${path}.${ruleProperty}.${property}`,
61 value[property]
62 );
63 if (this.additionalConditionFunction) {
64 result.conditions.push({
65 property: [dataProperty],
66 matchWhenEmpty: condition.matchWhenEmpty,
67 fn: this.additionalConditionFunction
68 });
69 }
70 result.conditions.push({
71 property: [dataProperty, ...nestedDataProperties],
72 matchWhenEmpty: condition.matchWhenEmpty,
73 fn: condition.fn
74 });
75 }
76 }
77 }
78 );
79 }
80}
81
82module.exports = ObjectMatcherRulePlugin;

Callers

nothing calls this directly

Calls 7

tapMethod · 0.80
splitMethod · 0.80
compileConditionMethod · 0.80
keysMethod · 0.65
hasMethod · 0.45
deleteMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected