@@ -31,7 +31,7 @@ use next_core::{
31
31
get_server_module_options_context, get_server_resolve_options_context,
32
32
get_server_runtime_entries, ServerContextType ,
33
33
} ,
34
- next_server_utility:: NextServerUtilityTransition ,
34
+ next_server_utility:: { NextServerUtilityTransition , NEXT_SERVER_UTILITY_MERGE_TAG } ,
35
35
parse_segment_config_from_source,
36
36
util:: NextRuntime ,
37
37
} ;
@@ -53,14 +53,15 @@ use turbopack::{
53
53
use turbopack_core:: {
54
54
asset:: AssetContent ,
55
55
chunk:: {
56
- availability_info:: AvailabilityInfo , ChunkGroupType , ChunkingContext , ChunkingContextExt ,
56
+ availability_info:: AvailabilityInfo , ChunkGroupResult , ChunkingContext , ChunkingContextExt ,
57
57
EvaluatableAsset , EvaluatableAssets ,
58
58
} ,
59
59
file_source:: FileSource ,
60
60
ident:: AssetIdent ,
61
61
module:: Module ,
62
62
module_graph:: {
63
- chunk_group_info:: ChunkGroup , GraphEntries , ModuleGraph , SingleModuleGraph , VisitedModules ,
63
+ chunk_group_info:: { ChunkGroup , ChunkGroupEntry } ,
64
+ GraphEntries , ModuleGraph , SingleModuleGraph , VisitedModules ,
64
65
} ,
65
66
output:: { OutputAsset , OutputAssets } ,
66
67
raw_output:: RawOutput ,
@@ -826,6 +827,9 @@ impl AppProject {
826
827
// Implements layout segment optimization to compute a graph "chain" for each layout
827
828
// segment
828
829
async move {
830
+ let rsc_entry_chunk_group =
831
+ ChunkGroupEntry :: Entry ( vec ! [ ResolvedVc :: upcast( rsc_entry) ] ) ;
832
+
829
833
let mut graphs = vec ! [ ] ;
830
834
let mut visited_modules = if has_layout_segments {
831
835
let ServerEntries {
@@ -835,15 +839,16 @@ impl AppProject {
835
839
836
840
let graph = SingleModuleGraph :: new_with_entries_visited_intern (
837
841
vec ! [
838
- (
839
- server_utils
842
+ ChunkGroupEntry :: SharedMerged {
843
+ parent: Box :: new( rsc_entry_chunk_group. clone( ) ) ,
844
+ merge_tag: NEXT_SERVER_UTILITY_MERGE_TAG . clone( ) ,
845
+ entries: server_utils
840
846
. iter( )
841
847
. map( async |m| Ok ( ResolvedVc :: upcast( m. await ?. module) ) )
842
848
. try_join( )
843
849
. await ?,
844
- ChunkGroupType :: Entry ,
845
- ) ,
846
- ( client_shared_entries, ChunkGroupType :: Evaluated ) ,
850
+ } ,
851
+ ChunkGroupEntry :: Entry ( client_shared_entries) ,
847
852
] ,
848
853
VisitedModules :: empty ( ) ,
849
854
) ;
@@ -852,7 +857,9 @@ impl AppProject {
852
857
853
858
for module in server_component_entries. iter ( ) {
854
859
let graph = SingleModuleGraph :: new_with_entries_visited_intern (
855
- vec ! [ ( vec![ ResolvedVc :: upcast( * module) ] , ChunkGroupType :: Entry ) ] ,
860
+ // This should really be ChunkGroupEntry::Shared(module.await?.module),
861
+ // but that breaks everything for some reason.
862
+ vec ! [ ChunkGroupEntry :: Entry ( vec![ ResolvedVc :: upcast( * module) ] ) ] ,
856
863
visited_modules,
857
864
) ;
858
865
graphs. push ( graph) ;
@@ -873,15 +880,15 @@ impl AppProject {
873
880
visited_modules
874
881
} else {
875
882
let graph = SingleModuleGraph :: new_with_entries_visited_intern (
876
- vec ! [ ( client_shared_entries , ChunkGroupType :: Evaluated ) ] ,
883
+ vec ! [ ChunkGroupEntry :: Entry ( client_shared_entries ) ] ,
877
884
VisitedModules :: empty ( ) ,
878
885
) ;
879
886
graphs. push ( graph) ;
880
887
VisitedModules :: from_graph ( graph)
881
888
} ;
882
889
883
890
let graph = SingleModuleGraph :: new_with_entries_visited_intern (
884
- vec ! [ ( vec! [ ResolvedVc :: upcast ( rsc_entry ) ] , ChunkGroupType :: Entry ) ] ,
891
+ vec ! [ rsc_entry_chunk_group ] ,
885
892
visited_modules,
886
893
) ;
887
894
graphs. push ( graph) ;
@@ -1664,25 +1671,35 @@ impl AppEndpoint {
1664
1671
1665
1672
Ok ( match runtime {
1666
1673
NextRuntime :: Edge => {
1674
+ let ChunkGroupResult {
1675
+ assets,
1676
+ availability_info,
1677
+ } = * chunking_context
1678
+ . evaluated_chunk_group (
1679
+ server_action_manifest_loader. ident ( ) ,
1680
+ Vc :: cell ( vec ! [ server_action_manifest_loader] ) ,
1681
+ module_graph,
1682
+ Value :: new ( AvailabilityInfo :: Root ) ,
1683
+ )
1684
+ . await ?;
1685
+
1667
1686
let mut evaluatable_assets =
1668
1687
this. app_project . edge_rsc_runtime_entries ( ) . owned ( ) . await ?;
1669
1688
let evaluatable = ResolvedVc :: try_sidecast ( app_entry. rsc_entry )
1670
1689
. context ( "Entry module must be evaluatable" ) ?;
1671
1690
evaluatable_assets. push ( evaluatable) ;
1672
- evaluatable_assets. push ( server_action_manifest_loader) ;
1673
1691
1674
- {
1675
- let _span = tracing:: info_span!( "Server Components" ) ;
1692
+ assets. concatenate (
1676
1693
chunking_context
1677
1694
. evaluated_chunk_group_assets (
1678
1695
app_entry. rsc_entry . ident ( ) ,
1679
1696
Vc :: cell ( evaluatable_assets. clone ( ) ) ,
1680
1697
module_graph,
1681
- Value :: new ( AvailabilityInfo :: Root ) ,
1698
+ Value :: new ( availability_info ) ,
1682
1699
)
1683
1700
. resolve ( )
1684
- . await ?
1685
- }
1701
+ . await ?,
1702
+ )
1686
1703
}
1687
1704
NextRuntime :: NodeJs => {
1688
1705
let mut evaluatable_assets = this. app_project . rsc_runtime_entries ( ) . owned ( ) . await ?;
@@ -1712,10 +1729,7 @@ impl AppEndpoint {
1712
1729
AssetIdent :: from_path ( this. app_project . project ( ) . project_path ( ) )
1713
1730
. with_modifier ( server_utils_modifier ( ) ) ,
1714
1731
// TODO this should be ChunkGroup::Shared
1715
- ChunkGroup :: Entry {
1716
- entries : server_utils,
1717
- ty : ChunkGroupType :: Entry ,
1718
- } ,
1732
+ ChunkGroup :: Entry ( server_utils) ,
1719
1733
module_graph,
1720
1734
Value :: new ( current_availability_info) ,
1721
1735
)
@@ -1751,12 +1765,9 @@ impl AppEndpoint {
1751
1765
. chunk_group (
1752
1766
server_component. ident ( ) ,
1753
1767
// TODO this should be ChunkGroup::Shared
1754
- ChunkGroup :: Entry {
1755
- entries : vec ! [ ResolvedVc :: upcast(
1756
- server_component. await ?. module,
1757
- ) ] ,
1758
- ty : ChunkGroupType :: Entry ,
1759
- } ,
1768
+ ChunkGroup :: Entry ( vec ! [ ResolvedVc :: upcast(
1769
+ server_component. await ?. module,
1770
+ ) ] ) ,
1760
1771
module_graph,
1761
1772
Value :: new ( current_availability_info) ,
1762
1773
)
@@ -1930,19 +1941,15 @@ impl Endpoint for AppEndpoint {
1930
1941
async fn entries ( self : Vc < Self > ) -> Result < Vc < GraphEntries > > {
1931
1942
let this = self . await ?;
1932
1943
Ok ( Vc :: cell ( vec ! [
1933
- (
1934
- vec![ self . app_endpoint_entry( ) . await ?. rsc_entry] ,
1935
- ChunkGroupType :: Entry ,
1936
- ) ,
1937
- (
1944
+ ChunkGroupEntry :: Entry ( vec![ self . app_endpoint_entry( ) . await ?. rsc_entry] ) ,
1945
+ ChunkGroupEntry :: Entry (
1938
1946
this. app_project
1939
1947
. client_runtime_entries( )
1940
1948
. await ?
1941
1949
. iter( )
1942
1950
. copied( )
1943
1951
. map( ResolvedVc :: upcast)
1944
1952
. collect( ) ,
1945
- ChunkGroupType :: Entry ,
1946
1953
) ,
1947
1954
] ) )
1948
1955
}
@@ -1983,10 +1990,9 @@ impl Endpoint for AppEndpoint {
1983
1990
. await ?,
1984
1991
) ;
1985
1992
1986
- Ok ( Vc :: cell ( vec ! [ (
1987
- vec![ server_actions_loader] ,
1988
- ChunkGroupType :: Entry ,
1989
- ) ] ) )
1993
+ Ok ( Vc :: cell ( vec ! [ ChunkGroupEntry :: Entry ( vec![
1994
+ server_actions_loader,
1995
+ ] ) ] ) )
1990
1996
}
1991
1997
}
1992
1998
0 commit comments