diff --git a/turbopack/crates/turbopack-core/src/ident.rs b/turbopack/crates/turbopack-core/src/ident.rs index 0a5e98adcb05e..475c1a18db35b 100644 --- a/turbopack/crates/turbopack-core/src/ident.rs +++ b/turbopack/crates/turbopack-core/src/ident.rs @@ -20,8 +20,8 @@ pub struct AssetIdent { pub assets: Vec<(ResolvedVc, ResolvedVc)>, /// The modifiers of this asset (e.g. `client chunks`) pub modifiers: Vec>, - /// The part of the asset that is a (ECMAScript) module - pub part: Option>, + /// The parts of the asset that are (ECMAScript) modules + pub parts: Vec>, /// The asset layer the asset was created from. pub layer: Option>, } @@ -95,12 +95,14 @@ impl ValueToString for AssetIdent { s.push(')'); } - if let Some(part) = self.part { - let part = part.to_string().await?; - // facade is not included in ident as switching between facade and non-facade shouldn't - // change the ident - if part.as_str() != "facade" { - write!(s, " <{}>", part)?; + if !self.parts.is_empty() { + for part in self.parts.iter() { + let part = part.to_string().await?; + // facade is not included in ident as switching between facade and non-facade + // shouldn't change the ident + if part.as_str() != "facade" { + write!(s, " <{}>", part)?; + } } } @@ -124,7 +126,7 @@ impl AssetIdent { fragment: None, assets: Vec::new(), modifiers: Vec::new(), - part: None, + parts: Vec::new(), layer: None, })) } @@ -146,7 +148,7 @@ impl AssetIdent { #[turbo_tasks::function] pub fn with_part(&self, part: ResolvedVc) -> Vc { let mut this = self.clone(); - this.part = Some(part); + this.parts.push(part); Self::new(Value::new(this)) } @@ -224,7 +226,7 @@ impl AssetIdent { fragment, assets, modifiers, - part, + parts, layer, } = self; let query = query.await?; @@ -255,7 +257,7 @@ impl AssetIdent { modifier.deterministic_hash(&mut hasher); has_hash = true; } - if let Some(part) = part { + for part in parts.iter() { 4_u8.deterministic_hash(&mut hasher); match &*part.await? { ModulePart::Evaluation => { diff --git a/turbopack/crates/turbopack-css/src/chunk/mod.rs b/turbopack/crates/turbopack-css/src/chunk/mod.rs index 03fb65cc737f8..e59305d0e138b 100644 --- a/turbopack/crates/turbopack-css/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-css/src/chunk/mod.rs @@ -297,7 +297,7 @@ impl OutputAsset for CssChunk { fragment: None, assets, modifiers: Vec::new(), - part: None, + parts: Vec::new(), layer: None, }; diff --git a/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs b/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs index 095e09e28a91e..0d24f25a93569 100644 --- a/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs @@ -117,7 +117,7 @@ impl Chunk for EcmascriptChunk { fragment: None, assets, modifiers: Vec::new(), - part: None, + parts: Vec::new(), layer: None, }; diff --git a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs index 8fbfcea8b550a..30c5316ced247 100644 --- a/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs +++ b/turbopack/crates/turbopack-ecmascript/src/side_effect_optimization/facade/module.rs @@ -61,10 +61,10 @@ impl EcmascriptModuleFacadeModule { #[turbo_tasks::value_impl] impl Module for EcmascriptModuleFacadeModule { #[turbo_tasks::function] - fn ident(&self) -> Vc { + async fn ident(&self) -> Result> { let inner = self.module.ident(); - inner.with_part(self.ty) + Ok(inner.with_part(self.ty)) } #[turbo_tasks::function] diff --git a/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs b/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs index b80036dd1ee73..9a76774d86017 100644 --- a/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs +++ b/turbopack/crates/turbopack-ecmascript/src/tree_shake/mod.rs @@ -428,7 +428,7 @@ pub(super) async fn split( parsed: Vc, ) -> Result> { // Do not split already split module - if ident.await?.part.is_some() { + if !ident.await?.parts.is_empty() { return Ok(SplitResult::Failed { parse_result: parsed, }