Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
55 changes: 38 additions & 17 deletions turbopack/crates/turbopack-core/src/resolve/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ pub enum ImportMapping {
#[turbo_tasks::value(shared)]
#[derive(Clone)]
pub enum ReplacedImportMapping {
External(Option<RcStr>, ExternalType, ExternalTraced),
External {
name_override: Option<RcStr>,
ty: ExternalType,
traced: ExternalTraced,
},
PrimaryAlternativeExternal {
name: Option<RcStr>,
ty: ExternalType,
Expand Down Expand Up @@ -190,9 +194,11 @@ impl AliasTemplate for Vc<ImportMapping> {
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,
Expand Down Expand Up @@ -233,13 +239,20 @@ impl AliasTemplate for Vc<ImportMapping> {
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 {
Expand Down Expand Up @@ -393,7 +406,11 @@ pub struct ResolvedMap {
#[derive(Clone)]
pub enum ImportMapResult {
Result(ResolvedVc<ResolveResult>),
External(RcStr, ExternalType, ExternalTraced),
External {
name: RcStr,
ty: ExternalType,
traced: ExternalTraced,
},
AliasExternal {
name: RcStr,
ty: ExternalType,
Expand All @@ -412,8 +429,12 @@ async fn import_mapping_to_result(
) -> Result<ImportMapResult> {
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
Expand All @@ -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,
Expand Down Expand Up @@ -480,7 +501,7 @@ impl ValueToString for ImportMapResult {
async fn to_string(&self) -> Result<Vc<RcStr>> {
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 {
Expand Down
Loading