Skip to content

Commit

Permalink
Merge branch 'canary' into patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
miki-tebe authored Dec 20, 2024
2 parents 9454e62 + 2e46a18 commit 3345380
Show file tree
Hide file tree
Showing 558 changed files with 75,603 additions and 71,472 deletions.
3 changes: 3 additions & 0 deletions .config/ast-grep/rules/resolved-vc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ rule:
kind: attribute
regex: '^turbo_tasks::value(\(.*\))?$'
fix: ResolvedVc<$A>

ignores:
- turbopack/crates/turbo-tasks-macros-tests/**/*.rs
30 changes: 0 additions & 30 deletions .config/ast-grep/rules/to-resolved-in-loop.yml

This file was deleted.

66 changes: 46 additions & 20 deletions crates/napi/src/next_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ use turbo_tasks::{
get_effects, Completion, Effects, ReadRef, ResolvedVc, TransientInstance, UpdateInfo, Vc,
};
use turbo_tasks_fs::{
util::uri_from_file, DiskFileSystem, FileContent, FileSystem, FileSystemPath,
get_relative_path_to, util::uri_from_file, DiskFileSystem, FileContent, FileSystem,
FileSystemPath,
};
use turbopack_core::{
diagnostics::PlainDiagnostic,
Expand Down Expand Up @@ -1015,6 +1016,7 @@ pub fn project_update_info_subscribe(
pub struct StackFrame {
pub is_server: bool,
pub is_internal: Option<bool>,
pub original_file: Option<String>,
pub file: String,
// 1-indexed, unlike source map tokens
pub line: Option<u32>,
Expand Down Expand Up @@ -1084,6 +1086,7 @@ pub async fn get_source_map(
pub async fn project_trace_source(
#[napi(ts_arg_type = "{ __napiType: \"Project\" }")] project: External<ProjectInstance>,
frame: StackFrame,
current_directory_file_url: String,
) -> napi::Result<Option<StackFrame>> {
let turbo_tasks = project.turbo_tasks.clone();
let container = project.container;
Expand Down Expand Up @@ -1120,27 +1123,50 @@ pub async fn project_trace_source(
}
};

let project_path_uri =
uri_from_file(project.container.project().project_path(), None).await? + "/";
let (source_file, is_internal) =
if let Some(source_file) = original_file.strip_prefix(&project_path_uri) {
// Client code uses file://
(source_file, false)
} else if let Some(source_file) =
original_file.strip_prefix(&*SOURCE_MAP_PREFIX_PROJECT)
{
// Server code uses turbopack://[project]
// TODO should this also be file://?
(source_file, false)
} else if let Some(source_file) = original_file.strip_prefix(SOURCE_MAP_PREFIX) {
// All other code like turbopack://[turbopack] is internal code
(source_file, true)
} else {
bail!("Original file ({}) outside project", original_file)
};
let project_root_uri =
uri_from_file(project.container.project().project_root_path(), None).await? + "/";
let (file, original_file, is_internal) = if let Some(source_file) =
original_file.strip_prefix(&project_root_uri)
{
// Client code uses file://
(
get_relative_path_to(&current_directory_file_url, &original_file)
// TODO(sokra) remove this to include a ./ here to make it a relative path
.trim_start_matches("./")
.to_string(),
Some(source_file.to_string()),
false,
)
} else if let Some(source_file) =
original_file.strip_prefix(&*SOURCE_MAP_PREFIX_PROJECT)
{
// Server code uses turbopack://[project]
// TODO should this also be file://?
(
get_relative_path_to(
&current_directory_file_url,
&format!("{}{}", project_root_uri, source_file),
)
// TODO(sokra) remove this to include a ./ here to make it a relative path
.trim_start_matches("./")
.to_string(),
Some(source_file.to_string()),
false,
)
} else if let Some(source_file) = original_file.strip_prefix(SOURCE_MAP_PREFIX) {
// All other code like turbopack://[turbopack] is internal code
(source_file.to_string(), None, true)
} else {
bail!(
"Original file ({}) outside project ({})",
original_file,
project_root_uri
)
};

Ok(Some(StackFrame {
file: source_file.to_string(),
file,
original_file,
method_name: name.as_ref().map(ToString::to_string),
line,
column,
Expand Down
Loading

0 comments on commit 3345380

Please sign in to comment.