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
ea818580
Unverified
Commit
ea818580
authored
Jan 23, 2026
by
Tobias Koppers
Committed by
GitHub
Jan 23, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: add indirection layer for better caching during resolving (#80062)
### What? Cache the before plugin matching
parent
088bbd8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
mod.rs
turbopack/crates/turbopack-core/src/resolve/mod.rs
+19
-8
No files found.
turbopack/crates/turbopack-core/src/resolve/mod.rs
View file @
ea818580
...
@@ -1700,6 +1700,24 @@ pub async fn url_resolve(
...
@@ -1700,6 +1700,24 @@ pub async fn url_resolve(
.await
.await
}
}
#[turbo_tasks
::
value(transparent)]
struct
MatchingBeforeResolvePlugins
(
Vec
<
ResolvedVc
<
Box
<
dyn
BeforeResolvePlugin
>>>
);
#[turbo_tasks
::
function]
async
fn
get_matching_before_resolve_plugins
(
options
:
Vc
<
ResolveOptions
>
,
request
:
Vc
<
Request
>
,
)
->
Result
<
Vc
<
MatchingBeforeResolvePlugins
>>
{
let
mut
matching_plugins
=
Vec
::
new
();
for
&
plugin
in
&
options
.await
?
.before_resolve_plugins
{
let
condition
=
plugin
.before_resolve_condition
()
.resolve
()
.await
?
;
if
*
condition
.matches
(
request
)
.await
?
{
matching_plugins
.push
(
plugin
);
}
}
Ok
(
Vc
::
cell
(
matching_plugins
))
}
#[tracing
::
instrument(level
=
"trace"
,
skip_all)]
#[tracing
::
instrument(level
=
"trace"
,
skip_all)]
async
fn
handle_before_resolve_plugins
(
async
fn
handle_before_resolve_plugins
(
lookup_path
:
FileSystemPath
,
lookup_path
:
FileSystemPath
,
...
@@ -1707,14 +1725,7 @@ async fn handle_before_resolve_plugins(
...
@@ -1707,14 +1725,7 @@ async fn handle_before_resolve_plugins(
request
:
Vc
<
Request
>
,
request
:
Vc
<
Request
>
,
options
:
Vc
<
ResolveOptions
>
,
options
:
Vc
<
ResolveOptions
>
,
)
->
Result
<
Option
<
Vc
<
ResolveResult
>>>
{
)
->
Result
<
Option
<
Vc
<
ResolveResult
>>>
{
let
options_value
=
options
.await
?
;
for
plugin
in
get_matching_before_resolve_plugins
(
options
,
request
)
.await
?
{
for
plugin
in
&
options_value
.before_resolve_plugins
{
let
condition
=
plugin
.before_resolve_condition
()
.resolve
()
.await
?
;
if
!*
condition
.matches
(
request
)
.await
?
{
continue
;
}
if
let
Some
(
result
)
=
*
plugin
if
let
Some
(
result
)
=
*
plugin
.before_resolve
(
lookup_path
.clone
(),
reference_type
.clone
(),
request
)
.before_resolve
(
lookup_path
.clone
(),
reference_type
.clone
(),
request
)
.await
?
.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