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
d960fd03
Unverified
Commit
d960fd03
authored
Sep 15, 2025
by
Niklas Mischkulnig
Committed by
GitHub
Sep 15, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[backport] Turbopack: don't match dynamic pattern for node_modules packages (#83803)
Backport #83176
parent
16de4b55
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
240 additions
and
62 deletions
+240
-62
pattern.rs
turbopack/crates/turbopack-core/src/resolve/pattern.rs
+188
-27
.gitignore
turbopack/crates/turbopack-core/tests/.gitignore
+1
-0
index.js
...crates/turbopack-core/tests/pattern/read_matches/index.js
+0
-0
LICENSE
...-core/tests/pattern/read_matches/node_modules/pkg/LICENSE
+1
-0
README.md
...ore/tests/pattern/read_matches/node_modules/pkg/README.md
+1
-0
index.js
...core/tests/pattern/read_matches/node_modules/pkg/index.js
+0
-0
package.json
.../tests/pattern/read_matches/node_modules/pkg/package.json
+1
-0
foo-a.js
...es/turbopack-core/tests/pattern/read_matches/sub/foo-a.js
+0
-0
foo-a.js.map
...urbopack-core/tests/pattern/read_matches/sub/foo-a.js.map
+0
-0
foo-b.js
...es/turbopack-core/tests/pattern/read_matches/sub/foo-b.js
+0
-0
node.rs
turbopack/crates/turbopack-ecmascript/src/references/node.rs
+35
-34
raw.rs
turbopack/crates/turbopack-ecmascript/src/references/raw.rs
+13
-1
No files found.
turbopack/crates/turbopack-core/src/resolve/pattern.rs
View file @
d960fd03
This diff is collapsed.
Click to expand it.
turbopack/crates/turbopack-core/tests/.gitignore
0 → 100644
View file @
d960fd03
!**
turbopack/crates/turbopack-core/tests/pattern/read_matches/index.js
0 → 100644
View file @
d960fd03
turbopack/crates/turbopack-core/tests/pattern/read_matches/node_modules/pkg/LICENSE
0 → 100644
View file @
d960fd03
Some Text
turbopack/crates/turbopack-core/tests/pattern/read_matches/node_modules/pkg/README.md
0 → 100644
View file @
d960fd03
Some Text
turbopack/crates/turbopack-core/tests/pattern/read_matches/node_modules/pkg/index.js
0 → 100644
View file @
d960fd03
turbopack/crates/turbopack-core/tests/pattern/read_matches/node_modules/pkg/package.json
0 → 100644
View file @
d960fd03
{}
turbopack/crates/turbopack-core/tests/pattern/read_matches/sub/foo-a.js
0 → 100644
View file @
d960fd03
turbopack/crates/turbopack-core/tests/pattern/read_matches/sub/foo-a.js.map
0 → 100644
View file @
d960fd03
turbopack/crates/turbopack-core/tests/pattern/read_matches/sub/foo-b.js
0 → 100644
View file @
d960fd03
turbopack/crates/turbopack-ecmascript/src/references/node.rs
View file @
d960fd03
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
either
::
Either
;
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
;
...
@@ -77,51 +77,42 @@ async fn resolve_reference_from_dir(
...
@@ -77,51 +77,42 @@ async fn resolve_reference_from_dir(
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
path_ref
=
path
.await
?
;
let
path_ref
=
path
.await
?
;
let
(
abs_path
,
rel_path
)
=
path_ref
.split_could_match
(
"/ROOT/"
);
let
(
abs_path
,
rel_path
)
=
path_ref
.split_could_match
(
"/ROOT/"
);
let
matches
=
match
(
abs_path
,
rel_path
)
{
if
abs_path
.is_none
()
&&
rel_path
.is_none
()
{
(
Some
(
abs_path
),
Some
(
rel_path
))
=>
Either
::
Right
(
return
Ok
(
*
ModuleResolveResult
::
unresolvable
());
read_matches
(
}
parent_path
.root
()
.owned
()
.await
?
,
rcstr!
(
"/ROOT/"
),
let
abs_matches
=
if
let
Some
(
abs_path
)
=
&
abs_path
{
true
,
Some
(
Pattern
::
new
(
abs_path
.or_any_nested_file
()),
)
.await
?
.into_iter
()
.chain
(
read_matches
(
parent_path
,
rcstr!
(
""
),
true
,
Pattern
::
new
(
rel_path
.or_any_nested_file
()),
)
.await
?
.into_iter
(),
),
),
(
Some
(
abs_path
),
None
)
=>
Either
::
Left
(
// absolute path only
read_matches
(
read_matches
(
parent_path
.root
()
.owned
()
.await
?
,
parent_path
.root
()
.owned
()
.await
?
,
rcstr!
(
"/ROOT/"
),
rcstr!
(
"/ROOT/"
),
true
,
true
,
Pattern
::
new
(
abs_path
.or_any_nested_file
()),
Pattern
::
new
(
abs_path
.or_any_nested_file
()),
)
)
.await
?
.await
?
,
.into_iter
(),
)
),
}
else
{
(
None
,
Some
(
rel_path
))
=>
Either
::
Left
(
None
// relative path only
};
let
rel_matches
=
if
let
Some
(
rel_path
)
=
&
rel_path
{
Some
(
read_matches
(
read_matches
(
parent_path
,
parent_path
,
rcstr!
(
""
),
rcstr!
(
""
),
true
,
true
,
Pattern
::
new
(
rel_path
.or_any_nested_file
()),
Pattern
::
new
(
rel_path
.or_any_nested_file
()),
)
)
.await
?
.await
?
,
.into_iter
(),
)
),
}
else
{
(
None
,
None
)
=>
return
Ok
(
*
ModuleResolveResult
::
unresolvable
()),
None
};
};
let
matches
=
abs_matches
.into_iter
()
.flatten
()
.chain
(
rel_matches
.into_iter
()
.flatten
());
let
mut
affecting_sources
=
Vec
::
new
();
let
mut
affecting_sources
=
Vec
::
new
();
let
mut
results
=
Vec
::
new
();
let
mut
results
=
Vec
::
new
();
for
pat_match
in
matches
{
for
pat_match
in
matches
{
...
@@ -156,7 +147,17 @@ impl ModuleReference for DirAssetReference {
...
@@ -156,7 +147,17 @@ impl ModuleReference for DirAssetReference {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
async
fn
resolve_reference
(
&
self
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
async
fn
resolve_reference
(
&
self
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
parent_path
=
self
.source
.ident
()
.path
()
.await
?
.parent
();
let
parent_path
=
self
.source
.ident
()
.path
()
.await
?
.parent
();
Ok
(
resolve_reference_from_dir
(
parent_path
,
*
self
.path
))
let
span
=
tracing
::
info_span!
(
"trace directory"
,
pattern
=
display
(
self
.path
.to_string
()
.await
?
)
);
async
{
resolve_reference_from_dir
(
parent_path
,
*
self
.path
)
.resolve
()
.await
}
.instrument
(
span
)
.await
}
}
}
}
...
...
turbopack/crates/turbopack-ecmascript/src/references/raw.rs
View file @
d960fd03
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
ValueToString
,
Vc
};
use
turbopack_core
::{
use
turbopack_core
::{
...
@@ -28,7 +29,18 @@ impl ModuleReference for FileSourceReference {
...
@@ -28,7 +29,18 @@ impl ModuleReference for FileSourceReference {
async
fn
resolve_reference
(
&
self
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
async
fn
resolve_reference
(
&
self
)
->
Result
<
Vc
<
ModuleResolveResult
>>
{
let
context_dir
=
self
.source
.ident
()
.path
()
.await
?
.parent
();
let
context_dir
=
self
.source
.ident
()
.path
()
.await
?
.parent
();
Ok
(
resolve_raw
(
context_dir
,
*
self
.path
,
false
)
.as_raw_module_result
())
let
span
=
tracing
::
info_span!
(
"trace file"
,
pattern
=
display
(
self
.path
.to_string
()
.await
?
)
);
async
{
resolve_raw
(
context_dir
,
*
self
.path
,
false
)
.as_raw_module_result
()
.resolve
()
.await
}
.instrument
(
span
)
.await
}
}
}
}
...
...
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