diff --git a/Cargo.lock b/Cargo.lock index 86d47e961352a..57cc734850ca0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2913,6 +2913,7 @@ version = "0.1.0" dependencies = [ "anyhow", "indexmap", + "mime", "rand", "serde", "serde_json", diff --git a/crates/next-core/Cargo.toml b/crates/next-core/Cargo.toml index 465b09129030a..327af9d4b2340 100644 --- a/crates/next-core/Cargo.toml +++ b/crates/next-core/Cargo.toml @@ -11,6 +11,7 @@ bench = false [dependencies] anyhow = "1.0.47" indexmap = { workspace = true, features = ["serde"] } +mime = "0.3.16" rand = "0.8.5" serde = "1.0.136" serde_json = "1.0.85" diff --git a/crates/next-core/src/manifest.rs b/crates/next-core/src/manifest.rs index 83b248c60317e..93439e63d13b1 100644 --- a/crates/next-core/src/manifest.rs +++ b/crates/next-core/src/manifest.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use anyhow::Result; use indexmap::IndexSet; use mime::APPLICATION_JSON; @@ -10,8 +8,7 @@ use turbopack_dev_server::source::{ combined::CombinedContentSourceVc, conditional::ConditionalContentSourceVc, ContentSource, ContentSourceContent, ContentSourceData, ContentSourceResultVc, ContentSourceVc, }; - -use crate::nodejs::{ +use turbopack_node::{ node_api_source::NodeApiContentSourceVc, node_rendered_source::NodeRenderContentSourceVc, }; @@ -48,7 +45,7 @@ impl DevManifestContentSourceVc { } if let Some(api_source) = NodeApiContentSourceVc::resolve_from(content_source).await? { - routes.insert(format!("/{}", api_source.await?.pathname.await?)); + routes.insert(format!("/{}", api_source.get_pathname().await?)); continue; } @@ -56,7 +53,7 @@ impl DevManifestContentSourceVc { if let Some(page_source) = NodeRenderContentSourceVc::resolve_from(content_source).await? { - routes.insert(format!("/{}", page_source.await?.pathname.await?)); + routes.insert(format!("/{}", page_source.get_pathname().await?)); continue; } diff --git a/crates/turbopack-node/src/node_api_source.rs b/crates/turbopack-node/src/node_api_source.rs index 03e1615c248c8..1c6140b731b43 100644 --- a/crates/turbopack-node/src/node_api_source.rs +++ b/crates/turbopack-node/src/node_api_source.rs @@ -46,15 +46,23 @@ pub fn create_node_api_source( /// for Node.js execution during rendering. The `chunking_context` should emit /// to this directory. #[turbo_tasks::value] -pub(crate) struct NodeApiContentSource { +pub struct NodeApiContentSource { specificity: SpecificityVc, server_root: FileSystemPathVc, - pub(crate) pathname: StringVc, + pathname: StringVc, path_regex: PathRegexVc, entry: NodeEntryVc, runtime_entries: EcmascriptChunkPlaceablesVc, } +#[turbo_tasks::value_impl] +impl NodeApiContentSourceVc { + #[turbo_tasks::function] + pub async fn get_pathname(self) -> Result { + Ok(self.await?.pathname) + } +} + impl NodeApiContentSource { /// Checks if a path matches the regular expression async fn is_matching_path(&self, path: &str) -> Result { diff --git a/crates/turbopack-node/src/node_rendered_source.rs b/crates/turbopack-node/src/node_rendered_source.rs index 2c8aed3f166e3..3461c0ef1d65c 100644 --- a/crates/turbopack-node/src/node_rendered_source.rs +++ b/crates/turbopack-node/src/node_rendered_source.rs @@ -67,16 +67,24 @@ pub fn create_node_rendered_source( /// see [create_node_rendered_source] #[turbo_tasks::value] -pub(crate) struct NodeRenderContentSource { +pub struct NodeRenderContentSource { specificity: SpecificityVc, server_root: FileSystemPathVc, - pub(crate) pathname: StringVc, + pathname: StringVc, path_regex: PathRegexVc, entry: NodeEntryVc, runtime_entries: EcmascriptChunkPlaceablesVc, fallback_page: DevHtmlAssetVc, } +#[turbo_tasks::value_impl] +impl NodeRenderContentSourceVc { + #[turbo_tasks::function] + pub async fn get_pathname(self) -> Result { + Ok(self.await?.pathname) + } +} + impl NodeRenderContentSource { /// Checks if a path matches the regular expression async fn is_matching_path(&self, path: &str) -> Result {