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
3651a450
Unverified
Commit
3651a450
authored
Jan 11, 2025
by
Benjamin Woodruff
Committed by
GitHub
Jan 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(turbopack-core): Remove remaining "local" value type opt-outs in turbopack-core (#74706)
parent
e1afc920
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
43 deletions
+57
-43
mod.rs
crates/next-core/src/next_font/local/mod.rs
+1
-1
resolve.rs
crates/next-core/src/next_shared/resolve.rs
+1
-1
mod.rs
turbopack/crates/turbopack-core/src/resolve/mod.rs
+17
-15
pattern.rs
turbopack/crates/turbopack-core/src/resolve/pattern.rs
+37
-23
lib.rs
turbopack/crates/turbopack/src/lib.rs
+1
-3
No files found.
crates/next-core/src/next_font/local/mod.rs
View file @
3651a450
...
@@ -123,7 +123,7 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin {
...
@@ -123,7 +123,7 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin {
.emit
();
.emit
();
return
Ok
(
ResolveResultOption
::
some
(
return
Ok
(
ResolveResultOption
::
some
(
ResolveResult
::
primary
(
ResolveResultItem
::
Error
(
Vc
::
cell
(
ResolveResult
::
primary
(
ResolveResultItem
::
Error
(
Resolved
Vc
::
cell
(
format!
(
"Font file not found: Can't resolve {}'"
,
font_path
)
format!
(
"Font file not found: Can't resolve {}'"
,
font_path
)
.into
(),
.into
(),
)))
)))
...
...
crates/next-core/src/next_shared/resolve.rs
View file @
3651a450
...
@@ -146,7 +146,7 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin {
...
@@ -146,7 +146,7 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin {
.emit
();
.emit
();
ResolveResultOption
::
some
(
ResolveResultOption
::
some
(
ResolveResult
::
primary
(
ResolveResultItem
::
Error
(
Vc
::
cell
(
ResolveResult
::
primary
(
ResolveResultItem
::
Error
(
Resolved
Vc
::
cell
(
self
.message
.join
(
"
\n
"
)
.into
(),
self
.message
.join
(
"
\n
"
)
.into
(),
)))
)))
.cell
(),
.cell
(),
...
...
turbopack/crates/turbopack-core/src/resolve/mod.rs
View file @
3651a450
...
@@ -100,7 +100,7 @@ impl ModuleResolveResultItem {
...
@@ -100,7 +100,7 @@ impl ModuleResolveResultItem {
}
}
}
}
#[turbo_tasks
::
value(shared
,
local
)]
#[turbo_tasks
::
value(shared)]
#[derive(Clone,
Debug)]
#[derive(Clone,
Debug)]
pub
struct
ModuleResolveResult
{
pub
struct
ModuleResolveResult
{
pub
primary
:
FxIndexMap
<
RequestKey
,
ModuleResolveResultItem
>
,
pub
primary
:
FxIndexMap
<
RequestKey
,
ModuleResolveResultItem
>
,
...
@@ -414,7 +414,7 @@ impl Display for ExternalType {
...
@@ -414,7 +414,7 @@ impl Display for ExternalType {
}
}
}
}
#[turbo_tasks
::
value(shared
,
local
)]
#[turbo_tasks
::
value(shared)]
#[derive(Clone)]
#[derive(Clone)]
pub
enum
ResolveResultItem
{
pub
enum
ResolveResultItem
{
Source
(
ResolvedVc
<
Box
<
dyn
Source
>>
),
Source
(
ResolvedVc
<
Box
<
dyn
Source
>>
),
...
@@ -425,7 +425,7 @@ pub enum ResolveResultItem {
...
@@ -425,7 +425,7 @@ pub enum ResolveResultItem {
traced
:
ExternalTraced
,
traced
:
ExternalTraced
,
},
},
Ignore
,
Ignore
,
Error
(
Vc
<
RcStr
>
),
Error
(
Resolved
Vc
<
RcStr
>
),
Empty
,
Empty
,
Custom
(
u8
),
Custom
(
u8
),
}
}
...
@@ -473,7 +473,7 @@ impl RequestKey {
...
@@ -473,7 +473,7 @@ impl RequestKey {
}
}
}
}
#[turbo_tasks
::
value(shared
,
local
)]
#[turbo_tasks
::
value(shared)]
#[derive(Clone)]
#[derive(Clone)]
pub
struct
ResolveResult
{
pub
struct
ResolveResult
{
pub
primary
:
FxIndexMap
<
RequestKey
,
ResolveResultItem
>
,
pub
primary
:
FxIndexMap
<
RequestKey
,
ResolveResultItem
>
,
...
@@ -721,9 +721,7 @@ impl ResolveResult {
...
@@ -721,9 +721,7 @@ impl ResolveResult {
}
}
ResolveResultItem
::
Ignore
=>
ModuleResolveResultItem
::
Ignore
,
ResolveResultItem
::
Ignore
=>
ModuleResolveResultItem
::
Ignore
,
ResolveResultItem
::
Empty
=>
ModuleResolveResultItem
::
Empty
,
ResolveResultItem
::
Empty
=>
ModuleResolveResultItem
::
Empty
,
ResolveResultItem
::
Error
(
e
)
=>
{
ResolveResultItem
::
Error
(
e
)
=>
ModuleResolveResultItem
::
Error
(
e
),
ModuleResolveResultItem
::
Error
(
e
.to_resolved
()
.await
?
)
}
ResolveResultItem
::
Custom
(
u8
)
=>
{
ResolveResultItem
::
Custom
(
u8
)
=>
{
ModuleResolveResultItem
::
Custom
(
u8
)
ModuleResolveResultItem
::
Custom
(
u8
)
}
}
...
@@ -1418,7 +1416,10 @@ pub async fn resolve_raw(
...
@@ -1418,7 +1416,10 @@ pub async fn resolve_raw(
path
:
Vc
<
Pattern
>
,
path
:
Vc
<
Pattern
>
,
force_in_lookup_dir
:
bool
,
force_in_lookup_dir
:
bool
,
)
->
Result
<
Vc
<
ResolveResult
>>
{
)
->
Result
<
Vc
<
ResolveResult
>>
{
async
fn
to_result
(
request
:
&
str
,
path
:
Vc
<
FileSystemPath
>
)
->
Result
<
Vc
<
ResolveResult
>>
{
async
fn
to_result
(
request
:
&
str
,
path
:
ResolvedVc
<
FileSystemPath
>
,
)
->
Result
<
Vc
<
ResolveResult
>>
{
let
RealPathResult
{
path
,
symlinks
}
=
&*
path
.realpath_with_links
()
.await
?
;
let
RealPathResult
{
path
,
symlinks
}
=
&*
path
.realpath_with_links
()
.await
?
;
Ok
(
ResolveResult
::
source_with_affecting_sources
(
Ok
(
ResolveResult
::
source_with_affecting_sources
(
RequestKey
::
new
(
request
.into
()),
RequestKey
::
new
(
request
.into
()),
...
@@ -1771,7 +1772,7 @@ async fn resolve_internal_inline(
...
@@ -1771,7 +1772,7 @@ async fn resolve_internal_inline(
results
.push
(
results
.push
(
resolved
(
resolved
(
RequestKey
::
new
(
matched_pattern
.clone
()),
RequestKey
::
new
(
matched_pattern
.clone
()),
*
path
,
*
*
path
,
lookup_path
,
lookup_path
,
request
,
request
,
options_value
,
options_value
,
...
@@ -1784,7 +1785,7 @@ async fn resolve_internal_inline(
...
@@ -1784,7 +1785,7 @@ async fn resolve_internal_inline(
}
}
PatternMatch
::
Directory
(
matched_pattern
,
path
)
=>
{
PatternMatch
::
Directory
(
matched_pattern
,
path
)
=>
{
results
.push
(
results
.push
(
resolve_into_folder
(
*
path
,
options
)
resolve_into_folder
(
*
*
path
,
options
)
.with_request
(
matched_pattern
.clone
()),
.with_request
(
matched_pattern
.clone
()),
);
);
}
}
...
@@ -2186,7 +2187,7 @@ async fn resolve_relative_request(
...
@@ -2186,7 +2187,7 @@ async fn resolve_relative_request(
results
.push
(
results
.push
(
resolved
(
resolved
(
RequestKey
::
new
(
matched_pattern
.into
()),
RequestKey
::
new
(
matched_pattern
.into
()),
*
path
,
*
*
path
,
lookup_path
,
lookup_path
,
request
,
request
,
options_value
,
options_value
,
...
@@ -2203,7 +2204,7 @@ async fn resolve_relative_request(
...
@@ -2203,7 +2204,7 @@ async fn resolve_relative_request(
results
.push
(
results
.push
(
resolved
(
resolved
(
RequestKey
::
new
(
matched_pattern
.into
()),
RequestKey
::
new
(
matched_pattern
.into
()),
*
path
,
*
*
path
,
lookup_path
,
lookup_path
,
request
,
request
,
options_value
,
options_value
,
...
@@ -2226,7 +2227,7 @@ async fn resolve_relative_request(
...
@@ -2226,7 +2227,7 @@ async fn resolve_relative_request(
results
.push
(
results
.push
(
resolved
(
resolved
(
RequestKey
::
new
(
matched_pattern
.into
()),
RequestKey
::
new
(
matched_pattern
.into
()),
*
path
,
*
*
path
,
lookup_path
,
lookup_path
,
request
,
request
,
options_value
,
options_value
,
...
@@ -2244,7 +2245,7 @@ async fn resolve_relative_request(
...
@@ -2244,7 +2245,7 @@ async fn resolve_relative_request(
results
.push
(
results
.push
(
resolved
(
resolved
(
RequestKey
::
new
(
matched_pattern
.clone
()),
RequestKey
::
new
(
matched_pattern
.clone
()),
*
path
,
*
*
path
,
lookup_path
,
lookup_path
,
request
,
request
,
options_value
,
options_value
,
...
@@ -2260,7 +2261,8 @@ async fn resolve_relative_request(
...
@@ -2260,7 +2261,8 @@ async fn resolve_relative_request(
// Directory matches must be resolved AFTER file matches
// Directory matches must be resolved AFTER file matches
for
m
in
matches
.iter
()
{
for
m
in
matches
.iter
()
{
if
let
PatternMatch
::
Directory
(
matched_pattern
,
path
)
=
m
{
if
let
PatternMatch
::
Directory
(
matched_pattern
,
path
)
=
m
{
results
.push
(
resolve_into_folder
(
*
path
,
options
)
.with_request
(
matched_pattern
.clone
()));
results
.push
(
resolve_into_folder
(
**
path
,
options
)
.with_request
(
matched_pattern
.clone
()));
}
}
}
}
...
...
turbopack/crates/turbopack-core/src/resolve/pattern.rs
View file @
3651a450
...
@@ -11,7 +11,8 @@ use serde::{Deserialize, Serialize};
...
@@ -11,7 +11,8 @@ use serde::{Deserialize, Serialize};
use
tracing
::
Instrument
;
use
tracing
::
Instrument
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
use
turbo_tasks
::{
debug
::
ValueDebugFormat
,
trace
::
TraceRawVcs
,
ResolvedVc
,
Value
,
ValueToString
,
Vc
,
debug
::
ValueDebugFormat
,
trace
::
TraceRawVcs
,
NonLocalValue
,
ResolvedVc
,
Value
,
ValueToString
,
Vc
,
};
};
use
turbo_tasks_fs
::{
use
turbo_tasks_fs
::{
util
::
normalize_path
,
DirectoryContent
,
DirectoryEntry
,
FileSystemEntryType
,
FileSystemPath
,
util
::
normalize_path
,
DirectoryContent
,
DirectoryEntry
,
FileSystemEntryType
,
FileSystemPath
,
...
@@ -1300,14 +1301,24 @@ impl ValueToString for Pattern {
...
@@ -1300,14 +1301,24 @@ impl ValueToString for Pattern {
}
}
}
}
#[derive(Debug,
PartialEq,
Eq,
Clone,
TraceRawVcs,
Serialize,
Deserialize,
ValueDebugFormat)]
#[derive(
Debug,
PartialEq,
Eq,
Clone,
TraceRawVcs,
Serialize,
Deserialize,
ValueDebugFormat,
NonLocalValue,
)]
pub
enum
PatternMatch
{
pub
enum
PatternMatch
{
File
(
RcStr
,
Vc
<
FileSystemPath
>
),
File
(
RcStr
,
Resolved
Vc
<
FileSystemPath
>
),
Directory
(
RcStr
,
Vc
<
FileSystemPath
>
),
Directory
(
RcStr
,
Resolved
Vc
<
FileSystemPath
>
),
}
}
impl
PatternMatch
{
impl
PatternMatch
{
pub
fn
path
(
&
self
)
->
Vc
<
FileSystemPath
>
{
pub
fn
path
(
&
self
)
->
Resolved
Vc
<
FileSystemPath
>
{
match
*
self
{
match
*
self
{
PatternMatch
::
File
(
_
,
path
)
|
PatternMatch
::
Directory
(
_
,
path
)
=>
path
,
PatternMatch
::
File
(
_
,
path
)
|
PatternMatch
::
Directory
(
_
,
path
)
=>
path
,
}
}
...
@@ -1322,7 +1333,7 @@ impl PatternMatch {
...
@@ -1322,7 +1333,7 @@ impl PatternMatch {
// TODO this isn't super efficient
// TODO this isn't super efficient
// avoid storing a large list of matches
// avoid storing a large list of matches
#[turbo_tasks
::
value(transparent
,
local
)]
#[turbo_tasks
::
value(transparent)]
pub
struct
PatternMatches
(
Vec
<
PatternMatch
>
);
pub
struct
PatternMatches
(
Vec
<
PatternMatch
>
);
/// Find all files or directories that match the provided `pattern` with the
/// Find all files or directories that match the provided `pattern` with the
...
@@ -1356,12 +1367,12 @@ pub async fn read_matches(
...
@@ -1356,12 +1367,12 @@ pub async fn read_matches(
for
(
index
,
(
str
,
until_end
))
in
constants
.into_iter
()
.enumerate
()
{
for
(
index
,
(
str
,
until_end
))
in
constants
.into_iter
()
.enumerate
()
{
if
until_end
{
if
until_end
{
if
handled
.insert
(
str
)
{
if
handled
.insert
(
str
)
{
if
let
Some
(
fs_path
)
=
&
*
if
force_in_lookup_dir
{
let
fs_path
=
*
if
force_in_lookup_dir
{
lookup_dir
.try_join_inside
(
str
.into
())
.await
?
lookup_dir
.try_join_inside
(
str
.into
())
.await
?
}
else
{
}
else
{
lookup_dir
.try_join
(
str
.into
())
.await
?
lookup_dir
.try_join
(
str
.into
())
.await
?
}
{
}
;
let
fs_path
=
fs_path
.resolve
()
.await
?
;
if
let
Some
(
fs_path
)
=
fs_path
{
// This explicit deref of `context` is necessary
// This explicit deref of `context` is necessary
#[allow(clippy
::
explicit_auto_deref)]
#[allow(clippy
::
explicit_auto_deref)]
let
should_match
=
!
force_in_lookup_dir
let
should_match
=
!
force_in_lookup_dir
...
@@ -1453,7 +1464,10 @@ pub async fn read_matches(
...
@@ -1453,7 +1464,10 @@ pub async fn read_matches(
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
lookup_dir
.parent
()),
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
lookup_dir
.parent
()
.to_resolved
()
.await
?
,
),
));
));
}
}
...
@@ -1462,7 +1476,10 @@ pub async fn read_matches(
...
@@ -1462,7 +1476,10 @@ pub async fn read_matches(
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
lookup_dir
.parent
()),
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
lookup_dir
.parent
()
.to_resolved
()
.await
?
,
),
));
));
}
}
if
let
Some
(
pos
)
=
pat
.could_match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.could_match_position
(
&
prefix
)
{
...
@@ -1481,14 +1498,14 @@ pub async fn read_matches(
...
@@ -1481,14 +1498,14 @@ pub async fn read_matches(
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
*
lookup_dir
),
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
lookup_dir
),
));
));
}
}
prefix
.pop
();
prefix
.pop
();
}
}
if
prefix
.is_empty
()
{
if
prefix
.is_empty
()
{
if
let
Some
(
pos
)
=
pat
.match_position
(
"./"
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
"./"
)
{
results
.push
((
pos
,
PatternMatch
::
Directory
(
"./"
.into
(),
*
lookup_dir
)));
results
.push
((
pos
,
PatternMatch
::
Directory
(
"./"
.into
(),
lookup_dir
)));
}
}
if
let
Some
(
pos
)
=
pat
.could_match_position
(
"./"
)
{
if
let
Some
(
pos
)
=
pat
.could_match_position
(
"./"
)
{
nested
.push
((
pos
,
read_matches
(
*
lookup_dir
,
"./"
.into
(),
false
,
pattern
)));
nested
.push
((
pos
,
read_matches
(
*
lookup_dir
,
"./"
.into
(),
false
,
pattern
)));
...
@@ -1525,7 +1542,7 @@ pub async fn read_matches(
...
@@ -1525,7 +1542,7 @@ pub async fn read_matches(
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
File
(
prefix
.clone
()
.into
(),
*
*
path
),
PatternMatch
::
File
(
prefix
.clone
()
.into
(),
*
path
),
));
));
}
}
prefix
.truncate
(
len
)
prefix
.truncate
(
len
)
...
@@ -1540,7 +1557,7 @@ pub async fn read_matches(
...
@@ -1540,7 +1557,7 @@ pub async fn read_matches(
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
*
*
path
),
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
*
path
),
));
));
}
}
prefix
.push
(
'/'
);
prefix
.push
(
'/'
);
...
@@ -1548,7 +1565,7 @@ pub async fn read_matches(
...
@@ -1548,7 +1565,7 @@ pub async fn read_matches(
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.match_position
(
&
prefix
)
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
*
*
path
),
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
*
path
),
));
));
}
}
if
let
Some
(
pos
)
=
pat
.could_match_position
(
&
prefix
)
{
if
let
Some
(
pos
)
=
pat
.could_match_position
(
&
prefix
)
{
...
@@ -1575,16 +1592,13 @@ pub async fn read_matches(
...
@@ -1575,16 +1592,13 @@ pub async fn read_matches(
pos
,
pos
,
PatternMatch
::
Directory
(
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
prefix
.clone
()
.into
(),
*
*
fs_path
,
*
fs_path
,
),
),
));
));
}
else
{
}
else
{
results
.push
((
results
.push
((
pos
,
pos
,
PatternMatch
::
File
(
PatternMatch
::
File
(
prefix
.clone
()
.into
(),
*
fs_path
),
prefix
.clone
()
.into
(),
**
fs_path
,
),
));
));
}
}
}
}
...
@@ -1599,7 +1613,7 @@ pub async fn read_matches(
...
@@ -1599,7 +1613,7 @@ pub async fn read_matches(
pos
,
pos
,
PatternMatch
::
Directory
(
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
prefix
.clone
()
.into
(),
*
*
fs_path
,
*
fs_path
,
),
),
));
));
}
}
...
@@ -1614,7 +1628,7 @@ pub async fn read_matches(
...
@@ -1614,7 +1628,7 @@ pub async fn read_matches(
pos
,
pos
,
PatternMatch
::
Directory
(
PatternMatch
::
Directory
(
prefix
.clone
()
.into
(),
prefix
.clone
()
.into
(),
*
*
fs_path
,
*
fs_path
,
),
),
));
));
}
}
...
...
turbopack/crates/turbopack/src/lib.rs
View file @
3651a450
...
@@ -836,9 +836,7 @@ impl AssetContext for ModuleAssetContext {
...
@@ -836,9 +836,7 @@ impl AssetContext for ModuleAssetContext {
}
}
ResolveResultItem
::
Ignore
=>
ModuleResolveResultItem
::
Ignore
,
ResolveResultItem
::
Ignore
=>
ModuleResolveResultItem
::
Ignore
,
ResolveResultItem
::
Empty
=>
ModuleResolveResultItem
::
Empty
,
ResolveResultItem
::
Empty
=>
ModuleResolveResultItem
::
Empty
,
ResolveResultItem
::
Error
(
e
)
=>
{
ResolveResultItem
::
Error
(
e
)
=>
ModuleResolveResultItem
::
Error
(
e
),
ModuleResolveResultItem
::
Error
(
e
.to_resolved
()
.await
?
)
}
ResolveResultItem
::
Custom
(
u8
)
=>
ModuleResolveResultItem
::
Custom
(
u8
),
ResolveResultItem
::
Custom
(
u8
)
=>
ModuleResolveResultItem
::
Custom
(
u8
),
})
})
}
}
...
...
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