Skip to content

Commit 6ab737a

Browse files
committed
try bundling react-server-dom-webpack/server
1 parent a5ef8c0 commit 6ab737a

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

packages/vite/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
compiled

packages/vite/build.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
import { build } from '@redwoodjs/framework-tools'
22

3+
import * as esbuild from 'esbuild'
4+
35
await build()
6+
7+
// Bundle react dependencies without poisoned imports
8+
// so that we don't need the react-server condition at runtime.
9+
10+
await esbuild.build({
11+
entryPoints: ['prebundled/react-server-dom-webpack.server.js'],
12+
outdir: 'compiled',
13+
14+
bundle: true,
15+
conditions: ['react-server'],
16+
platform: 'node',
17+
target: ['node20'],
18+
19+
logLevel: 'info',
20+
})

packages/vite/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"files": [
5555
"dist",
5656
"inject",
57-
"cjsWrapper.js"
57+
"cjsWrapper.js",
58+
"compiled"
5859
],
5960
"scripts": {
6061
"build": "tsx build.mts && yarn build:types",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export {
2+
decodeReply,
3+
decodeReplyFromBusboy,
4+
} from 'react-server-dom-webpack/server'

packages/vite/src/rsc/rscRequestHandler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import busboy from 'busboy'
22
import type { Request, Response } from 'express'
3-
import RSDWServer from 'react-server-dom-webpack/server.node.unbundled'
43

4+
import {
5+
decodeReply,
6+
decodeReplyFromBusboy,
7+
// @ts-expect-error todo
8+
} from '../../compiled/react-server-dom-webpack.server'
59
import { hasStatusCode } from '../lib/StatusError.js'
610

711
import { sendRscFlightToStudio } from './rscStudioHandlers.js'
812
import { renderRsc } from './rscWorkerCommunication.js'
913

10-
const { decodeReply, decodeReplyFromBusboy } = RSDWServer
11-
1214
export function createRscRequestHandler() {
1315
// This is mounted at /rw-rsc, so will have /rw-rsc stripped from req.url
1416
return async (req: Request, res: Response, next: () => void) => {

0 commit comments

Comments
 (0)