diff --git a/turbopack/crates/turbopack-core/src/resolve/mod.rs b/turbopack/crates/turbopack-core/src/resolve/mod.rs index 7c5cb7388beec8..ae51146660d323 100644 --- a/turbopack/crates/turbopack-core/src/resolve/mod.rs +++ b/turbopack/crates/turbopack-core/src/resolve/mod.rs @@ -2721,7 +2721,7 @@ async fn resolve_import_map_result( )) } } - ImportMapResult::External(name, ty, traced) => { + ImportMapResult::External { name, ty, traced } => { Some(*ResolveResult::primary(ResolveResultItem::External { name: name.clone(), ty: *ty, diff --git a/turbopack/crates/turbopack-core/src/resolve/options.rs b/turbopack/crates/turbopack-core/src/resolve/options.rs index cfdd3a6c006bdb..212679c8952b0d 100644 --- a/turbopack/crates/turbopack-core/src/resolve/options.rs +++ b/turbopack/crates/turbopack-core/src/resolve/options.rs @@ -134,7 +134,11 @@ pub enum ImportMapping { #[turbo_tasks::value(shared)] #[derive(Clone)] pub enum ReplacedImportMapping { - External(Option, ExternalType, ExternalTraced), + External { + name_override: Option, + ty: ExternalType, + traced: ExternalTraced, + }, PrimaryAlternativeExternal { name: Option, ty: ExternalType, @@ -190,9 +194,11 @@ impl AliasTemplate for Vc { Box::pin(async move { let this = &*self.await?; Ok(match this { - ImportMapping::External(name, ty, traced) => { - ReplacedImportMapping::External(name.clone(), *ty, *traced) - } + ImportMapping::External(name, ty, traced) => ReplacedImportMapping::External { + name_override: name.clone(), + ty: *ty, + traced: *traced, + }, ImportMapping::PrimaryAlternativeExternal { name, ty, @@ -233,13 +239,20 @@ impl AliasTemplate for Vc { Ok(match this { ImportMapping::External(name, ty, traced) => { if let Some(name) = name { - ReplacedImportMapping::External( - capture.spread_into_star(name).as_constant_string().cloned(), - *ty, - *traced, - ) + ReplacedImportMapping::External { + name_override: capture + .spread_into_star(name) + .as_constant_string() + .cloned(), + ty: *ty, + traced: *traced, + } } else { - ReplacedImportMapping::External(None, *ty, *traced) + ReplacedImportMapping::External { + name_override: None, + ty: *ty, + traced: *traced, + } } } ImportMapping::PrimaryAlternativeExternal { @@ -393,7 +406,11 @@ pub struct ResolvedMap { #[derive(Clone)] pub enum ImportMapResult { Result(ResolvedVc), - External(RcStr, ExternalType, ExternalTraced), + External { + name: RcStr, + ty: ExternalType, + traced: ExternalTraced, + }, AliasExternal { name: RcStr, ty: ExternalType, @@ -412,8 +429,12 @@ async fn import_mapping_to_result( ) -> Result { Ok(match &*mapping.await? { ReplacedImportMapping::Direct(result) => ImportMapResult::Result(*result), - ReplacedImportMapping::External(name, ty, traced) => ImportMapResult::External( - if let Some(name) = name { + ReplacedImportMapping::External { + name_override, + ty, + traced, + } => ImportMapResult::External { + name: if let Some(name) = name_override { name.clone() } else if let Some(request) = request.await?.request() { request @@ -423,9 +444,9 @@ async fn import_mapping_to_result( request.request_pattern().await?.describe_as_string() ) }, - *ty, - *traced, - ), + ty: *ty, + traced: *traced, + }, ReplacedImportMapping::PrimaryAlternativeExternal { name, ty, @@ -480,7 +501,7 @@ impl ValueToString for ImportMapResult { async fn to_string(&self) -> Result> { match self { ImportMapResult::Result(_) => Ok(Vc::cell(rcstr!("Resolved by import map"))), - ImportMapResult::External(_, _, _) => Ok(Vc::cell(rcstr!("TODO external"))), + ImportMapResult::External { .. } => Ok(Vc::cell(rcstr!("TODO external"))), ImportMapResult::AliasExternal { .. } => Ok(Vc::cell(rcstr!("TODO external"))), ImportMapResult::Alias(request, context) => { let s = if let Some(path) = context {