improve and enable issue path handling (vercel/turbo#4017)
### Description adds the issue trace again, adds some basic descriptions e. g. to pages ### Testing Instructions snapshot issues [X] Auto label
This commit is contained in:
parent
e01578032f
commit
951568c4c7
22 changed files with 240 additions and 68 deletions
|
@ -1,6 +1,7 @@
|
|||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
io::Write,
|
||||
iter::once,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
@ -394,7 +395,9 @@ async fn create_app_source_for_directory(
|
|||
intermediate_output_path_root: FileSystemPathVc,
|
||||
) -> Result<ContentSourceVc> {
|
||||
let AppStructure {
|
||||
item, ref children, ..
|
||||
item,
|
||||
ref children,
|
||||
directory,
|
||||
} = *app_structure.await?;
|
||||
let mut sources = Vec::new();
|
||||
|
||||
|
@ -473,21 +476,31 @@ async fn create_app_source_for_directory(
|
|||
return Ok(NoContentSourceVc::new().into());
|
||||
}
|
||||
}
|
||||
for child in children.iter() {
|
||||
sources.push(create_app_source_for_directory(
|
||||
*child,
|
||||
context_ssr,
|
||||
context,
|
||||
project_path,
|
||||
env,
|
||||
server_root,
|
||||
runtime_entries,
|
||||
fallback_page,
|
||||
intermediate_output_path_root,
|
||||
));
|
||||
}
|
||||
|
||||
Ok(CombinedContentSource { sources }.cell().into())
|
||||
let source = CombinedContentSource { sources }
|
||||
.cell()
|
||||
.as_content_source()
|
||||
.issue_context(directory, "Next.js App Router");
|
||||
|
||||
Ok(CombinedContentSource {
|
||||
sources: once(source)
|
||||
.chain(children.iter().map(|child| {
|
||||
create_app_source_for_directory(
|
||||
*child,
|
||||
context_ssr,
|
||||
context,
|
||||
project_path,
|
||||
env,
|
||||
server_root,
|
||||
runtime_entries,
|
||||
fallback_page,
|
||||
intermediate_output_path_root,
|
||||
)
|
||||
}))
|
||||
.collect(),
|
||||
}
|
||||
.cell()
|
||||
.into())
|
||||
}
|
||||
|
||||
/// The renderer for pages in app directory
|
||||
|
|
|
@ -15,6 +15,7 @@ use turbopack_core::{
|
|||
changed::any_content_changed,
|
||||
context::AssetContext,
|
||||
ident::AssetIdentVc,
|
||||
issue::IssueContextExt,
|
||||
reference_type::{EntryReferenceSubType, ReferenceType},
|
||||
resolve::{
|
||||
find_context_file,
|
||||
|
@ -539,6 +540,22 @@ fn next_configs() -> StringsVc {
|
|||
|
||||
#[turbo_tasks::function]
|
||||
pub async fn load_next_config(execution_context: ExecutionContextVc) -> Result<NextConfigVc> {
|
||||
let ExecutionContext { project_path, .. } = *execution_context.await?;
|
||||
let find_config_result = find_context_file(project_path, next_configs());
|
||||
let config_file = match &*find_config_result.await? {
|
||||
FindContextFileResult::Found(config_path, _) => Some(*config_path),
|
||||
FindContextFileResult::NotFound(_) => None,
|
||||
};
|
||||
load_next_config_internal(execution_context, config_file)
|
||||
.issue_context(config_file, "Loading Next.js config")
|
||||
.await
|
||||
}
|
||||
|
||||
#[turbo_tasks::function]
|
||||
pub async fn load_next_config_internal(
|
||||
execution_context: ExecutionContextVc,
|
||||
config_file: Option<FileSystemPathVc>,
|
||||
) -> Result<NextConfigVc> {
|
||||
let ExecutionContext {
|
||||
project_path,
|
||||
intermediate_output_path,
|
||||
|
@ -552,11 +569,7 @@ pub async fn load_next_config(execution_context: ExecutionContextVc) -> Result<N
|
|||
import_map.insert_wildcard_alias("styled-jsx/", ImportMapping::External(None).into());
|
||||
|
||||
let context = node_evaluate_asset_context(project_path, Some(import_map.cell()), None);
|
||||
let find_config_result = find_context_file(project_path, next_configs());
|
||||
let config_asset = match &*find_config_result.await? {
|
||||
FindContextFileResult::Found(config_path, _) => Some(SourceAssetVc::new(*config_path)),
|
||||
FindContextFileResult::NotFound(_) => None,
|
||||
};
|
||||
let config_asset = config_file.map(SourceAssetVc::new);
|
||||
|
||||
let config_changed = config_asset.map_or_else(CompletionVc::immutable, |config_asset| {
|
||||
// This invalidates the execution when anything referenced by the config file
|
||||
|
|
|
@ -277,17 +277,21 @@ pub async fn create_page_source(
|
|||
let fallback_source =
|
||||
AssetGraphContentSourceVc::new_eager(server_root, fallback_page.as_asset());
|
||||
|
||||
Ok(CombinedContentSource {
|
||||
let source = CombinedContentSource {
|
||||
sources: vec![
|
||||
// Match _next/404 first to ensure rewrites work properly.
|
||||
force_not_found_source,
|
||||
force_not_found_source.issue_context(pages_dir, "Next.js pages directory not found"),
|
||||
page_source,
|
||||
fallback_source.into(),
|
||||
fallback_not_found_source,
|
||||
fallback_source
|
||||
.as_content_source()
|
||||
.issue_context(pages_dir, "Next.js pages directory fallback"),
|
||||
fallback_not_found_source
|
||||
.issue_context(pages_dir, "Next.js pages directory not found fallback"),
|
||||
],
|
||||
}
|
||||
.cell()
|
||||
.into())
|
||||
.into();
|
||||
Ok(source)
|
||||
}
|
||||
|
||||
/// Handles a single page file in the pages directory
|
||||
|
@ -555,54 +559,53 @@ async fn create_page_source_for_directory(
|
|||
let mut sources = vec![];
|
||||
|
||||
for item in items.iter() {
|
||||
match *item.await? {
|
||||
let source = match *item.await? {
|
||||
PagesStructureItem::Page {
|
||||
page,
|
||||
specificity,
|
||||
url,
|
||||
} => {
|
||||
sources.push(create_page_source_for_file(
|
||||
project_path,
|
||||
env,
|
||||
server_context,
|
||||
server_data_context,
|
||||
client_context,
|
||||
pages_dir,
|
||||
specificity,
|
||||
SourceAssetVc::new(page).into(),
|
||||
runtime_entries,
|
||||
fallback_page,
|
||||
server_root,
|
||||
url,
|
||||
false,
|
||||
output_root,
|
||||
output_root,
|
||||
));
|
||||
}
|
||||
} => create_page_source_for_file(
|
||||
project_path,
|
||||
env,
|
||||
server_context,
|
||||
server_data_context,
|
||||
client_context,
|
||||
pages_dir,
|
||||
specificity,
|
||||
SourceAssetVc::new(page).into(),
|
||||
runtime_entries,
|
||||
fallback_page,
|
||||
server_root,
|
||||
url,
|
||||
false,
|
||||
output_root,
|
||||
output_root,
|
||||
)
|
||||
.issue_context(page, "Next.js pages directory"),
|
||||
PagesStructureItem::Api {
|
||||
api,
|
||||
specificity,
|
||||
url,
|
||||
} => {
|
||||
sources.push(create_page_source_for_file(
|
||||
project_path,
|
||||
env,
|
||||
server_context,
|
||||
server_data_context,
|
||||
client_context,
|
||||
pages_dir,
|
||||
specificity,
|
||||
SourceAssetVc::new(api).into(),
|
||||
runtime_entries,
|
||||
fallback_page,
|
||||
server_root,
|
||||
url,
|
||||
true,
|
||||
output_root,
|
||||
output_root,
|
||||
));
|
||||
}
|
||||
}
|
||||
} => create_page_source_for_file(
|
||||
project_path,
|
||||
env,
|
||||
server_context,
|
||||
server_data_context,
|
||||
client_context,
|
||||
pages_dir,
|
||||
specificity,
|
||||
SourceAssetVc::new(api).into(),
|
||||
runtime_entries,
|
||||
fallback_page,
|
||||
server_root,
|
||||
url,
|
||||
true,
|
||||
output_root,
|
||||
output_root,
|
||||
)
|
||||
.issue_context(api, "Next.js pages api directory"),
|
||||
};
|
||||
sources.push(source);
|
||||
}
|
||||
|
||||
for child in children.iter() {
|
||||
|
|
|
@ -17,6 +17,7 @@ use turbopack_core::{
|
|||
context::{AssetContext, AssetContextVc},
|
||||
environment::{EnvironmentIntention::Middleware, ServerAddrVc},
|
||||
ident::AssetIdentVc,
|
||||
issue::IssueVc,
|
||||
reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType},
|
||||
resolve::{find_context_file, FindContextFileResult},
|
||||
source_asset::SourceAssetVc,
|
||||
|
@ -316,6 +317,32 @@ pub async fn route(
|
|||
next_config: NextConfigVc,
|
||||
server_addr: ServerAddrVc,
|
||||
routes_changed: CompletionVc,
|
||||
) -> Result<RouterResultVc> {
|
||||
let RouterRequest {
|
||||
ref method,
|
||||
ref pathname,
|
||||
..
|
||||
} = *request.await?;
|
||||
IssueVc::attach_description(
|
||||
format!("Next.js Routing for {} {}", method, pathname),
|
||||
route_internal(
|
||||
execution_context,
|
||||
request,
|
||||
next_config,
|
||||
server_addr,
|
||||
routes_changed,
|
||||
),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[turbo_tasks::function]
|
||||
async fn route_internal(
|
||||
execution_context: ExecutionContextVc,
|
||||
request: RouterRequestVc,
|
||||
next_config: NextConfigVc,
|
||||
server_addr: ServerAddrVc,
|
||||
routes_changed: CompletionVc,
|
||||
) -> Result<RouterResultVc> {
|
||||
let ExecutionContext {
|
||||
project_path,
|
||||
|
|
|
@ -494,8 +494,8 @@ impl IssueReporter for TestIssueReporter {
|
|||
_source: TransientValue<RawVc>,
|
||||
) -> Result<BoolVc> {
|
||||
let issue_tx = self.issue_tx.get_untracked().clone();
|
||||
for issue in captured_issues.iter() {
|
||||
let plain = issue.into_plain();
|
||||
for (issue, path) in captured_issues.iter_with_shortest_path() {
|
||||
let plain = issue.into_plain(path);
|
||||
issue_tx.send((plain.await?, plain.dbg().await?)).await?;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,4 +22,20 @@ PlainIssue {
|
|||
},
|
||||
),
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/tailwind/basic/input/pages/index.jsx",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/tailwind/basic/input/styles/globals.css",
|
||||
),
|
||||
description: "PostCSS processing",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -22,4 +22,20 @@ PlainIssue {
|
|||
},
|
||||
),
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/tailwind/basic/input/pages/index.jsx",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/tailwind/basic/input/styles/globals.css",
|
||||
),
|
||||
description: "PostCSS processing",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -22,4 +22,20 @@ PlainIssue {
|
|||
},
|
||||
),
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/tailwind/basic/input/pages/index.jsx",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/tailwind/basic/input/styles/globals.css",
|
||||
),
|
||||
description: "PostCSS processing",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,14 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/pages/index.js",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,14 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/pages/index.js",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,14 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/pages/index.js",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,14 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[
|
||||
PlainIssueProcessingPathItem {
|
||||
context: Some(
|
||||
"[project]/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/input/pages/index.js",
|
||||
),
|
||||
description: "Next.js pages directory",
|
||||
},
|
||||
],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -22,4 +22,7 @@ PlainIssue {
|
|||
},
|
||||
),
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -8,4 +8,7 @@ PlainIssue {
|
|||
documentation_link: "",
|
||||
source: None,
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -22,4 +22,7 @@ PlainIssue {
|
|||
},
|
||||
),
|
||||
sub_issues: [],
|
||||
processing_path: Some(
|
||||
[],
|
||||
),
|
||||
}
|
|
@ -10,7 +10,7 @@ use std::{
|
|||
future::{join, Future},
|
||||
io::{stdout, Write},
|
||||
net::{IpAddr, SocketAddr},
|
||||
path::MAIN_SEPARATOR,
|
||||
path::{PathBuf, MAIN_SEPARATOR},
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
@ -206,6 +206,7 @@ impl NextDevServerBuilder {
|
|||
let browserslist_query = self.browserslist_query;
|
||||
let log_options = Arc::new(LogOptions {
|
||||
current_dir: current_dir().unwrap(),
|
||||
project_dir: PathBuf::from(project_dir.clone()),
|
||||
show_all,
|
||||
log_detail,
|
||||
log_level: self.log_level,
|
||||
|
|
Loading…
Reference in a new issue