Skip to content
Draft
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
12 changes: 6 additions & 6 deletions crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ impl MiddlewareEndpoint {
parse_segment_config_from_source(*self.await?.source, ParseSegmentMode::Base).await?;
let runtime = config.runtime.unwrap_or(NextRuntime::Edge);

let next_config = this.project.next_config();
let i18n = next_config.i18n().await?;
let has_i18n = i18n.is_some();
let has_i18n_locales = i18n
let next_config = this.project.next_config().await?;
let has_i18n = next_config.i18n.is_some();
let has_i18n_locales = next_config
.i18n
.as_ref()
.map(|i18n| i18n.locales.len() > 1)
.unwrap_or(false);
let base_path = next_config.base_path().await?;
let base_path = next_config.base_path.as_ref();

let matchers = if let Some(matchers) = config.middleware_matcher.as_ref() {
matchers
Expand Down Expand Up @@ -202,7 +202,7 @@ impl MiddlewareEndpoint {

source.insert_str(0, "/:nextData(_next/data/[^/]{1,})?");

if let Some(base_path) = base_path.as_ref() {
if let Some(base_path) = base_path {
source.insert_str(0, base_path);
}

Expand Down
8 changes: 2 additions & 6 deletions crates/next-api/src/nft_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,7 @@ pub async fn all_assets_from_entries_filtered(
Ok((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate the list of assets when
// the span name changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down Expand Up @@ -500,9 +498,7 @@ async fn get_referenced_server_assets(
Ok(Some((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate the list of assets when the span
// name changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down
42 changes: 13 additions & 29 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
/// E.g. `/home/user/projects/my-repo`.
pub root_path: RcStr,

/// A path which contains the app/pages directories, relative to [`Project::root_path`], always

Check warning on line 156 in crates/next-api/src/project.rs

View workflow job for this annotation

GitHub Actions / rustdoc check / build

public documentation for `project_path` links to private item `Project::root_path`
/// Unix path. E.g. `apps/my-app`
pub project_path: RcStr,

Expand Down Expand Up @@ -479,8 +479,8 @@
}

let dist_dir = next_config
.dist_dir()
.await?
.dist_dir
.as_ref()
.map_or_else(|| rcstr!(".next"), |d| d.clone());

Expand Down Expand Up @@ -722,17 +722,13 @@

#[turbo_tasks::function]
pub async fn client_relative_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let next_config = self.next_config();
let next_config = self.next_config().await?;
Ok(self
.client_root()
.await?
.join(&format!(
"{}/_next",
next_config
.base_path()
.await?
.as_deref()
.unwrap_or_default(),
next_config.base_path.clone().unwrap_or_default(),
))?
.cell())
}
Expand Down Expand Up @@ -1160,38 +1156,26 @@
*config.persistent_caching_enabled().await?,
);

emit_event(
"modularizeImports",
!config.modularize_imports().await?.is_empty(),
);
emit_event(
"transpilePackages",
!config.transpile_packages().await?.is_empty(),
);
let config = &config.await?;

emit_event("modularizeImports", config.modularize_imports.is_some());
emit_event("transpilePackages", config.transpile_packages.is_some());
emit_event("turbotrace", false);

// compiler options
let compiler_options = config.compiler().await?;
let swc_relay_enabled = compiler_options.relay.is_some();
let compiler_options = config.compiler.as_ref();
let swc_relay_enabled = compiler_options.and_then(|c| c.relay.as_ref()).is_some();
let styled_components_enabled = compiler_options
.styled_components
.as_ref()
.map(|sc| sc.is_enabled())
.and_then(|c| c.styled_components.as_ref().map(|sc| sc.is_enabled()))
.unwrap_or_default();
let react_remove_properties_enabled = compiler_options
.react_remove_properties
.as_ref()
.map(|rc| rc.is_enabled())
.and_then(|c| c.react_remove_properties.as_ref().map(|rc| rc.is_enabled()))
.unwrap_or_default();
let remove_console_enabled = compiler_options
.remove_console
.as_ref()
.map(|rc| rc.is_enabled())
.and_then(|c| c.remove_console.as_ref().map(|rc| rc.is_enabled()))
.unwrap_or_default();
let emotion_enabled = compiler_options
.emotion
.as_ref()
.map(|e| e.is_enabled())
.and_then(|c| c.emotion.as_ref().map(|e| e.is_enabled()))
.unwrap_or_default();

emit_event("swcRelay", swc_relay_enabled);
Expand Down
10 changes: 3 additions & 7 deletions crates/next-core/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use tracing::{Instrument, Level, Span};
use turbo_rcstr::RcStr;
use turbo_tasks::{
FxIndexSet, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc,
FxIndexSet, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc,
graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow},
};
use turbo_tasks_fs::{FileSystemPath, rebase};
Expand Down Expand Up @@ -161,9 +161,7 @@ pub async fn all_assets_from_entries(entries: Vc<OutputAssets>) -> Result<Vc<Out
Ok((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name
// changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down Expand Up @@ -197,9 +195,7 @@ async fn get_referenced_assets(
Ok((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate the list of assets when the span
// name changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/next_app/app_page_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub async fn get_app_page_entry(
let server_component_transition =
ResolvedVc::upcast(NextServerComponentTransition::new().to_resolved().await?);

let base_path = next_config.base_path().owned().await?;
let base_path = next_config.await?.base_path.clone();
let loader_tree = AppPageLoaderTreeModule::build(
loader_tree,
module_asset_context,
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/next_app/app_route_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub async fn get_app_route_entry(
let inner = rcstr!("INNER_APP_ROUTE");

let output_type: &str = next_config
.output()
.await?
.output
.as_ref()
.map(|o| match o {
OutputType::Standalone => "\"standalone\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::future::Future;
use anyhow::Result;
use rustc_hash::FxHashSet;
use serde::{Deserialize, Serialize};
use tracing::{Instrument, Level, Span};
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{
FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TryJoinIterExt, Vc,
FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
debug::ValueDebugFormat,
graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow},
trace::TraceRawVcs,
Expand Down Expand Up @@ -121,23 +121,14 @@ pub async fn find_server_entries(
include_traced: bool,
) -> Result<Vc<ServerEntries>> {
async move {
let emit_spans = tracing::enabled!(Level::INFO);
let graph = AdjacencyMap::new()
.skip_duplicates()
.visit(
vec![FindServerEntriesNode::Internal(
entry,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(entry.ident_string().untracked().await?)
} else {
None
},
entry.ident().to_string().await?,
)],
FindServerEntries {
include_traced,
emit_spans,
},
FindServerEntries { include_traced },
)
.await
.completed()?
Expand Down Expand Up @@ -170,7 +161,6 @@ pub async fn find_server_entries(
struct FindServerEntries {
/// Whether to walk ChunkingType::Traced references
include_traced: bool,
emit_spans: bool,
}

#[derive(
Expand All @@ -187,12 +177,9 @@ struct FindServerEntries {
)]
enum FindServerEntriesNode {
ClientReference,
ServerComponentEntry(
ResolvedVc<NextServerComponentModule>,
Option<ReadRef<RcStr>>,
),
ServerUtilEntry(ResolvedVc<NextServerUtilityModule>, Option<ReadRef<RcStr>>),
Internal(ResolvedVc<Box<dyn Module>>, Option<ReadRef<RcStr>>),
ServerComponentEntry(ResolvedVc<NextServerComponentModule>, ReadRef<RcStr>),
ServerUtilEntry(ResolvedVc<NextServerUtilityModule>, ReadRef<RcStr>),
Internal(ResolvedVc<Box<dyn Module>>, ReadRef<RcStr>),
}

impl Visit<FindServerEntriesNode> for FindServerEntries {
Expand Down Expand Up @@ -221,7 +208,6 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
FindServerEntriesNode::ServerUtilEntry(module, _) => Vc::upcast(**module),
FindServerEntriesNode::ServerComponentEntry(module, _) => Vc::upcast(**module),
};
let emit_spans = self.emit_spans;
async move {
// Pass include_traced to reuse the same cached `primary_chunkable_referenced_modules`
// task result, but the traced references will be filtered out again afterwards.
Expand Down Expand Up @@ -249,13 +235,7 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
{
return Ok(FindServerEntriesNode::ServerComponentEntry(
server_component_asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name
// changes
Some(server_component_asset.ident_string().untracked().await?)
} else {
None
},
server_component_asset.ident().to_string().await?,
));
}

Expand All @@ -264,24 +244,13 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
{
return Ok(FindServerEntriesNode::ServerUtilEntry(
server_util_module,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name
// changes
Some(module.ident_string().untracked().await?)
} else {
None
},
module.ident().to_string().await?,
));
}

Ok(FindServerEntriesNode::Internal(
*module,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(module.ident_string().untracked().await?)
} else {
None
},
module.ident().to_string().await?,
))
});

Expand All @@ -292,21 +261,18 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
}

fn span(&mut self, node: &FindServerEntriesNode) -> tracing::Span {
if !self.emit_spans {
return Span::current();
}
match node {
FindServerEntriesNode::ClientReference => {
tracing::info_span!("client reference")
}
FindServerEntriesNode::Internal(_, name) => {
tracing::info_span!("module", name = display(name.as_ref().unwrap()))
tracing::info_span!("module", name = display(name))
}
FindServerEntriesNode::ServerUtilEntry(_, name) => {
tracing::info_span!("server util", name = display(name.as_ref().unwrap()))
tracing::info_span!("server util", name = display(name))
}
FindServerEntriesNode::ServerComponentEntry(_, name) => {
tracing::info_span!("layout segment", name = display(name.as_ref().unwrap()))
tracing::info_span!("layout segment", name = display(name))
}
}
}
Expand Down
Loading
Loading