Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
5cee7222
Unverified
Commit
5cee7222
authored
Oct 13, 2025
by
Joseph
Committed by
GitHub
Oct 13, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'canary' into fix/handle-null-origin
parents
cf0de7bd
90bc934b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
218 additions
and
178 deletions
+218
-178
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+21
-15
node.rs
turbopack/crates/turbopack-ecmascript/src/references/node.rs
+4
-133
raw.rs
turbopack/crates/turbopack-ecmascript/src/references/raw.rs
+193
-30
No files found.
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
5cee7222
...
@@ -104,8 +104,7 @@ use self::{
...
@@ -104,8 +104,7 @@ use self::{
EsmAssetReference
,
EsmAsyncAssetReference
,
EsmExports
,
EsmModuleItem
,
ImportMetaBinding
,
EsmAssetReference
,
EsmAsyncAssetReference
,
EsmExports
,
EsmModuleItem
,
ImportMetaBinding
,
ImportMetaRef
,
UrlAssetReference
,
export
::
EsmExport
,
ImportMetaRef
,
UrlAssetReference
,
export
::
EsmExport
,
},
},
node
::
DirAssetReference
,
raw
::{
DirAssetReference
,
FileSourceReference
},
raw
::
FileSourceReference
,
typescript
::{
TsConfigReference
,
TsReferencePathAssetReference
,
TsReferenceTypeAssetReference
},
typescript
::{
TsConfigReference
,
TsReferencePathAssetReference
,
TsReferenceTypeAssetReference
},
};
};
use
super
::{
use
super
::{
...
@@ -1652,6 +1651,8 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -1652,6 +1651,8 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
.await
.await
};
};
let
make_issue_source
=
||
IssueSource
::
from_swc_offsets
(
source
,
span
.lo
.to_u32
(),
span
.hi
.to_u32
());
if
new
{
if
new
{
match
func
{
match
func
{
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
URLConstructor
)
=>
{
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
URLConstructor
)
=>
{
...
@@ -1987,11 +1988,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -1987,11 +1988,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
context_dir
,
context_dir
,
Pattern
::
new
(
pat
),
Pattern
::
new
(
pat
),
collect_affecting_sources
,
collect_affecting_sources
,
IssueSource
::
from_swc_offsets
(
make_issue_source
(),
source
,
span
.lo
.to_u32
(),
span
.hi
.to_u32
(),
),
)
)
.to_resolved
()
.to_resolved
()
.await
?
,
.await
?
,
...
@@ -2043,7 +2040,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -2043,7 +2040,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
}
}
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
analysis
.add_reference
(
analysis
.add_reference
(
DirAssetReference
::
new
(
context_dir
,
Pattern
::
new
(
pat
))
DirAssetReference
::
new
(
context_dir
,
Pattern
::
new
(
pat
)
,
make_issue_source
()
)
.to_resolved
()
.to_resolved
()
.await
?
,
.await
?
,
);
);
...
@@ -2085,7 +2082,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -2085,7 +2082,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
}
}
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
analysis
.add_reference
(
analysis
.add_reference
(
DirAssetReference
::
new
(
context_dir
,
Pattern
::
new
(
pat
))
DirAssetReference
::
new
(
context_dir
,
Pattern
::
new
(
pat
)
,
make_issue_source
()
)
.to_resolved
()
.to_resolved
()
.await
?
,
.await
?
,
);
);
...
@@ -2376,9 +2373,13 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -2376,9 +2373,13 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
};
};
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
analysis
.add_reference
(
analysis
.add_reference
(
DirAssetReference
::
new
(
context_dir
,
Pattern
::
new
(
abs_pattern
))
DirAssetReference
::
new
(
.to_resolved
()
context_dir
,
.await
?
,
Pattern
::
new
(
abs_pattern
),
make_issue_source
(),
)
.to_resolved
()
.await
?
,
);
);
}
}
return
Ok
(());
return
Ok
(());
...
@@ -2441,9 +2442,13 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -2441,9 +2442,13 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
};
};
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
if
let
Some
(
context_dir
)
=
get_traced_project_dir
()
.await
?
{
analysis
.add_reference
(
analysis
.add_reference
(
DirAssetReference
::
new
(
context_dir
,
Pattern
::
new
(
abs_pattern
))
DirAssetReference
::
new
(
.to_resolved
()
context_dir
,
.await
?
,
Pattern
::
new
(
abs_pattern
),
make_issue_source
(),
)
.to_resolved
()
.await
?
,
);
);
}
}
return
Ok
(());
return
Ok
(());
...
@@ -2510,6 +2515,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
...
@@ -2510,6 +2515,7 @@ async fn handle_call<G: Fn(Vec<Effect>) + Send + Sync>(
DirAssetReference
::
new
(
DirAssetReference
::
new
(
context_dir
.clone
(),
context_dir
.clone
(),
Pattern
::
new
(
Pattern
::
Constant
(
dir
.into
())),
Pattern
::
new
(
Pattern
::
Constant
(
dir
.into
())),
make_issue_source
(),
)
)
.to_resolved
()
.to_resolved
()
})
})
...
...
turbopack/crates/turbopack-ecmascript/src/references/node.rs
View file @
5cee7222
use
anyhow
::{
Result
,
bail
};
use
anyhow
::
Result
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
ChunkableModuleReference
,
ChunkingType
,
ChunkingTypeOption
},
file_source
::
FileSource
,
raw_module
::
RawModule
,
reference
::
ModuleReference
,
file_source
::
FileSource
,
resolve
::
ModuleResolveResult
,
raw_module
::
RawModule
,
reference
::
ModuleReference
,
resolve
::{
ModuleResolveResult
,
RequestKey
,
pattern
::{
Pattern
,
PatternMatch
,
read_matches
},
},
};
};
#[turbo_tasks
::
value]
#[turbo_tasks
::
value]
...
@@ -53,125 +46,3 @@ impl ValueToString for PackageJsonReference {
...
@@ -53,125 +46,3 @@ impl ValueToString for PackageJsonReference {
))
))
}
}
}
}
#[turbo_tasks
::
value]
#[derive(Hash,
Debug)]
pub
struct
DirAssetReference
{
pub
context_dir
:
FileSystemPath
,
pub
path
:
ResolvedVc
<
Pattern
>
,
}
#[turbo_tasks
::
value_impl]
impl
DirAssetReference
{
#[turbo_tasks
::
function]
pub
fn
new
(
context_dir
:
FileSystemPath
,
path
:
ResolvedVc
<
Pattern
>
)
->
Vc
<
Self
>
{
Self
::
cell
(
DirAssetReference
{
context_dir
,
path
})
}
}
async
fn
resolve_reference_from_dir
(
context_dir
:
FileSystemPath
,
path
:
Vc
<
Pattern
>
,
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
path_ref
=
path
.await
?
;
let
(
abs_path
,
rel_path
)
=
path_ref
.split_could_match
(
"/ROOT/"
);
if
abs_path
.is_none
()
&&
rel_path
.is_none
()
{
return
Ok
(
*
ModuleResolveResult
::
unresolvable
());
}
let
abs_matches
=
if
let
Some
(
abs_path
)
=
&
abs_path
{
Some
(
read_matches
(
context_dir
.root
()
.owned
()
.await
?
,
rcstr!
(
"/ROOT/"
),
true
,
Pattern
::
new
(
abs_path
.or_any_nested_file
()),
)
.await
?
,
)
}
else
{
None
};
let
rel_matches
=
if
let
Some
(
rel_path
)
=
&
rel_path
{
Some
(
read_matches
(
context_dir
,
rcstr!
(
""
),
true
,
Pattern
::
new
(
rel_path
.or_any_nested_file
()),
)
.await
?
,
)
}
else
{
None
};
let
matches
=
abs_matches
.into_iter
()
.flatten
()
.chain
(
rel_matches
.into_iter
()
.flatten
());
let
mut
affecting_sources
=
Vec
::
new
();
let
mut
results
=
Vec
::
new
();
for
pat_match
in
matches
{
match
pat_match
{
PatternMatch
::
File
(
matched_path
,
file
)
=>
{
let
realpath
=
file
.realpath_with_links
()
.await
?
;
for
symlink
in
&
realpath
.symlinks
{
affecting_sources
.push
(
ResolvedVc
::
upcast
(
FileSource
::
new
(
symlink
.clone
())
.to_resolved
()
.await
?
,
));
}
let
path
:
FileSystemPath
=
match
&
realpath
.path_result
{
Ok
(
path
)
=>
path
.clone
(),
Err
(
e
)
=>
bail!
(
e
.as_error_message
(
file
,
&
realpath
)),
};
results
.push
((
RequestKey
::
new
(
matched_path
.clone
()),
ResolvedVc
::
upcast
(
RawModule
::
new
(
Vc
::
upcast
(
FileSource
::
new
(
path
)))
.to_resolved
()
.await
?
,
),
));
}
PatternMatch
::
Directory
(
..
)
=>
{}
}
}
Ok
(
*
ModuleResolveResult
::
modules_with_affecting_sources
(
results
,
affecting_sources
,
))
}
#[turbo_tasks
::
value_impl]
impl
ModuleReference
for
DirAssetReference
{
#[turbo_tasks
::
function]
async
fn
resolve_reference
(
&
self
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
span
=
tracing
::
info_span!
(
"trace directory"
,
pattern
=
display
(
self
.path
.to_string
()
.await
?
)
);
resolve_reference_from_dir
(
self
.context_dir
.clone
(),
*
self
.path
)
.instrument
(
span
)
.await
}
}
#[turbo_tasks
::
value_impl]
impl
ChunkableModuleReference
for
DirAssetReference
{
#[turbo_tasks
::
function]
fn
chunking_type
(
&
self
)
->
Vc
<
ChunkingTypeOption
>
{
Vc
::
cell
(
Some
(
ChunkingType
::
Traced
))
}
}
#[turbo_tasks
::
value_impl]
impl
ValueToString
for
DirAssetReference
{
#[turbo_tasks
::
function]
async
fn
to_string
(
&
self
)
->
Result
<
Vc
<
RcStr
>>
{
Ok
(
Vc
::
cell
(
format!
(
"directory assets {}"
,
self
.path
.to_string
()
.await
?
,)
.into
(),
))
}
}
turbopack/crates/turbopack-ecmascript/src/references/raw.rs
View file @
5cee7222
use
anyhow
::
Result
;
use
anyhow
::
{
Result
,
bail
}
;
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbopack_core
::{
use
turbopack_core
::{
chunk
::{
ChunkableModuleReference
,
ChunkingType
,
ChunkingTypeOption
},
chunk
::{
ChunkableModuleReference
,
ChunkingType
,
ChunkingTypeOption
},
file_source
::
FileSource
,
issue
::{
issue
::{
Issue
,
IssueExt
,
IssueSeverity
,
IssueSource
,
IssueStage
,
OptionIssueSource
,
Issue
,
IssueExt
,
IssueSeverity
,
IssueSource
,
IssueStage
,
OptionIssueSource
,
OptionStyledString
,
StyledString
,
OptionStyledString
,
StyledString
,
},
},
raw_module
::
RawModule
,
reference
::
ModuleReference
,
reference
::
ModuleReference
,
resolve
::{
ModuleResolveResult
,
pattern
::
Pattern
,
resolve_raw
},
resolve
::{
ModuleResolveResult
,
RequestKey
,
pattern
::{
Pattern
,
PatternMatch
,
read_matches
},
resolve_raw
,
},
};
};
#[turbo_tasks
::
value]
#[turbo_tasks
::
value]
#[derive(Hash,
Debug)]
#[derive(Hash,
Debug)]
pub
struct
FileSourceReference
{
pub
struct
FileSourceReference
{
...
@@ -58,26 +63,202 @@ impl ModuleReference for FileSourceReference {
...
@@ -58,26 +63,202 @@ impl ModuleReference for FileSourceReference {
.as_raw_module_result
()
.as_raw_module_result
()
.resolve
()
.resolve
()
.await
?
;
.await
?
;
let
num_matches
=
result
.await
?
.primary
.len
();
check_and_emit_too_many_matches_warning
(
if
num_matches
>
TOO_MANY_MATCHES_LIMIT
{
result
,
TooManyMatchesWarning
{
self
.issue_source
,
source
:
self
.issue_source
,
self
.context_dir
.clone
(),
context_dir
:
self
.context_dir
.clone
(),
self
.path
,
num_matches
,
)
pattern
:
self
.path
,
.await
?
;
Ok
(
result
)
}
.instrument
(
span
)
.await
}
}
#[turbo_tasks
::
value_impl]
impl
ChunkableModuleReference
for
FileSourceReference
{
#[turbo_tasks
::
function]
fn
chunking_type
(
&
self
)
->
Vc
<
ChunkingTypeOption
>
{
Vc
::
cell
(
Some
(
ChunkingType
::
Traced
))
}
}
#[turbo_tasks
::
value_impl]
impl
ValueToString
for
FileSourceReference
{
#[turbo_tasks
::
function]
async
fn
to_string
(
&
self
)
->
Result
<
Vc
<
RcStr
>>
{
Ok
(
Vc
::
cell
(
format!
(
"raw asset {}"
,
self
.path
.to_string
()
.await
?
,)
.into
(),
))
}
}
#[turbo_tasks
::
value]
#[derive(Hash,
Debug)]
pub
struct
DirAssetReference
{
context_dir
:
FileSystemPath
,
path
:
ResolvedVc
<
Pattern
>
,
issue_source
:
IssueSource
,
}
#[turbo_tasks
::
value_impl]
impl
DirAssetReference
{
#[turbo_tasks
::
function]
pub
fn
new
(
context_dir
:
FileSystemPath
,
path
:
ResolvedVc
<
Pattern
>
,
issue_source
:
IssueSource
,
)
->
Vc
<
Self
>
{
Self
::
cell
(
DirAssetReference
{
context_dir
,
path
,
issue_source
,
})
}
}
async
fn
resolve_reference_from_dir
(
context_dir
:
FileSystemPath
,
path
:
Vc
<
Pattern
>
,
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
path_ref
=
path
.await
?
;
let
(
abs_path
,
rel_path
)
=
path_ref
.split_could_match
(
"/ROOT/"
);
if
abs_path
.is_none
()
&&
rel_path
.is_none
()
{
return
Ok
(
*
ModuleResolveResult
::
unresolvable
());
}
let
abs_matches
=
if
let
Some
(
abs_path
)
=
&
abs_path
{
Some
(
read_matches
(
context_dir
.root
()
.owned
()
.await
?
,
rcstr!
(
"/ROOT/"
),
true
,
Pattern
::
new
(
abs_path
.or_any_nested_file
()),
)
.await
?
,
)
}
else
{
None
};
let
rel_matches
=
if
let
Some
(
rel_path
)
=
&
rel_path
{
Some
(
read_matches
(
context_dir
,
rcstr!
(
""
),
true
,
Pattern
::
new
(
rel_path
.or_any_nested_file
()),
)
.await
?
,
)
}
else
{
None
};
let
matches
=
abs_matches
.into_iter
()
.flatten
()
.chain
(
rel_matches
.into_iter
()
.flatten
());
let
mut
affecting_sources
=
Vec
::
new
();
let
mut
results
=
Vec
::
new
();
for
pat_match
in
matches
{
match
pat_match
{
PatternMatch
::
File
(
matched_path
,
file
)
=>
{
let
realpath
=
file
.realpath_with_links
()
.await
?
;
for
symlink
in
&
realpath
.symlinks
{
affecting_sources
.push
(
ResolvedVc
::
upcast
(
FileSource
::
new
(
symlink
.clone
())
.to_resolved
()
.await
?
,
));
}
}
.resolved_cell
()
let
path
:
FileSystemPath
=
match
&
realpath
.path_result
{
.emit
();
Ok
(
path
)
=>
path
.clone
(),
Err
(
e
)
=>
bail!
(
e
.as_error_message
(
file
,
&
realpath
)),
};
results
.push
((
RequestKey
::
new
(
matched_path
.clone
()),
ResolvedVc
::
upcast
(
RawModule
::
new
(
Vc
::
upcast
(
FileSource
::
new
(
path
)))
.to_resolved
()
.await
?
,
),
));
}
}
PatternMatch
::
Directory
(
..
)
=>
{}
}
}
Ok
(
*
ModuleResolveResult
::
modules_with_affecting_sources
(
results
,
affecting_sources
,
))
}
#[turbo_tasks
::
value_impl]
impl
ModuleReference
for
DirAssetReference
{
#[turbo_tasks
::
function]
async
fn
resolve_reference
(
&
self
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
span
=
tracing
::
info_span!
(
"trace directory"
,
pattern
=
display
(
self
.path
.to_string
()
.await
?
)
);
async
{
let
result
=
resolve_reference_from_dir
(
self
.context_dir
.clone
(),
*
self
.path
)
.await
?
;
check_and_emit_too_many_matches_warning
(
result
,
self
.issue_source
,
self
.context_dir
.clone
(),
self
.path
,
)
.await
?
;
Ok
(
result
)
Ok
(
result
)
}
}
.instrument
(
span
)
.instrument
(
span
)
.await
.await
}
}
}
}
#[turbo_tasks
::
value_impl]
impl
ChunkableModuleReference
for
DirAssetReference
{
#[turbo_tasks
::
function]
fn
chunking_type
(
&
self
)
->
Vc
<
ChunkingTypeOption
>
{
Vc
::
cell
(
Some
(
ChunkingType
::
Traced
))
}
}
#[turbo_tasks
::
value_impl]
impl
ValueToString
for
DirAssetReference
{
#[turbo_tasks
::
function]
async
fn
to_string
(
&
self
)
->
Result
<
Vc
<
RcStr
>>
{
Ok
(
Vc
::
cell
(
format!
(
"directory assets {}"
,
self
.path
.to_string
()
.await
?
,)
.into
(),
))
}
}
/// If a pattern resolves to more than 10000 results, it's likely a mistake so issue a warning.
/// If a pattern resolves to more than 10000 results, it's likely a mistake so issue a warning.
const
TOO_MANY_MATCHES_LIMIT
:
usize
=
10000
;
const
TOO_MANY_MATCHES_LIMIT
:
usize
=
10000
;
async
fn
check_and_emit_too_many_matches_warning
(
result
:
Vc
<
ModuleResolveResult
>
,
issue_source
:
IssueSource
,
context_dir
:
FileSystemPath
,
pattern
:
ResolvedVc
<
Pattern
>
,
)
->
Result
<
()
>
{
let
num_matches
=
result
.await
?
.primary
.len
();
if
num_matches
>
TOO_MANY_MATCHES_LIMIT
{
TooManyMatchesWarning
{
source
:
issue_source
,
context_dir
,
num_matches
,
pattern
,
}
.resolved_cell
()
.emit
();
}
Ok
(())
}
#[turbo_tasks
::
value(shared)]
#[turbo_tasks
::
value(shared)]
struct
TooManyMatchesWarning
{
struct
TooManyMatchesWarning
{
source
:
IssueSource
,
source
:
IssueSource
,
...
@@ -131,21 +312,3 @@ impl Issue for TooManyMatchesWarning {
...
@@ -131,21 +312,3 @@ impl Issue for TooManyMatchesWarning {
Vc
::
cell
(
Some
(
self
.source
))
Vc
::
cell
(
Some
(
self
.source
))
}
}
}
}
#[turbo_tasks
::
value_impl]
impl
ChunkableModuleReference
for
FileSourceReference
{
#[turbo_tasks
::
function]
fn
chunking_type
(
&
self
)
->
Vc
<
ChunkingTypeOption
>
{
Vc
::
cell
(
Some
(
ChunkingType
::
Traced
))
}
}
#[turbo_tasks
::
value_impl]
impl
ValueToString
for
FileSourceReference
{
#[turbo_tasks
::
function]
async
fn
to_string
(
&
self
)
->
Result
<
Vc
<
RcStr
>>
{
Ok
(
Vc
::
cell
(
format!
(
"raw asset {}"
,
self
.path
.to_string
()
.await
?
,)
.into
(),
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment