Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Dec 2, 2022
1 parent 97c0c74 commit 3ab8163
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 3 additions & 6 deletions crates/next-core/src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::HashSet;

use anyhow::Result;
use indexmap::IndexSet;
use mime::APPLICATION_JSON;
Expand All @@ -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,
};

Expand Down Expand Up @@ -48,15 +45,15 @@ 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;
}

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;
}
Expand Down
12 changes: 10 additions & 2 deletions crates/turbopack-node/src/node_api_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringVc> {
Ok(self.await?.pathname)
}
}

impl NodeApiContentSource {
/// Checks if a path matches the regular expression
async fn is_matching_path(&self, path: &str) -> Result<bool> {
Expand Down
12 changes: 10 additions & 2 deletions crates/turbopack-node/src/node_rendered_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringVc> {
Ok(self.await?.pathname)
}
}

impl NodeRenderContentSource {
/// Checks if a path matches the regular expression
async fn is_matching_path(&self, path: &str) -> Result<bool> {
Expand Down

0 comments on commit 3ab8163

Please sign in to comment.