File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
packages/plugin-rsc/examples/ssg/src/framework Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { createFromReadableStream } from '@vitejs/plugin-rsc/ssr'
2
2
import React from 'react'
3
3
import { renderToReadableStream } from 'react-dom/server.edge'
4
+ import { prerender } from 'react-dom/static.edge'
4
5
import { injectRSCPayload } from 'rsc-html-stream/server'
5
6
import type { RscPayload } from './shared'
6
7
@@ -18,15 +19,19 @@ export async function renderHtml(
18
19
const root = React . use ( payload ) . root
19
20
return root
20
21
}
21
-
22
22
const bootstrapScriptContent =
23
23
await import . meta. viteRsc . loadBootstrapScriptContent ( 'index' )
24
24
25
- const htmlStream = await renderToReadableStream ( < SsrRoot /> , {
26
- bootstrapScriptContent,
27
- } )
25
+ let htmlStream : ReadableStream < Uint8Array >
28
26
if ( options ?. ssg ) {
29
- await htmlStream . allReady
27
+ const prerenderResult = await prerender ( < SsrRoot /> , {
28
+ bootstrapScriptContent,
29
+ } )
30
+ htmlStream = prerenderResult . prelude
31
+ } else {
32
+ htmlStream = await renderToReadableStream ( < SsrRoot /> , {
33
+ bootstrapScriptContent,
34
+ } )
30
35
}
31
36
32
37
let responseStream : ReadableStream < Uint8Array > = htmlStream
You can’t perform that action at this time.
0 commit comments