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
86fd4ea1
Commit
86fd4ea1
authored
Mar 05, 2026
by
Matt Mastracci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cargo fmt
parent
90c17993
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
201 deletions
+175
-201
builtin.rs
...opack/crates/turbopack-ecmascript/src/analyzer/builtin.rs
+10
-47
mod.rs
turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs
+93
-83
well_known.rs
...ck/crates/turbopack-ecmascript/src/analyzer/well_known.rs
+3
-9
mod.rs
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
+69
-62
No files found.
turbopack/crates/turbopack-ecmascript/src/analyzer/builtin.rs
View file @
86fd4ea1
...
...
@@ -73,12 +73,7 @@ pub fn early_replace_builtin(value: &mut JsValue) -> bool {
}
// matching property access like `obj.prop` when we don't know what the obj is.
// We can early return here
JsValue
::
Member
(
_
,
obj
,
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
Unknown
{
..
}
)
=>
{
JsValue
::
Member
(
_
,
obj
,
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
Unknown
{
..
})
=>
{
let
JsValue
::
Unknown
{
has_side_effects
,
..
}
=
obj
.as_ref
()
...
...
@@ -140,10 +135,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
prop
:
&
mut
Arc
<
JsValue
>
,
)
->
JsValue
{
items
.push
(
JsValue
::
unknown
(
JsValue
::
member
(
Arc
::
new
(
JsValue
::
array
(
Vec
::
new
())),
take
(
prop
),
),
JsValue
::
member
(
Arc
::
new
(
JsValue
::
array
(
Vec
::
new
())),
take
(
prop
)),
false
,
"unknown array prototype methods or values"
,
));
...
...
@@ -158,12 +150,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
// Returns Some((item, mutable)) if found, None for invalid index,
// or Some((default, false)) with separate handling for non-index
let
result
=
{
let
JsValue
::
Array
{
items
,
mutable
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
let
JsValue
::
Array
{
items
,
mutable
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
unreachable!
()
};
let
JsValue
::
Constant
(
ConstantValue
::
Num
(
num
@
ConstantNumber
(
_
)))
=
...
...
@@ -231,10 +218,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
}
else
{
// otherwise we can say that this might gives an item of the array
// but we also add an unknown value to the alternatives for other properties
let
JsValue
::
Array
{
items
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
let
JsValue
::
Array
{
items
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
unreachable!
()
};
*
value
=
items_to_alternatives
(
items
,
prop
);
...
...
@@ -267,10 +251,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
}
if
include_unknown
{
values
.push
(
JsValue
::
unknown
(
JsValue
::
member
(
Arc
::
new
(
JsValue
::
object
(
Vec
::
new
())),
take
(
prop
),
),
JsValue
::
member
(
Arc
::
new
(
JsValue
::
object
(
Vec
::
new
())),
take
(
prop
)),
true
,
"unknown object prototype methods or values"
,
));
...
...
@@ -316,12 +297,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
// - Ok((new_value, mutable)) - replace *value with new_value
// - Err(()) - call value.make_unknown for spread case
let
result
:
Result
<
(
JsValue
,
bool
),
()
>
=
{
let
JsValue
::
Object
{
parts
,
mutable
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
let
JsValue
::
Object
{
parts
,
mutable
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
unreachable!
()
};
let
mutable
=
*
mutable
;
...
...
@@ -418,10 +394,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
);
true
}
else
{
let
JsValue
::
Object
{
parts
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
let
JsValue
::
Object
{
parts
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
unreachable!
()
};
*
value
=
parts_to_alternatives
(
parts
,
prop
,
true
);
...
...
@@ -454,8 +427,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
)
})
{
{
let
JsValue
::
Array
{
items
,
mutable
,
..
}
=
Arc
::
make_mut
(
obj
)
let
JsValue
::
Array
{
items
,
mutable
,
..
}
=
Arc
::
make_mut
(
obj
)
else
{
unreachable!
()
};
...
...
@@ -532,13 +504,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
*
value
=
JsValue
::
alternatives
(
take
(
values
)
.into_iter
()
.map
(|
alt
|
{
JsValue
::
member_call
(
Arc
::
new
(
alt
),
prop
.clone
(),
args
.clone
(),
)
})
.map
(|
alt
|
JsValue
::
member_call
(
Arc
::
new
(
alt
),
prop
.clone
(),
args
.clone
()))
.collect
(),
);
return
true
;
...
...
@@ -560,10 +526,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
// without special handling, we convert it into a normal call like
// `(obj.prop)(arg1, arg2, ...)`
*
value
=
JsValue
::
call
(
Arc
::
new
(
JsValue
::
member
(
take
(
obj
),
take
(
prop
))),
take
(
args
),
);
*
value
=
JsValue
::
call
(
Arc
::
new
(
JsValue
::
member
(
take
(
obj
),
take
(
prop
))),
take
(
args
));
true
}
// match calls when the callee are multiple alternative functions like `(func1 |
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/mod.rs
View file @
86fd4ea1
...
...
@@ -2321,20 +2321,23 @@ impl JsValue {
logical_property
:
_
,
}
=>
merge_if_known
(
values
,
JsValue
::
is_string
),
JsValue
::
Call
(
_
,
callee
,
_
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireResolve
|
WellKnownFunctionKind
::
PathJoin
|
WellKnownFunctionKind
::
PathResolve
(
..
)
|
WellKnownFunctionKind
::
OsArch
|
WellKnownFunctionKind
::
OsPlatform
|
WellKnownFunctionKind
::
PathDirname
|
WellKnownFunctionKind
::
PathToFileUrl
|
WellKnownFunctionKind
::
ProcessCwd
,
))
=>
Some
(
true
),
JsValue
::
Call
(
_
,
callee
,
_
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireResolve
|
WellKnownFunctionKind
::
PathJoin
|
WellKnownFunctionKind
::
PathResolve
(
..
)
|
WellKnownFunctionKind
::
OsArch
|
WellKnownFunctionKind
::
OsPlatform
|
WellKnownFunctionKind
::
PathDirname
|
WellKnownFunctionKind
::
PathToFileUrl
|
WellKnownFunctionKind
::
ProcessCwd
,
)
)
=>
{
Some
(
true
)
}
JsValue
::
Awaited
(
_
,
operand
)
=>
match
&**
operand
{
JsValue
::
Promise
(
_
,
v
)
=>
v
.is_string
(),
...
...
@@ -3529,32 +3532,33 @@ pub mod test_utils {
)
->
Result
<
(
JsValue
,
bool
)
>
{
let
ImportAttributes
{
ignore
,
..
}
=
*
attributes
;
let
mut
new_value
=
match
v
{
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
Import
))
=>
match
&
args
[
0
]
{
JsValue
::
Constant
(
ConstantValue
::
Str
(
v
))
=>
{
JsValue
::
promise
(
JsValue
::
Module
(
ModuleValue
{
module
:
v
.as_atom
()
.into_owned
()
.into
(),
annotations
:
ImportAnnotations
::
default
(),
}))
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
Import
)
)
=>
{
match
&
args
[
0
]
{
JsValue
::
Constant
(
ConstantValue
::
Str
(
v
))
=>
{
JsValue
::
promise
(
JsValue
::
Module
(
ModuleValue
{
module
:
v
.as_atom
()
.into_owned
()
.into
(),
annotations
:
ImportAnnotations
::
default
(),
}))
}
_
=>
v
.into_unknown
(
true
,
"import() non constant"
),
}
_
=>
v
.into_unknown
(
true
,
"import() non constant"
),
},
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
CreateRequire
))
=>
{
if
let
[
JsValue
::
Member
(
_
,
obj
,
prop
,
),
]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
))
}
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
CreateRequire
)
)
=>
{
if
let
[
JsValue
::
Member
(
_
,
obj
,
prop
)]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
)
)
&&
matches!
(
prop
.as_ref
(),
JsValue
::
Constant
(
ConstantValue
::
Str
(
p
))
if
p
.as_str
()
==
"url"
)
{
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
Require
)
...
...
@@ -3562,55 +3566,61 @@ pub mod test_utils {
v
.into_unknown
(
true
,
"createRequire() non constant"
)
}
}
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireResolve
))
=>
match
&
args
[
0
]
{
JsValue
::
Constant
(
v
)
=>
(
v
.to_string
()
+
"/resolved/lib/index.js"
)
.into
(),
_
=>
v
.into_unknown
(
true
,
"require.resolve non constant"
),
},
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContext
))
=>
match
parse_require_context
(
args
)
{
Ok
(
options
)
=>
{
let
mut
map
=
FxIndexMap
::
default
();
map
.insert
(
rcstr!
(
"./a"
),
format!
(
"[context: {}]/a"
,
options
.dir
)
.into
(),
);
map
.insert
(
rcstr!
(
"./b"
),
format!
(
"[context: {}]/b"
,
options
.dir
)
.into
(),
);
map
.insert
(
rcstr!
(
"./c"
),
format!
(
"[context: {}]/c"
,
options
.dir
)
.into
(),
);
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireResolve
)
)
=>
{
match
&
args
[
0
]
{
JsValue
::
Constant
(
v
)
=>
(
v
.to_string
()
+
"/resolved/lib/index.js"
)
.into
(),
_
=>
v
.into_unknown
(
true
,
"require.resolve non constant"
),
}
}
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContext
)
)
=>
{
match
parse_require_context
(
args
)
{
Ok
(
options
)
=>
{
let
mut
map
=
FxIndexMap
::
default
();
map
.insert
(
rcstr!
(
"./a"
),
format!
(
"[context: {}]/a"
,
options
.dir
)
.into
(),
);
map
.insert
(
rcstr!
(
"./b"
),
format!
(
"[context: {}]/b"
,
options
.dir
)
.into
(),
);
map
.insert
(
rcstr!
(
"./c"
),
format!
(
"[context: {}]/c"
,
options
.dir
)
.into
(),
);
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContextRequire
(
RequireContextValue
(
map
),
))
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContextRequire
(
RequireContextValue
(
map
),
))
}
Err
(
err
)
=>
v
.into_unknown
(
true
,
PrettyPrintError
(
&
err
)
.to_string
()),
}
Err
(
err
)
=>
v
.into_unknown
(
true
,
PrettyPrintError
(
&
err
)
.to_string
()),
},
JsValue
::
New
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
URLConstructor
))
=>
{
}
JsValue
::
New
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
()
,
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
URLConstructor
)
)
=>
{
if
let
[
JsValue
::
Constant
(
ConstantValue
::
Str
(
url
)),
JsValue
::
Member
(
_
,
obj
,
prop
,
),
JsValue
::
Member
(
_
,
obj
,
prop
),
]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
))
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
)
)
&&
matches!
(
prop
.as_ref
(),
JsValue
::
Constant
(
ConstantValue
::
Str
(
p
))
if
p
.as_str
()
==
"url"
)
{
// TODO avoid clone
...
...
turbopack/crates/turbopack-ecmascript/src/analyzer/well_known.rs
View file @
86fd4ea1
...
...
@@ -46,25 +46,19 @@ pub async fn replace_well_known(
}
(
JsValue
::
Call
(
usize
,
callee
,
args
),
false
)
}
JsValue
::
Member
(
_
,
obj
,
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
..
))
=>
{
JsValue
::
Member
(
_
,
obj
,
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
..
))
=>
{
let
JsValue
::
WellKnownObject
(
kind
)
=
Arc
::
unwrap_or_clone
(
obj
)
else
{
unreachable!
()
};
well_known_object_member
(
kind
,
Arc
::
unwrap_or_clone
(
prop
),
compile_time_info
)
.await
?
}
JsValue
::
Member
(
_
,
obj
,
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownFunction
(
..
))
=>
{
JsValue
::
Member
(
_
,
obj
,
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownFunction
(
..
))
=>
{
let
JsValue
::
WellKnownFunction
(
kind
)
=
Arc
::
unwrap_or_clone
(
obj
)
else
{
unreachable!
()
};
well_known_function_member
(
kind
,
Arc
::
unwrap_or_clone
(
prop
))
}
JsValue
::
Member
(
_
,
ref
obj
,
ref
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
Array
{
..
})
=>
{
JsValue
::
Member
(
_
,
ref
obj
,
ref
prop
)
if
matches!
(
obj
.as_ref
(),
JsValue
::
Array
{
..
})
=>
{
match
prop
.as_ref
()
.as_str
()
{
Some
(
"filter"
)
=>
(
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
ArrayFilter
),
...
...
turbopack/crates/turbopack-ecmascript/src/references/mod.rs
View file @
86fd4ea1
...
...
@@ -1143,7 +1143,10 @@ async fn analyze_ecmascript_module_internal(
let
condition_has_side_effects
=
condition
.has_side_effects
();
let
condition
=
analysis_state
.link_value
(
Arc
::
unwrap_or_clone
(
condition
),
ImportAttributes
::
empty_ref
())
.link_value
(
Arc
::
unwrap_or_clone
(
condition
),
ImportAttributes
::
empty_ref
(),
)
.await
?
;
macro_rules!
inactive
{
...
...
@@ -1306,7 +1309,10 @@ async fn analyze_ecmascript_module_internal(
}
let
func
=
analysis_state
.link_value
(
Arc
::
unwrap_or_clone
(
func
),
eval_context
.imports
.get_attributes
(
span
))
.link_value
(
Arc
::
unwrap_or_clone
(
func
),
eval_context
.imports
.get_attributes
(
span
),
)
.await
?
;
handle_call
(
...
...
@@ -1386,7 +1392,10 @@ async fn analyze_ecmascript_module_internal(
mutable
,
..
}
=
analysis_state
.link_value
(
Arc
::
unwrap_or_clone
(
obj
),
eval_context
.imports
.get_attributes
(
span
))
.link_value
(
Arc
::
unwrap_or_clone
(
obj
),
eval_context
.imports
.get_attributes
(
span
),
)
.await
?
{
*
value
=
analysis_state
...
...
@@ -1477,7 +1486,8 @@ async fn analyze_ecmascript_module_internal(
);
// Intentionally not awaited because `handle_member` reads this only when needed
let
obj
=
analysis_state
.link_value
(
Arc
::
unwrap_or_clone
(
obj
),
ImportAttributes
::
empty_ref
());
let
obj
=
analysis_state
.link_value
(
Arc
::
unwrap_or_clone
(
obj
),
ImportAttributes
::
empty_ref
());
let
prop
=
analysis_state
.link_value
(
Arc
::
unwrap_or_clone
(
prop
),
ImportAttributes
::
empty_ref
())
...
...
@@ -2041,16 +2051,13 @@ where
match
func
{
WellKnownFunctionKind
::
URLConstructor
=>
{
let
args
=
linked_args
()
.await
?
;
if
let
[
url
,
JsValue
::
Member
(
_
,
obj
,
prop
,
),
]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
))
&&
let
JsValue
::
Constant
(
super
::
analyzer
::
ConstantValue
::
Str
(
meta_prop
))
=
prop
.as_ref
()
if
let
[
url
,
JsValue
::
Member
(
_
,
obj
,
prop
)]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
)
)
&&
let
JsValue
::
Constant
(
super
::
analyzer
::
ConstantValue
::
Str
(
meta_prop
))
=
prop
.as_ref
()
&&
meta_prop
.as_str
()
==
"url"
{
let
pat
=
js_value_to_pattern
(
url
);
...
...
@@ -3404,32 +3411,32 @@ async fn value_visitor_inner(
return
Ok
(((
&*
value
)
.try_into
()
?
,
true
));
}
let
value
=
match
v
{
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireResolve
))
=>
{
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireResolve
)
)
=>
{
require_resolve_visitor
(
origin
,
args
.clone
())
.await
?
}
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContext
))
=>
{
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContext
)
)
=>
{
require_context_visitor
(
origin
,
args
.clone
())
.await
?
}
JsValue
::
Call
(
_
,
ref
callee
,
_
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContextRequire
(
..
)
|
WellKnownFunctionKind
::
RequireContextRequireKeys
(
..
)
|
WellKnownFunctionKind
::
RequireContextRequireResolve
(
..
),
)
)
=>
{
JsValue
::
Call
(
_
,
ref
callee
,
_
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
RequireContextRequire
(
..
)
|
WellKnownFunctionKind
::
RequireContextRequireKeys
(
..
)
|
WellKnownFunctionKind
::
RequireContextRequireResolve
(
..
),
)
)
=>
{
// TODO: figure out how to do static analysis without invalidating the whole
// analysis when a new file gets added
v
.into_unknown
(
...
...
@@ -3437,20 +3444,18 @@ async fn value_visitor_inner(
"require.context() static analysis is currently limited"
,
)
}
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
CreateRequire
))
=>
{
JsValue
::
Call
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
CreateRequire
)
)
=>
{
// Only support `createRequire(import.meta.url)` for now
if
let
[
JsValue
::
Member
(
_
,
obj
,
prop
,
),
]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
))
if
let
[
JsValue
::
Member
(
_
,
obj
,
prop
)]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
)
)
&&
let
JsValue
::
Constant
(
super
::
analyzer
::
ConstantValue
::
Str
(
prop
))
=
prop
.as_ref
()
&&
prop
.as_str
()
==
"url"
{
...
...
@@ -3459,20 +3464,20 @@ async fn value_visitor_inner(
v
.into_unknown
(
true
,
"createRequire() non constant"
)
}
}
JsValue
::
New
(
_
,
ref
callee
,
ref
args
,
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
URLConstructor
))
=>
{
JsValue
::
New
(
_
,
ref
callee
,
ref
args
)
if
matches!
(
callee
.as_ref
(),
JsValue
::
WellKnownFunction
(
WellKnownFunctionKind
::
URLConstructor
)
)
=>
{
if
let
[
JsValue
::
Constant
(
super
::
analyzer
::
ConstantValue
::
Str
(
url
)),
JsValue
::
Member
(
_
,
obj
,
prop
,
),
JsValue
::
Member
(
_
,
obj
,
prop
),
]
=
&
args
[
..
]
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
))
&&
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
ImportMeta
)
)
&&
let
JsValue
::
Constant
(
super
::
analyzer
::
ConstantValue
::
Str
(
prop
))
=
prop
.as_ref
()
{
if
prop
.as_str
()
==
"url"
{
...
...
@@ -4306,8 +4311,10 @@ fn is_invoking_node_process_eval(args: &[JsValue]) -> bool {
if
let
JsValue
::
Member
(
_
,
obj
,
constant
)
=
&
args
[
0
]
{
// Is the first argument to spawn `process.argv[]`?
if
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
NodeProcessArgv
))
&&
let
JsValue
::
Constant
(
JsConstantValue
::
Num
(
ConstantNumber
(
num
)))
=
constant
.as_ref
()
if
matches!
(
obj
.as_ref
(),
JsValue
::
WellKnownObject
(
WellKnownObjectKind
::
NodeProcessArgv
)
)
&&
let
JsValue
::
Constant
(
JsConstantValue
::
Num
(
ConstantNumber
(
num
)))
=
constant
.as_ref
()
{
// Is it specifically `process.argv[0]`?
if
num
.is_zero
()
...
...
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