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
7ed6339f
Commit
7ed6339f
authored
Feb 19, 2026
by
Matt Mastracci
Committed by
Matt Mastracci
Feb 23, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Second phase
parent
58f4b029
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
119 additions
and
88 deletions
+119
-88
app.rs
crates/next-api/src/app.rs
+30
-7
client_references.rs
crates/next-api/src/client_references.rs
+10
-10
dynamic_imports.rs
crates/next-api/src/dynamic_imports.rs
+7
-9
module_graph.rs
crates/next-api/src/module_graph.rs
+3
-7
app_client_references_chunks.rs
...es/next-core/src/next_app/app_client_references_chunks.rs
+15
-13
visit_client_reference.rs
...-core/src/next_client_reference/visit_client_reference.rs
+13
-29
dynamic_module.rs
crates/next-core/src/next_dynamic/dynamic_module.rs
+5
-2
client_reference_manifest.rs
...next-core/src/next_manifests/client_reference_manifest.rs
+12
-5
server_component_module.rs
...core/src/next_server_component/server_component_module.rs
+7
-4
server_utility_module.rs
...ext-core/src/next_server_utility/server_utility_module.rs
+5
-2
boundary.rs
turbopack/crates/turbopack-core/src/boundary.rs
+12
-0
No files found.
crates/next-api/src/app.rs
View file @
7ed6339f
...
@@ -918,7 +918,16 @@ impl AppProject {
...
@@ -918,7 +918,16 @@ impl AppProject {
merge_tag
:
NEXT_SERVER_UTILITY_MERGE_TAG
.clone
(),
merge_tag
:
NEXT_SERVER_UTILITY_MERGE_TAG
.clone
(),
entries
:
server_utils
entries
:
server_utils
.iter
()
.iter
()
.map
(
async
|
m
|
Ok
(
ResolvedVc
::
upcast
(
m
.await
?
.module
)))
.map
(
async
|
m
|
{
let
boundary
=
m
.boundary_info
()
.await
?
.as_ref
()
.expect
(
"server utility must have boundary info"
)
.inner_module
.expect
(
"server utility must have inner module"
);
Ok
(
boundary
)
})
.try_join
()
.try_join
()
.await
?
,
.await
?
,
},
},
...
@@ -941,13 +950,13 @@ impl AppProject {
...
@@ -941,13 +950,13 @@ impl AppProject {
let
graph
=
SingleModuleGraph
::
new_with_entries_visited_intern
(
let
graph
=
SingleModuleGraph
::
new_with_entries_visited_intern
(
// This should really be ChunkGroupEntry::Shared(module.await?.module),
// This should really be ChunkGroupEntry::Shared(module.await?.module),
// but that breaks everything for some reason.
// but that breaks everything for some reason.
vec!
[
ChunkGroupEntry
::
Entry
(
vec!
[
ResolvedVc
::
upcast
(
*
module
)
])],
vec!
[
ChunkGroupEntry
::
Entry
(
vec!
[
*
module
])],
visited_modules
,
visited_modules
,
should_trace
,
should_trace
,
should_read_binding_usage
,
should_read_binding_usage
,
);
);
graphs
.push
(
graph
);
graphs
.push
(
graph
);
let
is_layout
=
module
.
server_
path
()
.await
?
.file_stem
()
==
Some
(
"layout"
);
let
is_layout
=
module
.
ident
()
.
path
()
.await
?
.file_stem
()
==
Some
(
"layout"
);
visited_modules
=
if
is_layout
{
visited_modules
=
if
is_layout
{
// Only propagate the visited_modules of the parent layout(s), not
// Only propagate the visited_modules of the parent layout(s), not
// across siblings such as loading.js and
// across siblings such as loading.js and
...
@@ -1847,7 +1856,16 @@ impl AppEndpoint {
...
@@ -1847,7 +1856,16 @@ impl AppEndpoint {
let
server_utils
=
client_references
let
server_utils
=
client_references
.server_utils
.server_utils
.iter
()
.iter
()
.map
(
async
|
m
|
Ok
(
ResolvedVc
::
upcast
(
m
.await
?
.module
)))
.map
(
async
|
m
|
{
let
boundary
=
m
.boundary_info
()
.await
?
.as_ref
()
.expect
(
"server utility must have boundary info"
)
.inner_module
.expect
(
"server utility must have inner module"
);
Ok
(
boundary
)
})
.try_join
()
.try_join
()
.await
?
;
.await
?
;
let
chunk_group
=
chunking_context
let
chunk_group
=
chunking_context
...
@@ -1886,12 +1904,17 @@ impl AppEndpoint {
...
@@ -1886,12 +1904,17 @@ impl AppEndpoint {
name
=
display
(
server_component
.ident
()
.to_string
()
.await
?
)
name
=
display
(
server_component
.ident
()
.to_string
()
.await
?
)
);
);
async
{
async
{
let
inner
=
server_component
.boundary_info
()
.await
?
.as_ref
()
.expect
(
"server component must have boundary info"
)
.inner_module
.expect
(
"server component must have inner module"
);
let
chunk_group
=
chunking_context
.chunk_group
(
let
chunk_group
=
chunking_context
.chunk_group
(
server_component
.ident
(),
server_component
.ident
(),
// TODO this should be ChunkGroup::Shared
// TODO this should be ChunkGroup::Shared
ChunkGroup
::
Entry
(
vec!
[
ResolvedVc
::
upcast
(
ChunkGroup
::
Entry
(
vec!
[
inner
]),
server_component
.await
?
.module
,
)]),
module_graph
,
module_graph
,
current_chunk_group
.await
?
.availability_info
,
current_chunk_group
.await
?
.availability_info
,
);
);
...
...
crates/next-api/src/client_references.rs
View file @
7ed6339f
...
@@ -3,8 +3,6 @@ use bincode::{Decode, Encode};
...
@@ -3,8 +3,6 @@ use bincode::{Decode, Encode};
use
next_core
::{
use
next_core
::{
boundary_types
::{
boundary_type_server_component
,
boundary_type_server_utility
},
boundary_types
::{
boundary_type_server_component
,
boundary_type_server_utility
},
next_client_reference
::{
CssClientReferenceModule
,
EcmascriptClientReferenceModule
},
next_client_reference
::{
CssClientReferenceModule
,
EcmascriptClientReferenceModule
},
next_server_component
::
server_component_module
::
NextServerComponentModule
,
next_server_utility
::
server_utility_module
::
NextServerUtilityModule
,
};
};
use
rustc_hash
::
FxHashMap
;
use
rustc_hash
::
FxHashMap
;
use
turbo_tasks
::{
use
turbo_tasks
::{
...
@@ -22,8 +20,8 @@ pub enum ClientManifestEntryType {
...
@@ -22,8 +20,8 @@ pub enum ClientManifestEntryType {
ssr_module
:
ResolvedVc
<
Box
<
dyn
Module
>>
,
ssr_module
:
ResolvedVc
<
Box
<
dyn
Module
>>
,
},
},
CssClientReference
(
ResolvedVc
<
Box
<
dyn
CssChunkPlaceable
>>
),
CssClientReference
(
ResolvedVc
<
Box
<
dyn
CssChunkPlaceable
>>
),
ServerComponent
(
ResolvedVc
<
NextServerComponentModule
>
),
ServerComponent
(
ResolvedVc
<
Box
<
dyn
Module
>
>
),
ServerUtility
(
ResolvedVc
<
NextServerUtilityModule
>
),
ServerUtility
(
ResolvedVc
<
Box
<
dyn
Module
>
>
),
}
}
/// Tracks information about all the css and js client references in the graph.
/// Tracks information about all the css and js client references in the graph.
...
@@ -59,13 +57,15 @@ pub async fn map_client_references(
...
@@ -59,13 +57,15 @@ pub async fn map_client_references(
)))
)))
}
else
if
let
Some
(
boundary
)
=
&*
module
.boundary_info
()
.await
?
{
}
else
if
let
Some
(
boundary
)
=
&*
module
.boundary_info
()
.await
?
{
if
boundary
.boundary_type
==
boundary_type_server_component
()
{
if
boundary
.boundary_type
==
boundary_type_server_component
()
{
let
sc
=
ResolvedVc
::
try_downcast_type
::
<
NextServerComponentModule
>
(
module
)
Ok
(
Some
((
.expect
(
"server-component boundary must be NextServerComponentModule"
);
module
,
Ok
(
Some
((
module
,
ClientManifestEntryType
::
ServerComponent
(
sc
))))
ClientManifestEntryType
::
ServerComponent
(
module
),
)))
}
else
if
boundary
.boundary_type
==
boundary_type_server_utility
()
{
}
else
if
boundary
.boundary_type
==
boundary_type_server_utility
()
{
let
su
=
ResolvedVc
::
try_downcast_type
::
<
NextServerUtilityModule
>
(
module
)
Ok
(
Some
((
.expect
(
"server-utility boundary must be NextServerUtilityModule"
);
module
,
Ok
(
Some
((
module
,
ClientManifestEntryType
::
ServerUtility
(
su
))))
ClientManifestEntryType
::
ServerUtility
(
module
),
)))
}
else
{
}
else
{
Ok
(
None
)
Ok
(
None
)
}
}
...
...
crates/next-api/src/dynamic_imports.rs
View file @
7ed6339f
...
@@ -23,7 +23,7 @@ use anyhow::{Context, Result};
...
@@ -23,7 +23,7 @@ use anyhow::{Context, Result};
use
bincode
::{
Decode
,
Encode
};
use
bincode
::{
Decode
,
Encode
};
use
next_core
::{
use
next_core
::{
boundary_types
::
boundary_type_dynamic_entry
,
next_app
::
ClientReferencesChunks
,
boundary_types
::
boundary_type_dynamic_entry
,
next_app
::
ClientReferencesChunks
,
next_client_reference
::
EcmascriptClientReferenceModule
,
next_dynamic
::
NextDynamicEntryModule
,
next_client_reference
::
EcmascriptClientReferenceModule
,
};
};
use
turbo_tasks
::{
use
turbo_tasks
::{
FxIndexMap
,
NonLocalValue
,
ReadRef
,
ResolvedVc
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Vc
,
FxIndexMap
,
NonLocalValue
,
ReadRef
,
ResolvedVc
,
TryFlatJoinIterExt
,
TryJoinIterExt
,
Vc
,
...
@@ -55,7 +55,8 @@ pub(crate) async fn collect_next_dynamic_chunks(
...
@@ -55,7 +55,8 @@ pub(crate) async fn collect_next_dynamic_chunks(
let
dynamic_import_chunks
=
dynamic_import_entries
let
dynamic_import_chunks
=
dynamic_import_entries
.iter
()
.iter
()
.map
(|(
dynamic_entry
,
parent_client_reference
)|
async
move
{
.map
(|(
dynamic_entry
,
parent_client_reference
)|
async
move
{
let
module
=
ResolvedVc
::
upcast
::
<
Box
<
dyn
ChunkableModule
>>
(
*
dynamic_entry
);
let
module
=
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
ChunkableModule
>>
(
*
dynamic_entry
)
.expect
(
"dynamic entry must be ChunkableModule"
);
// This is the availability info for the parent chunk group, i.e. the client reference
// This is the availability info for the parent chunk group, i.e. the client reference
// containing the next/dynamic imports
// containing the next/dynamic imports
...
@@ -96,9 +97,9 @@ pub(crate) async fn collect_next_dynamic_chunks(
...
@@ -96,9 +97,9 @@ pub(crate) async fn collect_next_dynamic_chunks(
pub
struct
DynamicImportedChunks
(
pub
struct
DynamicImportedChunks
(
#[bincode(with
=
"turbo_bincode::indexmap"
)]
#[bincode(with
=
"turbo_bincode::indexmap"
)]
pub
FxIndexMap
<
pub
FxIndexMap
<
ResolvedVc
<
NextDynamicEntryModule
>
,
ResolvedVc
<
Box
<
dyn
Module
>
>
,
(
(
ResolvedVc
<
NextDynamicEntryModule
>
,
ResolvedVc
<
Box
<
dyn
Module
>
>
,
ResolvedVc
<
OutputAssetsWithReferenced
>
,
ResolvedVc
<
OutputAssetsWithReferenced
>
,
),
),
>
,
>
,
...
@@ -106,7 +107,7 @@ pub struct DynamicImportedChunks(
...
@@ -106,7 +107,7 @@ pub struct DynamicImportedChunks(
#[derive(Clone,
PartialEq,
Eq,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue,
Encode,
Decode)]
#[derive(Clone,
PartialEq,
Eq,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue,
Encode,
Decode)]
pub
enum
DynamicImportEntriesMapType
{
pub
enum
DynamicImportEntriesMapType
{
DynamicEntry
(
ResolvedVc
<
NextDynamicEntryModule
>
),
DynamicEntry
(
ResolvedVc
<
Box
<
dyn
Module
>
>
),
ClientReference
(
ResolvedVc
<
EcmascriptClientReferenceModule
>
),
ClientReference
(
ResolvedVc
<
EcmascriptClientReferenceModule
>
),
}
}
...
@@ -133,12 +134,9 @@ pub async fn map_next_dynamic(
...
@@ -133,12 +134,9 @@ pub async fn map_next_dynamic(
&&
let
Some
(
boundary
)
=
&*
module
.boundary_info
()
.await
?
&&
let
Some
(
boundary
)
=
&*
module
.boundary_info
()
.await
?
&&
boundary
.boundary_type
==
boundary_type_dynamic_entry
()
&&
boundary
.boundary_type
==
boundary_type_dynamic_entry
()
{
{
let
dynamic_entry_module
=
ResolvedVc
::
try_downcast_type
::
<
NextDynamicEntryModule
>
(
module
)
.expect
(
"dynamic-entry boundary must be NextDynamicEntryModule"
);
return
Ok
(
Some
((
return
Ok
(
Some
((
module
,
module
,
DynamicImportEntriesMapType
::
DynamicEntry
(
dynamic_entry_
module
),
DynamicImportEntriesMapType
::
DynamicEntry
(
module
),
)));
)));
}
}
// TODO add this check once these modules have the correct layer
// TODO add this check once these modules have the correct layer
...
...
crates/next-api/src/module_graph.rs
View file @
7ed6339f
...
@@ -8,7 +8,6 @@ use next_core::{
...
@@ -8,7 +8,6 @@ use next_core::{
ClientReference
,
ClientReferenceGraphResult
,
ClientReferenceType
,
ServerEntries
,
ClientReference
,
ClientReferenceGraphResult
,
ClientReferenceType
,
ServerEntries
,
find_server_entries
,
find_server_entries
,
},
},
next_dynamic
::
NextDynamicEntryModule
,
next_manifests
::
ActionLayer
,
next_manifests
::
ActionLayer
,
};
};
use
rustc_hash
::
FxHashMap
;
use
rustc_hash
::
FxHashMap
;
...
@@ -39,7 +38,7 @@ pub struct NextDynamicGraph {
...
@@ -39,7 +38,7 @@ pub struct NextDynamicGraph {
graph
:
ResolvedVc
<
ModuleGraphLayer
>
,
graph
:
ResolvedVc
<
ModuleGraphLayer
>
,
is_single_page
:
bool
,
is_single_page
:
bool
,
/// list of
NextDynamicEntryM
odules
/// list of
next/dynamic entry m
odules
data
:
ResolvedVc
<
DynamicImportEntries
>
,
data
:
ResolvedVc
<
DynamicImportEntries
>
,
}
}
...
@@ -122,10 +121,7 @@ impl NextDynamicGraphs {
...
@@ -122,10 +121,7 @@ impl NextDynamicGraphs {
#[turbo_tasks
::
value(transparent)]
#[turbo_tasks
::
value(transparent)]
pub
struct
DynamicImportEntriesWithImporter
(
pub
struct
DynamicImportEntriesWithImporter
(
pub
Vec
<
(
pub
Vec
<
(
ResolvedVc
<
Box
<
dyn
Module
>>
,
Option
<
ClientReferenceType
>
)
>
,
ResolvedVc
<
NextDynamicEntryModule
>
,
Option
<
ClientReferenceType
>
,
)
>
,
);
);
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
...
@@ -622,7 +618,7 @@ impl ClientReferencesGraph {
...
@@ -622,7 +618,7 @@ impl ClientReferencesGraph {
// determine the order of client references individually for each server component.
// determine the order of client references individually for each server component.
for
sc
in
server_components
.iter
()
.copied
()
{
for
sc
in
server_components
.iter
()
.copied
()
{
graph
.traverse_nodes_dfs
(
graph
.traverse_nodes_dfs
(
std
::
iter
::
once
(
ResolvedVc
::
upcast
(
sc
)
),
std
::
iter
::
once
(
sc
),
&
mut
(),
&
mut
(),
|
node
,
_
|
{
|
node
,
_
|
{
let
module
=
node
;
let
module
=
node
;
...
...
crates/next-core/src/next_app/app_client_references_chunks.rs
View file @
7ed6339f
...
@@ -9,15 +9,12 @@ use turbopack_core::{
...
@@ -9,15 +9,12 @@ use turbopack_core::{
output
::
OutputAssetsWithReferenced
,
output
::
OutputAssetsWithReferenced
,
};
};
use
crate
::{
use
crate
::
next_client_reference
::{
next_client_reference
::{
ClientReferenceType
,
ClientReferenceType
,
ecmascript_client_reference
::
ecmascript_client_reference_module
::{
ecmascript_client_reference
::
ecmascript_client_reference_module
::{
ecmascript_client_reference_merge_tag
,
ecmascript_client_reference_merge_tag_ssr
,
ecmascript_client_reference_merge_tag
,
ecmascript_client_reference_merge_tag_ssr
,
},
visit_client_reference
::
ClientReferenceGraphResult
,
},
},
next_server_component
::
server_component_module
::
NextServerComponentModule
,
visit_client_reference
::
ClientReferenceGraphResult
,
};
};
#[turbo_tasks
::
value]
#[turbo_tasks
::
value]
...
@@ -30,7 +27,7 @@ pub struct ClientReferencesChunks {
...
@@ -30,7 +27,7 @@ pub struct ClientReferencesChunks {
FxIndexMap
<
ClientReferenceType
,
ResolvedVc
<
OutputAssetsWithReferenced
>>
,
FxIndexMap
<
ClientReferenceType
,
ResolvedVc
<
OutputAssetsWithReferenced
>>
,
#[bincode(with
=
"turbo_bincode::indexmap"
)]
#[bincode(with
=
"turbo_bincode::indexmap"
)]
pub
layout_segment_client_chunks
:
pub
layout_segment_client_chunks
:
FxIndexMap
<
ResolvedVc
<
NextServerComponentModule
>
,
ResolvedVc
<
OutputAssetsWithReferenced
>>
,
FxIndexMap
<
ResolvedVc
<
Box
<
dyn
Module
>
>
,
ResolvedVc
<
OutputAssetsWithReferenced
>>
,
}
}
/// Computes all client references chunks.
/// Computes all client references chunks.
...
@@ -177,15 +174,20 @@ pub async fn get_app_client_references_chunks(
...
@@ -177,15 +174,20 @@ pub async fn get_app_client_references_chunks(
for
(
server_component
,
client_reference_types
)
in
for
(
server_component
,
client_reference_types
)
in
client_references_by_server_component
.into_iter
()
client_references_by_server_component
.into_iter
()
{
{
let
boundary
=
server_component
.boundary_info
()
.await
?
.as_ref
()
.expect
(
"server component must have boundary info"
)
.inner_module
.expect
(
"server component must have inner module"
);
let
parent_chunk_group
=
*
chunk_group_info
let
parent_chunk_group
=
*
chunk_group_info
.get_index_of
(
ChunkGroup
::
Shared
(
ResolvedVc
::
upcast
(
.get_index_of
(
ChunkGroup
::
Shared
(
boundary
))
server_component
.await
?
.module
,
)))
.await
?
;
.await
?
;
let
base_ident
=
server_component
.ident
();
let
base_ident
=
server_component
.ident
();
let
server_path
=
server_component
.
server_
path
()
.owned
()
.await
?
;
let
server_path
=
server_component
.
ident
()
.
path
()
.owned
()
.await
?
;
let
is_layout
=
server_path
.file_stem
()
==
Some
(
"layout"
);
let
is_layout
=
server_path
.file_stem
()
==
Some
(
"layout"
);
let
server_component_path
=
server_path
.value_to_string
()
.await
?
;
let
server_component_path
=
server_path
.value_to_string
()
.await
?
;
...
...
crates/next-core/src/next_client_reference/visit_client_reference.rs
View file @
7ed6339f
...
@@ -21,8 +21,6 @@ use crate::{
...
@@ -21,8 +21,6 @@ use crate::{
CssClientReferenceModule
,
CssClientReferenceModule
,
ecmascript_client_reference
::
ecmascript_client_reference_module
::
EcmascriptClientReferenceModule
,
ecmascript_client_reference
::
ecmascript_client_reference_module
::
EcmascriptClientReferenceModule
,
},
},
next_server_component
::
server_component_module
::
NextServerComponentModule
,
next_server_utility
::
server_utility_module
::
NextServerUtilityModule
,
};
};
#[derive(
#[derive(
...
@@ -39,7 +37,7 @@ use crate::{
...
@@ -39,7 +37,7 @@ use crate::{
Decode,
Decode,
)]
)]
pub
struct
ClientReference
{
pub
struct
ClientReference
{
pub
server_component
:
Option
<
ResolvedVc
<
NextServerComponentModule
>>
,
pub
server_component
:
Option
<
ResolvedVc
<
Box
<
dyn
Module
>
>>
,
pub
ty
:
ClientReferenceType
,
pub
ty
:
ClientReferenceType
,
}
}
...
@@ -65,15 +63,15 @@ pub enum ClientReferenceType {
...
@@ -65,15 +63,15 @@ pub enum ClientReferenceType {
#[derive(Clone,
Debug,
Default)]
#[derive(Clone,
Debug,
Default)]
pub
struct
ClientReferenceGraphResult
{
pub
struct
ClientReferenceGraphResult
{
pub
client_references
:
Vec
<
ClientReference
>
,
pub
client_references
:
Vec
<
ClientReference
>
,
pub
server_component_entries
:
Vec
<
ResolvedVc
<
NextServerComponentModule
>>
,
pub
server_component_entries
:
Vec
<
ResolvedVc
<
Box
<
dyn
Module
>
>>
,
pub
server_utils
:
Vec
<
ResolvedVc
<
NextServerUtilityModule
>>
,
pub
server_utils
:
Vec
<
ResolvedVc
<
Box
<
dyn
Module
>
>>
,
}
}
#[turbo_tasks
::
value(shared)]
#[turbo_tasks
::
value(shared)]
#[derive(Clone,
Debug)]
#[derive(Clone,
Debug)]
pub
struct
ServerEntries
{
pub
struct
ServerEntries
{
pub
server_component_entries
:
Vec
<
ResolvedVc
<
NextServerComponentModule
>>
,
pub
server_component_entries
:
Vec
<
ResolvedVc
<
Box
<
dyn
Module
>
>>
,
pub
server_utils
:
Vec
<
ResolvedVc
<
NextServerUtilityModule
>>
,
pub
server_utils
:
Vec
<
ResolvedVc
<
Box
<
dyn
Module
>
>>
,
}
}
/// For a given RSC entry, finds all server components (i.e. layout segments) and server utils that
/// For a given RSC entry, finds all server components (i.e. layout segments) and server utils that
...
@@ -141,11 +139,8 @@ struct FindServerEntries {
...
@@ -141,11 +139,8 @@ struct FindServerEntries {
#[derive(Clone,
Eq,
PartialEq,
Hash,
Debug,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue)]
#[derive(Clone,
Eq,
PartialEq,
Hash,
Debug,
ValueDebugFormat,
TraceRawVcs,
NonLocalValue)]
enum
FindServerEntriesNode
{
enum
FindServerEntriesNode
{
ClientReference
,
ClientReference
,
ServerComponentEntry
(
ServerComponentEntry
(
ResolvedVc
<
Box
<
dyn
Module
>>
,
Option
<
ReadRef
<
RcStr
>>
),
ResolvedVc
<
NextServerComponentModule
>
,
ServerUtilEntry
(
ResolvedVc
<
Box
<
dyn
Module
>>
,
Option
<
ReadRef
<
RcStr
>>
),
Option
<
ReadRef
<
RcStr
>>
,
),
ServerUtilEntry
(
ResolvedVc
<
NextServerUtilityModule
>
,
Option
<
ReadRef
<
RcStr
>>
),
Internal
(
ResolvedVc
<
Box
<
dyn
Module
>>
,
Option
<
ReadRef
<
RcStr
>>
),
Internal
(
ResolvedVc
<
Box
<
dyn
Module
>>
,
Option
<
ReadRef
<
RcStr
>>
),
}
}
...
@@ -171,9 +166,9 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
...
@@ -171,9 +166,9 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
FindServerEntriesNode
::
ClientReference
=>
{
FindServerEntriesNode
::
ClientReference
=>
{
unreachable!
(
"ClientReference node should not be visited"
)
unreachable!
(
"ClientReference node should not be visited"
)
}
}
FindServerEntriesNode
::
Internal
(
module
,
_
)
=>
**
module
,
FindServerEntriesNode
::
Internal
(
module
,
_
)
FindServerEntriesNode
::
ServerUtilEntry
(
module
,
_
)
=>
Vc
::
upcast
(
**
module
),
|
FindServerEntriesNode
::
ServerUtilEntry
(
module
,
_
)
FindServerEntriesNode
::
ServerComponentEntry
(
module
,
_
)
=>
Vc
::
upcast
(
**
module
)
,
|
FindServerEntriesNode
::
ServerComponentEntry
(
module
,
_
)
=>
**
module
,
};
};
let
emit_spans
=
self
.emit_spans
;
let
emit_spans
=
self
.emit_spans
;
async
move
{
async
move
{
...
@@ -205,19 +200,13 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
...
@@ -205,19 +200,13 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
if
let
Some
(
boundary
)
=
&*
module
.boundary_info
()
.await
?
{
if
let
Some
(
boundary
)
=
&*
module
.boundary_info
()
.await
?
{
if
boundary
.boundary_type
==
boundary_type_server_component
()
{
if
boundary
.boundary_type
==
boundary_type_server_component
()
{
let
sc
=
ResolvedVc
::
try_downcast_type
::
<
NextServerComponentModule
>
(
*
module
)
.expect
(
"server-component boundary must be
\
NextServerComponentModule"
,
);
return
Ok
((
return
Ok
((
FindServerEntriesNode
::
ServerComponentEntry
(
FindServerEntriesNode
::
ServerComponentEntry
(
sc
,
*
module
,
if
emit_spans
{
if
emit_spans
{
// INVALIDATION: we don't need to invalidate when the span
// INVALIDATION: we don't need to invalidate when the span
// name changes
// name changes
Some
(
sc
.ident_string
()
.untracked
()
.await
?
)
Some
(
module
.ident_string
()
.untracked
()
.await
?
)
}
else
{
}
else
{
None
None
},
},
...
@@ -226,14 +215,9 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
...
@@ -226,14 +215,9 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
));
));
}
}
if
boundary
.boundary_type
==
boundary_type_server_utility
()
{
if
boundary
.boundary_type
==
boundary_type_server_utility
()
{
let
su
=
ResolvedVc
::
try_downcast_type
::
<
NextServerUtilityModule
>
(
*
module
)
.expect
(
"server-utility boundary must be NextServerUtilityModule"
,
);
return
Ok
((
return
Ok
((
FindServerEntriesNode
::
ServerUtilEntry
(
FindServerEntriesNode
::
ServerUtilEntry
(
su
,
*
module
,
if
emit_spans
{
if
emit_spans
{
// INVALIDATION: we don't need to invalidate when the span
// INVALIDATION: we don't need to invalidate when the span
// name changes
// name changes
...
...
crates/next-core/src/next_dynamic/dynamic_module.rs
View file @
7ed6339f
...
@@ -76,8 +76,11 @@ impl Module for NextDynamicEntryModule {
...
@@ -76,8 +76,11 @@ impl Module for NextDynamicEntryModule {
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
boundary_info
(
self
:
Vc
<
Self
>
)
->
Vc
<
OptionBoundaryInfo
>
{
fn
boundary_info
(
&
self
)
->
Vc
<
OptionBoundaryInfo
>
{
Vc
::
cell
(
Some
(
BoundaryInfo
::
new
(
boundary_type_dynamic_entry
())))
Vc
::
cell
(
Some
(
BoundaryInfo
::
new
(
boundary_type_dynamic_entry
())
.with_inner_module
(
ResolvedVc
::
upcast
(
self
.module
)),
))
}
}
}
}
...
...
crates/next-core/src/next_manifests/client_reference_manifest.rs
View file @
7ed6339f
...
@@ -13,6 +13,7 @@ use turbo_tasks_fs::{File, FileContent, FileSystemPath};
...
@@ -13,6 +13,7 @@ use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
chunk
::{
ChunkingContext
,
ModuleChunkItemIdExt
,
ModuleId
as
TurbopackModuleId
},
chunk
::{
ChunkingContext
,
ModuleChunkItemIdExt
,
ModuleId
as
TurbopackModuleId
},
module
::
Module
,
module_graph
::
async_module_info
::
AsyncModulesInfo
,
module_graph
::
async_module_info
::
AsyncModulesInfo
,
output
::{
OutputAsset
,
OutputAssets
,
OutputAssetsReference
,
OutputAssetsWithReferenced
},
output
::{
OutputAsset
,
OutputAssets
,
OutputAssetsReference
,
OutputAssetsWithReferenced
},
};
};
...
@@ -406,13 +407,19 @@ async fn build_manifest(
...
@@ -406,13 +407,19 @@ async fn build_manifest(
// per layout segment chunks need to be emitted into the manifest too
// per layout segment chunks need to be emitted into the manifest too
for
(
server_component
,
client_assets
)
in
layout_segment_client_chunks
.iter
()
{
for
(
server_component
,
client_assets
)
in
layout_segment_client_chunks
.iter
()
{
// Use
source_path() to get the original source path
(e.g., page.mdx) instead of
// Use
the original source path from boundary info
(e.g., page.mdx) instead of
//
server_
path() which returns the transformed path (e.g., page.mdx.tsx).
//
ident().
path() which returns the transformed path (e.g., page.mdx.tsx).
// This ensures the manifest key matches what the LoaderTree stores and what
// This ensures the manifest key matches what the LoaderTree stores and what
// the runtime looks up after stripping one extension.
// the runtime looks up after stripping one extension.
let
server_component_name
=
server_component
let
boundary_opt
=
server_component
.boundary_info
()
.await
?
;
.source_path
()
let
boundary
=
boundary_opt
.await
?
.as_ref
()
.expect
(
"server component must have boundary info"
);
let
source_path
=
boundary
.source_path
.as_ref
()
.expect
(
"server component must have source path"
);
let
server_component_name
:
RcStr
=
source_path
.with_extension
(
""
)
.with_extension
(
""
)
.value_to_string
()
.value_to_string
()
.owned
()
.owned
()
...
...
crates/next-core/src/next_server_component/server_component_module.rs
View file @
7ed6339f
...
@@ -93,10 +93,13 @@ impl Module for NextServerComponentModule {
...
@@ -93,10 +93,13 @@ impl Module for NextServerComponentModule {
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
boundary_info
(
&
self
)
->
Vc
<
OptionBoundaryInfo
>
{
fn
boundary_info
(
&
self
)
->
Vc
<
OptionBoundaryInfo
>
{
Vc
::
cell
(
Some
(
BoundaryInfo
::
with_source_path
(
Vc
::
cell
(
Some
(
boundary_type_server_component
(),
BoundaryInfo
::
with_source_path
(
self
.source_path
.clone
(),
boundary_type_server_component
(),
)))
self
.source_path
.clone
(),
)
.with_inner_module
(
ResolvedVc
::
upcast
(
self
.module
)),
))
}
}
}
}
...
...
crates/next-core/src/next_server_utility/server_utility_module.rs
View file @
7ed6339f
...
@@ -73,8 +73,11 @@ impl Module for NextServerUtilityModule {
...
@@ -73,8 +73,11 @@ impl Module for NextServerUtilityModule {
}
}
#[turbo_tasks
::
function]
#[turbo_tasks
::
function]
fn
boundary_info
(
self
:
Vc
<
Self
>
)
->
Vc
<
OptionBoundaryInfo
>
{
fn
boundary_info
(
&
self
)
->
Vc
<
OptionBoundaryInfo
>
{
Vc
::
cell
(
Some
(
BoundaryInfo
::
new
(
boundary_type_server_utility
())))
Vc
::
cell
(
Some
(
BoundaryInfo
::
new
(
boundary_type_server_utility
())
.with_inner_module
(
ResolvedVc
::
upcast
(
self
.module
)),
))
}
}
}
}
...
...
turbopack/crates/turbopack-core/src/boundary.rs
View file @
7ed6339f
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::
ResolvedVc
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
turbo_tasks_fs
::
FileSystemPath
;
use
crate
::
module
::
Module
;
/// Metadata describing a module boundary (e.g., server component, server utility, dynamic entry).
/// Metadata describing a module boundary (e.g., server component, server utility, dynamic entry).
///
///
/// This allows detection of boundary types without downcasting to concrete module types,
/// This allows detection of boundary types without downcasting to concrete module types,
...
@@ -12,6 +15,8 @@ pub struct BoundaryInfo {
...
@@ -12,6 +15,8 @@ pub struct BoundaryInfo {
pub
boundary_type
:
RcStr
,
pub
boundary_type
:
RcStr
,
/// Optional original source path before transformations (e.g., page.mdx before page.mdx.tsx).
/// Optional original source path before transformations (e.g., page.mdx before page.mdx.tsx).
pub
source_path
:
Option
<
FileSystemPath
>
,
pub
source_path
:
Option
<
FileSystemPath
>
,
/// The inner module wrapped by this boundary (e.g., the original module before wrapping).
pub
inner_module
:
Option
<
ResolvedVc
<
Box
<
dyn
Module
>>>
,
}
}
impl
BoundaryInfo
{
impl
BoundaryInfo
{
...
@@ -19,6 +24,7 @@ impl BoundaryInfo {
...
@@ -19,6 +24,7 @@ impl BoundaryInfo {
BoundaryInfo
{
BoundaryInfo
{
boundary_type
,
boundary_type
,
source_path
:
None
,
source_path
:
None
,
inner_module
:
None
,
}
}
}
}
...
@@ -26,8 +32,14 @@ impl BoundaryInfo {
...
@@ -26,8 +32,14 @@ impl BoundaryInfo {
BoundaryInfo
{
BoundaryInfo
{
boundary_type
,
boundary_type
,
source_path
:
Some
(
source_path
),
source_path
:
Some
(
source_path
),
inner_module
:
None
,
}
}
}
}
pub
fn
with_inner_module
(
mut
self
,
inner_module
:
ResolvedVc
<
Box
<
dyn
Module
>>
)
->
Self
{
self
.inner_module
=
Some
(
inner_module
);
self
}
}
}
#[turbo_tasks
::
value(transparent)]
#[turbo_tasks
::
value(transparent)]
...
...
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