1
1
import path from 'node:path'
2
2
3
- import type { default as RSDWClientModule } from 'react-server-dom-webpack/client.edge'
4
- import type { default as RSDWServerModule } from 'react-server-dom-webpack/server.edge'
5
-
6
3
import { getPaths } from '@redwoodjs/project-config'
7
4
8
5
import { moduleMap } from './ssrModuleMap.js'
9
- import { importRsdwClient , importReact } from './utils.js'
6
+ import { importRsdwClient , importRsdwServer , importReact } from './utils.js'
10
7
import { makeFilePath } from './utils.js'
11
8
12
- type RSDWClientType = typeof RSDWClientModule
13
- type RSDWServerType = typeof RSDWServerModule
14
-
15
9
async function getEntries ( ) {
16
10
const entriesPath = getPaths ( ) . web . distRscEntries
17
11
const entries = await import ( makeFilePath ( entriesPath ) )
@@ -110,17 +104,7 @@ export async function renderRoutesSsr(pathname: string) {
110
104
)
111
105
112
106
const { createElement } = await importReact ( )
113
-
114
- // We need to do this weird import dance because we need to import a version
115
- // of react-server-dom-webpack/server.edge that has been built with the
116
- // `react-server` condition. If we just did a regular import, we'd get the
117
- // generic version in node_modules, and it'd throw an error about not being
118
- // run in an environment with the `react-server` condition.
119
- const dynamicImport = ''
120
- const { renderToReadableStream } : RSDWServerType = await import (
121
- /* @vite -ignore */
122
- dynamicImport + 'react-server-dom-webpack/server.edge'
123
- )
107
+ const { renderToReadableStream } = await importRsdwServer ( )
124
108
125
109
console . log ( 'clientSsr.ts right before renderToReadableStream' )
126
110
// We're in clientSsr.ts, but we're supposed to be pretending we're in the
@@ -132,7 +116,7 @@ export async function renderRoutesSsr(pathname: string) {
132
116
// react-server-dom-webpack/client.edge that uses the same bundled version
133
117
// of React as all the client components. Also see comment in
134
118
// streamHelpers.ts about the rd-server import for some more context
135
- const { createFromReadableStream } : RSDWClientType = await importRsdwClient ( )
119
+ const { createFromReadableStream } = await importRsdwClient ( )
136
120
137
121
// Here we use `createFromReadableStream`, which is equivalent to
138
122
// `createFromFetch` as used in the browser
0 commit comments