Skip to content

Commit e4411ef

Browse files
committed
fixup
1 parent e00fe99 commit e4411ef

File tree

1 file changed

+25
-8
lines changed
  • turbopack/crates/turbopack/src/module_options

1 file changed

+25
-8
lines changed

turbopack/crates/turbopack/src/module_options/mod.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,17 @@ impl ModuleOptions {
160160
// For React Client References, the CSS Module "facade" module lives in the parent (server)
161161
// module context, but the facade's references should be transitioned to the client (and
162162
// only then be processed with Webpack/PostCSS).
163-
let module_css_external_transform_condition = RuleCondition::Any(vec![
164-
// If module css, then only when (Inner or Analyze or Compose)
165-
// <=> (not (module css)) or (Inner or Analyzer or Compose)
166-
RuleCondition::not(module_css_condition.clone()),
163+
//
164+
// Note that this is not an exhaustive condition for PostCSS/Webpack, but excludes certain
165+
// cases, so it should be added conjunctively together with the `module_css_condition` rule.
166+
//
167+
// If module css, then only when (Inner or Analyze or Compose)
168+
// <=> (not (module css)) or (Inner or Analyzer or Compose)
169+
let module_css_external_transform_conditions = vec![
167170
RuleCondition::ReferenceType(ReferenceType::Css(CssReferenceSubType::Inner)),
168171
RuleCondition::ReferenceType(ReferenceType::Css(CssReferenceSubType::Analyze)),
169172
RuleCondition::ReferenceType(ReferenceType::Css(CssReferenceSubType::Compose)),
170-
]);
173+
];
171174

172175
let mut ts_preprocess = vec![];
173176
let mut ecma_preprocess = vec![];
@@ -502,15 +505,22 @@ impl ModuleOptions {
502505
};
503506

504507
rules.push(ModuleRule::new(
505-
RuleCondition::All(vec![
508+
RuleCondition::Any(vec![
506509
RuleCondition::All(vec![
507510
RuleCondition::Any(vec![
508511
RuleCondition::ResourcePathEndsWith(".css".to_string()),
509512
RuleCondition::ContentTypeStartsWith("text/css".to_string()),
510513
]),
511514
RuleCondition::not(module_css_condition.clone()),
512515
]),
513-
module_css_external_transform_condition.clone(),
516+
RuleCondition::All(
517+
[
518+
vec![module_css_condition.clone()],
519+
// see comment on module_css_external_transform_conditions
520+
module_css_external_transform_conditions.clone(),
521+
]
522+
.concat(),
523+
),
514524
]),
515525
vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![
516526
ResolvedVc::upcast(
@@ -693,7 +703,14 @@ impl ModuleOptions {
693703
RuleCondition::ResourceBasePathGlob(Glob::new(key.clone()).await?)
694704
},
695705
RuleCondition::not(RuleCondition::ResourceIsVirtualSource),
696-
module_css_external_transform_condition.clone(),
706+
// see comment on module_css_external_transform_conditions
707+
RuleCondition::Any(
708+
[
709+
vec![RuleCondition::not(module_css_condition.clone())],
710+
module_css_external_transform_conditions.clone(),
711+
]
712+
.concat(),
713+
),
697714
]),
698715
vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![
699716
ResolvedVc::upcast(

0 commit comments

Comments
 (0)