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
5c9525be
Commit
5c9525be
authored
Aug 01, 2025
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tracing
parent
6d318d61
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
444 additions
and
267 deletions
+444
-267
graph.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
+80
-0
linker.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/linker.rs
+15
-8
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+349
-259
No files found.
turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
View file @
5c9525be
...
...
@@ -245,6 +245,86 @@ impl Effect {
Effect
::
Unreachable
{
..
}
=>
{}
}
}
/// Returns all JsValues referened by this effect. (Intended for debugging purposes.)
pub
fn
values
(
&
self
)
->
Vec
<&
JsValue
>
{
match
self
{
Effect
::
Call
{
func
,
args
,
..
}
=>
{
let
mut
result
=
vec!
[
&**
func
];
result
.extend
(
args
.iter
()
.flat_map
(|
arg
|
{
match
arg
{
EffectArg
::
Value
(
val
)
=>
vec!
[
val
],
EffectArg
::
Closure
(
func
,
block
)
=>
std
::
iter
::
once
(
func
)
.chain
(
block
.effects
.iter
()
.flat_map
(|
e
|
e
.values
()))
.collect
(),
EffectArg
::
Spread
=>
vec!
[],
}
}));
result
}
Effect
::
MemberCall
{
obj
,
prop
,
args
,
..
}
=>
{
let
mut
result
=
vec!
[
&**
obj
,
&**
prop
];
result
.extend
(
args
.iter
()
.flat_map
(|
arg
|
{
match
arg
{
EffectArg
::
Value
(
val
)
=>
vec!
[
val
],
EffectArg
::
Closure
(
func
,
block
)
=>
std
::
iter
::
once
(
func
)
.chain
(
block
.effects
.iter
()
.flat_map
(|
e
|
e
.values
()))
.collect
(),
EffectArg
::
Spread
=>
vec!
[],
}
}));
result
}
Effect
::
Conditional
{
condition
,
kind
,
..
}
=>
{
let
mut
result
=
vec!
[
&**
condition
];
match
&**
kind
{
ConditionalKind
::
If
{
then
:
block
}
|
ConditionalKind
::
Else
{
r
#
else
:
block
}
|
ConditionalKind
::
And
{
expr
:
block
,
..
}
|
ConditionalKind
::
Or
{
expr
:
block
,
..
}
|
ConditionalKind
::
NullishCoalescing
{
expr
:
block
,
..
}
|
ConditionalKind
::
Labeled
{
body
:
block
}
=>
{
result
.extend
(
block
.effects
.iter
()
.flat_map
(|
e
|
e
.values
()));
}
ConditionalKind
::
IfElse
{
then
,
r
#
else
,
..
}
|
ConditionalKind
::
Ternary
{
then
,
r
#
else
,
..
}
=>
{
result
.extend
(
then
.effects
.iter
()
.chain
(
r
#
else
.effects
.iter
())
.flat_map
(|
e
|
e
.values
()),
);
}
ConditionalKind
::
IfElseMultiple
{
then
,
r
#
else
,
..
}
=>
{
result
.extend
(
then
.iter
()
.flat_map
(|
b
|
b
.effects
.iter
()
.flat_map
(|
e
|
e
.values
()))
.chain
(
r
#
else
.iter
()
.flat_map
(|
b
|
b
.effects
.iter
()
.flat_map
(|
e
|
e
.values
())),
),
);
}
};
result
}
Effect
::
Member
{
obj
,
prop
,
..
}
=>
{
vec!
[
obj
,
prop
]
}
Effect
::
TypeOf
{
arg
,
..
}
=>
{
vec!
[
arg
]
}
Effect
::
FreeVar
{
..
}
|
Effect
::
ImportedBinding
{
..
}
|
Effect
::
ImportMeta
{
..
}
|
Effect
::
Unreachable
{
..
}
=>
vec!
[],
}
}
}
pub
enum
AssignmentScope
{
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/linker.rs
View file @
5c9525be
...
...
@@ -22,16 +22,23 @@ where
RF
:
'a
+
Future
<
Output
=
Result
<
(
JsValue
,
bool
)
>>
+
Send
,
F
:
'a
+
Fn
(
JsValue
)
->
RF
+
Sync
,
{
// use tracing::Instrument;
// let span = tracing::trace_span!("link", steps = tracing::field::Empty);
val
.normalize
();
let
(
val
,
steps
)
=
link_internal_iterative
(
graph
,
val
,
early_visitor
,
visitor
,
fun_args_values
,
var_cache
,
)
let
(
val
,
steps
)
=
async
{
link_internal_iterative
(
graph
,
val
,
early_visitor
,
visitor
,
fun_args_values
,
var_cache
,
)
.await
}
// .instrument(span.clone())
.await
?
;
// span.record("steps", steps);
Ok
((
val
,
steps
))
}
...
...
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
5c9525be
This diff is collapsed.
Click to expand it.
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