@@ -5,7 +5,7 @@ use indexmap::IndexMap;
5
5
use indoc:: writedoc;
6
6
use next_core:: {
7
7
next_manifests:: { ActionLayer , ActionManifestWorkerEntry , ServerReferenceManifest } ,
8
- util:: NextRuntime ,
8
+ util:: { get_asset_prefix_from_pathname , NextRuntime } ,
9
9
} ;
10
10
use next_swc:: server_actions:: parse_server_actions;
11
11
use turbo_tasks:: {
@@ -39,7 +39,8 @@ use turbopack_binding::{
39
39
pub ( crate ) async fn create_server_actions_manifest (
40
40
entry : Vc < Box < dyn EcmascriptChunkPlaceable > > ,
41
41
node_root : Vc < FileSystemPath > ,
42
- app_page_name : & str ,
42
+ pathname : & str ,
43
+ page_name : & str ,
43
44
runtime : NextRuntime ,
44
45
asset_context : Vc < Box < dyn AssetContext > > ,
45
46
chunking_context : Vc < Box < dyn EcmascriptChunkingContext > > ,
@@ -54,7 +55,8 @@ pub(crate) async fn create_server_actions_manifest(
54
55
if !* enable_server_actions. await ? {
55
56
let manifest = build_manifest (
56
57
node_root,
57
- app_page_name,
58
+ pathname,
59
+ page_name,
58
60
runtime,
59
61
ModuleActionMap :: empty ( ) ,
60
62
Default :: default ( ) ,
@@ -64,15 +66,15 @@ pub(crate) async fn create_server_actions_manifest(
64
66
}
65
67
66
68
let actions = get_actions ( Vc :: upcast ( entry) ) ;
67
- let loader =
68
- build_server_actions_loader ( node_root, app_page_name, actions, asset_context) . await ?;
69
+ let loader = build_server_actions_loader ( node_root, page_name, actions, asset_context) . await ?;
69
70
let Some ( evaluable) = Vc :: try_resolve_sidecast :: < Box < dyn EvaluatableAsset > > ( loader) . await ?
70
71
else {
71
72
bail ! ( "loader module must be evaluatable" ) ;
72
73
} ;
73
74
74
75
let loader_id = loader. as_chunk_item ( chunking_context) . id ( ) . to_string ( ) ;
75
- let manifest = build_manifest ( node_root, app_page_name, runtime, actions, loader_id) . await ?;
76
+ let manifest =
77
+ build_manifest ( node_root, pathname, page_name, runtime, actions, loader_id) . await ?;
76
78
Ok ( ( Some ( evaluable) , manifest) )
77
79
}
78
80
@@ -84,7 +86,7 @@ pub(crate) async fn create_server_actions_manifest(
84
86
/// client and present inside the paired manifest.
85
87
async fn build_server_actions_loader (
86
88
node_root : Vc < FileSystemPath > ,
87
- app_page_name : & str ,
89
+ page_name : & str ,
88
90
actions : Vc < ModuleActionMap > ,
89
91
asset_context : Vc < Box < dyn AssetContext > > ,
90
92
) -> Result < Vc < Box < dyn EcmascriptChunkPlaceable > > > {
@@ -111,7 +113,7 @@ async fn build_server_actions_loader(
111
113
}
112
114
write ! ( contents, "}});" ) ?;
113
115
114
- let output_path = node_root. join ( format ! ( "server/app{app_page_name }/actions.js" ) ) ;
116
+ let output_path = node_root. join ( format ! ( "server/app{page_name }/actions.js" ) ) ;
115
117
let file = File :: from ( contents. build ( ) ) ;
116
118
let source = VirtualSource :: new ( output_path, AssetContent :: file ( file. into ( ) ) ) ;
117
119
let module = asset_context. process (
@@ -132,13 +134,15 @@ async fn build_server_actions_loader(
132
134
/// module id which exports a function using that hashed name.
133
135
async fn build_manifest (
134
136
node_root : Vc < FileSystemPath > ,
135
- app_page_name : & str ,
137
+ pathname : & str ,
138
+ page_name : & str ,
136
139
runtime : NextRuntime ,
137
140
actions : Vc < ModuleActionMap > ,
138
141
loader_id : Vc < String > ,
139
142
) -> Result < Vc < Box < dyn OutputAsset > > > {
143
+ let manifest_path_prefix = get_asset_prefix_from_pathname ( pathname) ;
140
144
let manifest_path = node_root. join ( format ! (
141
- "server/app{app_page_name }/page/server-reference-manifest.json" ,
145
+ "server/app{manifest_path_prefix }/page/server-reference-manifest.json" ,
142
146
) ) ;
143
147
let mut manifest = ServerReferenceManifest {
144
148
..Default :: default ( )
@@ -156,12 +160,12 @@ async fn build_manifest(
156
160
for hash in value. keys ( ) {
157
161
let entry = mapping. entry ( hash. clone ( ) ) . or_default ( ) ;
158
162
entry. workers . insert (
159
- format ! ( "app{app_page_name }" ) ,
163
+ format ! ( "app{page_name }" ) ,
160
164
ActionManifestWorkerEntry :: String ( loader_id_value. clone_value ( ) ) ,
161
165
) ;
162
166
entry
163
167
. layer
164
- . insert ( format ! ( "app{app_page_name }" ) , ActionLayer :: Rsc ) ;
168
+ . insert ( format ! ( "app{page_name }" ) , ActionLayer :: Rsc ) ;
165
169
}
166
170
}
167
171
0 commit comments