Skip to content

Commit

Permalink
Remove field from ExternalTraced::Traced
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Nov 18, 2024
1 parent d553f76 commit e8eac67
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
3 changes: 1 addition & 2 deletions crates/next-core/src/next_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ pub async fn get_postcss_package_mapping(

#[turbo_tasks::function]
pub async fn get_external_next_compiled_package_mapping(
project_path: ResolvedVc<FileSystemPath>,
package_name: Vc<RcStr>,
) -> Result<Vc<ImportMapping>> {
Ok(ImportMapping::Alternatives(vec![ImportMapping::External(
Some(format!("next/dist/compiled/{}", &*package_name.await?).into()),
ExternalType::CommonJs,
ExternalTraced::Traced(project_path),
ExternalTraced::Traced,
None,
)
.resolved_cell()])
Expand Down
22 changes: 8 additions & 14 deletions crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ pub async fn get_next_client_import_map(

/// Computes the Next-specific client import map.
#[turbo_tasks::function]
pub async fn get_next_build_import_map(
project_path: ResolvedVc<FileSystemPath>,
) -> Result<Vc<ImportMap>> {
pub async fn get_next_build_import_map() -> Result<Vc<ImportMap>> {
let mut import_map = ImportMap::empty();

insert_package_alias(
Expand All @@ -251,13 +249,9 @@ pub async fn get_next_build_import_map(
next_js_fs().root().to_resolved().await?,
);

let external = ImportMapping::External(
None,
ExternalType::CommonJs,
ExternalTraced::Traced(project_path),
None,
)
.resolved_cell();
let external =
ImportMapping::External(None, ExternalType::CommonJs, ExternalTraced::Traced, None)
.resolved_cell();

import_map.insert_exact_alias("next", external);
import_map.insert_wildcard_alias("next/", external);
Expand All @@ -267,7 +261,7 @@ pub async fn get_next_build_import_map(
ImportMapping::External(
Some("styled-jsx/style.js".into()),
ExternalType::CommonJs,
ExternalTraced::Traced(project_path),
ExternalTraced::Traced,
None,
)
.resolved_cell(),
Expand Down Expand Up @@ -360,7 +354,7 @@ pub async fn get_next_server_import_map(
ImportMapping::External(
Some("styled-jsx/style.js".into()),
ExternalType::CommonJs,
ExternalTraced::Traced(project_path),
ExternalTraced::Traced,
None,
)
.resolved_cell(),
Expand Down Expand Up @@ -1152,7 +1146,7 @@ fn external_request_to_cjs_import_mapping(
ImportMapping::External(
Some(request.into()),
ExternalType::CommonJs,
ExternalTraced::Traced(context_dir),
ExternalTraced::Traced,
Some(context_dir),
)
.resolved_cell()
Expand All @@ -1167,7 +1161,7 @@ fn external_request_to_esm_import_mapping(
ImportMapping::External(
Some(request.into()),
ExternalType::EcmaScriptModule,
ExternalTraced::Traced(context_dir),
ExternalTraced::Traced,
Some(context_dir),
)
.resolved_cell()
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/next_shared/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl AfterResolvePlugin for NextExternalResolvePlugin {
ResolveResult::primary(ResolveResultItem::External {
name: specifier.clone(),
ty: ExternalType::CommonJs,
traced: ExternalTraced::Traced(self.project_path),
traced: ExternalTraced::Traced,
})
.into(),
)))
Expand Down
18 changes: 8 additions & 10 deletions turbopack/crates/turbopack-core/src/resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,15 @@ impl ModuleResolveResult {
#[turbo_tasks::value(shared)]
pub enum ExternalTraced {
Untraced,
Traced(ResolvedVc<FileSystemPath>),
Traced,
}

impl ExternalTraced {
async fn as_string(&self) -> Result<String> {
Ok(match self {
ExternalTraced::Untraced => "untraced".to_string(),
ExternalTraced::Traced(context) => {
format!("traced from {}", context.to_string().await?)
}
})
impl Display for ExternalTraced {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ExternalTraced::Untraced => write!(f, "untraced"),
ExternalTraced::Traced => write!(f, "traced"),
}
}
}

Expand Down Expand Up @@ -502,7 +500,7 @@ impl ValueToString for ResolveResult {
} => {
result.push_str("external ");
result.push_str(s);
write!(result, " ({}, {})", ty, traced.as_string().await?)?;
write!(result, " ({}, {})", ty, traced)?;
}
ResolveResultItem::Ignore => {
result.push_str("ignore");
Expand Down

0 comments on commit e8eac67

Please sign in to comment.