Skip to content

Commit f743efb

Browse files
committed
Turbopack: don't look into fallback import map twice
1 parent bccdb3f commit f743efb

File tree

1 file changed

+24
-20
lines changed
  • turbopack/crates/turbopack-core/src/resolve

1 file changed

+24
-20
lines changed

turbopack/crates/turbopack-core/src/resolve/mod.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,27 +2094,31 @@ async fn resolve_internal_inline(
20942094
}
20952095
};
20962096

2097-
// Apply fallback import mappings if provided
2098-
if let Some(import_map) = &options_value.fallback_import_map
2099-
&& *result.is_unresolvable().await?
2100-
{
2101-
let result = import_map
2102-
.await?
2103-
.lookup(lookup_path.clone(), request)
2104-
.await?;
2105-
let resolved_result = resolve_import_map_result(
2106-
&result,
2107-
lookup_path.clone(),
2108-
lookup_path.clone(),
2109-
request,
2110-
options,
2111-
request.query().owned().await?,
2112-
)
2113-
.await?;
2114-
if let Some(result) = resolved_result
2115-
&& !*result.is_unresolvable().await?
2097+
// The individual variants inside the alternative already looked at the fallback import
2098+
// map in the recursive `resolve_internal_inline` calls
2099+
if !matches!(*request_value, Request::Alternatives { .. }) {
2100+
// Apply fallback import mappings if provided
2101+
if let Some(import_map) = &options_value.fallback_import_map
2102+
&& *result.is_unresolvable().await?
21162103
{
2117-
return Ok(result);
2104+
let result = import_map
2105+
.await?
2106+
.lookup(lookup_path.clone(), request)
2107+
.await?;
2108+
let resolved_result = resolve_import_map_result(
2109+
&result,
2110+
lookup_path.clone(),
2111+
lookup_path.clone(),
2112+
request,
2113+
options,
2114+
request.query().owned().await?,
2115+
)
2116+
.await?;
2117+
if let Some(result) = resolved_result
2118+
&& !*result.is_unresolvable().await?
2119+
{
2120+
return Ok(result);
2121+
}
21182122
}
21192123
}
21202124

0 commit comments

Comments
 (0)