diff --git a/crates/rspack_core/src/options/module.rs b/crates/rspack_core/src/options/module.rs index 584cd2034ad..f49e9e064ef 100644 --- a/crates/rspack_core/src/options/module.rs +++ b/crates/rspack_core/src/options/module.rs @@ -639,7 +639,7 @@ impl RuleSetCondition { } #[async_recursion] - pub async fn match_when_empty(&self) -> Result { + async fn match_when_empty(&self) -> Result { let res = match self { RuleSetCondition::String(s) => s.len() == 0, RuleSetCondition::Regexp(rspack_regex) => rspack_regex.test(""), @@ -655,7 +655,7 @@ impl RuleSetCondition { #[derive(Debug)] pub struct RuleSetConditionMatch { - pub condition: RuleSetCondition, + condition: RuleSetCondition, match_when_empty: RwLock>, } @@ -759,17 +759,17 @@ pub struct ModuleRule { /// Note: /// This is a custom matching rule not initially designed by webpack. /// Only for single-threaded environment interoperation purpose. - pub rspack_resource: Option, + pub rspack_resource: Option, /// A condition matcher matching an absolute path. - pub test: Option, - pub include: Option, - pub exclude: Option, + pub test: Option, + pub include: Option, + pub exclude: Option, /// A condition matcher matching an absolute path. - pub resource: Option, + pub resource: Option, /// A condition matcher against the resource query. pub resource_query: Option, pub resource_fragment: Option, - pub dependency: Option, + pub dependency: Option, pub issuer: Option, pub issuer_layer: Option, pub scheme: Option, diff --git a/crates/rspack_core/src/utils/module_rules.rs b/crates/rspack_core/src/utils/module_rules.rs index 15c6afbbedf..a35e6dc5e41 100644 --- a/crates/rspack_core/src/utils/module_rules.rs +++ b/crates/rspack_core/src/utils/module_rules.rs @@ -87,7 +87,7 @@ pub async fn module_rule_matcher<'a>( return Ok(false); } } else { - if !resource_query_rule.condition.match_when_empty().await? { + if !resource_query_rule.match_when_empty().await? { return Ok(false); } } @@ -102,11 +102,7 @@ pub async fn module_rule_matcher<'a>( return Ok(false); } } else { - if !resource_fragment_condition - .condition - .match_when_empty() - .await? - { + if !resource_fragment_condition.match_when_empty().await? { return Ok(false); } } @@ -121,7 +117,7 @@ pub async fn module_rule_matcher<'a>( return Ok(false); } } else { - if !mimetype_condition.condition.match_when_empty().await? { + if !mimetype_condition.match_when_empty().await? { return Ok(false); } } @@ -130,7 +126,7 @@ pub async fn module_rule_matcher<'a>( if let Some(scheme_condition) = &module_rule.scheme { let scheme = resource_data.get_scheme(); if scheme.is_none() { - if !scheme_condition.condition.match_when_empty().await? { + if !scheme_condition.match_when_empty().await? { return Ok(false); } } @@ -147,7 +143,7 @@ pub async fn module_rule_matcher<'a>( } } None => { - if !issuer_rule.condition.match_when_empty().await? { + if !issuer_rule.match_when_empty().await? { return Ok(false); } } @@ -162,7 +158,7 @@ pub async fn module_rule_matcher<'a>( } } None => { - if !issuer_layer_rule.condition.match_when_empty().await? { + if !issuer_layer_rule.match_when_empty().await? { return Ok(false); } }