@@ -202,15 +202,7 @@ export default function vitePluginRsc(
202
202
clientReferenceMetaMap = sortObject ( clientReferenceMetaMap )
203
203
serverResourcesMetaMap = sortObject ( serverResourcesMetaMap )
204
204
await builder . build ( builder . environments . client ! )
205
-
206
- const assetsManifestCode = `export default ${ serializeValueWithRuntime (
207
- buildAssetsManifest ,
208
- ) } `
209
- const manifestPath = path . join (
210
- builder . environments ! . rsc ! . config . build ! . outDir ! ,
211
- BUILD_ASSETS_MANIFEST_NAME ,
212
- )
213
- fs . writeFileSync ( manifestPath , assetsManifestCode )
205
+ writeAssetsManifest ( [ 'rsc' ] )
214
206
return
215
207
}
216
208
@@ -229,6 +221,22 @@ export default function vitePluginRsc(
229
221
serverResourcesMetaMap = sortObject ( serverResourcesMetaMap )
230
222
await builder . build ( builder . environments . client ! )
231
223
await builder . build ( builder . environments . ssr ! )
224
+ writeAssetsManifest ( [ 'ssr' , 'rsc' ] )
225
+ }
226
+
227
+ function writeAssetsManifest ( environmentNames : string [ ] ) {
228
+ // output client manifest to non-client build directly.
229
+ // this makes server build to be self-contained and deploy-able for cloudflare.
230
+ const assetsManifestCode = `export default ${ serializeValueWithRuntime (
231
+ buildAssetsManifest ,
232
+ ) } `
233
+ for ( const name of environmentNames ) {
234
+ const manifestPath = path . join (
235
+ config . environments [ name ] ! . build . outDir ,
236
+ BUILD_ASSETS_MANIFEST_NAME ,
237
+ )
238
+ fs . writeFileSync ( manifestPath , assetsManifestCode )
239
+ }
232
240
}
233
241
234
242
return [
@@ -752,24 +760,6 @@ export default function vitePluginRsc(
752
760
}
753
761
return
754
762
} ,
755
- writeBundle ( ) {
756
- // TODO: move this to `buildApp`.
757
- // note that we already do this in buildApp for no-ssr case.
758
- if ( this . environment . name === 'ssr' ) {
759
- // output client manifest to non-client build directly.
760
- // this makes server build to be self-contained and deploy-able for cloudflare.
761
- const assetsManifestCode = `export default ${ serializeValueWithRuntime (
762
- buildAssetsManifest ,
763
- ) } `
764
- for ( const name of [ 'ssr' , 'rsc' ] ) {
765
- const manifestPath = path . join (
766
- config . environments [ name ] ! . build . outDir ,
767
- BUILD_ASSETS_MANIFEST_NAME ,
768
- )
769
- fs . writeFileSync ( manifestPath , assetsManifestCode )
770
- }
771
- }
772
- } ,
773
763
} ,
774
764
createVirtualPlugin ( 'vite-rsc/bootstrap-script-content' , function ( ) {
775
765
assert ( this . environment . name !== 'client' )
0 commit comments