Skip to content

Commit 82f45aa

Browse files
authored
chore(rsc): update starter-cf-single example (#1062)
1 parent caf9bf1 commit 82f45aa

File tree

7 files changed

+247
-272
lines changed

7 files changed

+247
-272
lines changed

packages/plugin-rsc/examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"rsc-html-stream": "^0.0.7",
3232
"tailwindcss": "^4.1.18",
3333
"vite": "^7.3.1",
34-
"wrangler": "^4.58.0"
34+
"wrangler": "^4.59.2"
3535
},
3636
"stackblitz": {
3737
"installDependencies": false,

packages/plugin-rsc/examples/react-router/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"react-router": "7.12.0"
1919
},
2020
"devDependencies": {
21-
"@cloudflare/vite-plugin": "^1.20.1",
21+
"@cloudflare/vite-plugin": "^1.21.0",
2222
"@tailwindcss/typography": "^0.5.19",
2323
"@tailwindcss/vite": "^4.1.18",
2424
"@types/react": "^19.2.8",
@@ -27,6 +27,6 @@
2727
"@vitejs/plugin-rsc": "latest",
2828
"tailwindcss": "^4.1.18",
2929
"vite": "^7.3.1",
30-
"wrangler": "^4.58.0"
30+
"wrangler": "^4.59.2"
3131
}
3232
}

packages/plugin-rsc/examples/starter-cf-single/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ https://vite-rsc-starter.hiro18181.workers.dev
44

55
[examples/starter](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc/examples/starter) integrated with [`@cloudflare/vite-plugin`](https://github.com/cloudflare/workers-sdk/tree/main/packages/vite-plugin-cloudflare).
66

7-
The difference from [examples/react-router](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc/examples/react-router) is that this doesn't require two workers.
7+
The difference from [examples/react-router](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc/examples/react-router) is that this doesn't require two Workers.
88

9-
- RSC environment always runs on Cloudflare Workers.
10-
- During development, SSR environment runs as Vite's default Node environment.
11-
- During production, SSR environment build output is directly imported into RSC environment build and both codes run on the same worker.
9+
`rsc` is defined as the main Worker environment while `ssr` is defined as a child environment that is embedded in the same Worker.
1210

13-
Such communication mechanism is enabled via `rsc({ loadModuleDevProxy: true })` plugin option.
11+
```ts
12+
cloudflare({
13+
viteEnvironment: {
14+
name: 'rsc',
15+
// Define `ssr` as a child environment so that it runs in the same Worker as the parent `rsc` environment
16+
childEnvironments: ['ssr'],
17+
},
18+
}),
19+
```
1420

1521
```sh
1622
# run dev server

packages/plugin-rsc/examples/starter-cf-single/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"react-dom": "^19.2.3"
1616
},
1717
"devDependencies": {
18-
"@cloudflare/vite-plugin": "^1.20.1",
18+
"@cloudflare/vite-plugin": "^1.21.0",
1919
"@types/react": "^19.2.8",
2020
"@types/react-dom": "^19.2.3",
2121
"@vitejs/plugin-react": "latest",
2222
"@vitejs/plugin-rsc": "latest",
2323
"rsc-html-stream": "^0.0.7",
2424
"vite": "^7.3.1",
25-
"wrangler": "^4.58.0"
25+
"wrangler": "^4.59.2"
2626
}
2727
}

packages/plugin-rsc/examples/starter-cf-single/vite.config.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,42 @@ import rsc from '@vitejs/plugin-rsc'
44
import { defineConfig } from 'vite'
55

66
export default defineConfig({
7-
clearScreen: false,
8-
build: {
9-
minify: false,
10-
},
117
plugins: [
128
react(),
139
rsc({
14-
entries: {
15-
client: './src/framework/entry.browser.tsx',
16-
ssr: './src/framework/entry.ssr.tsx',
17-
},
1810
serverHandler: false,
19-
loadModuleDevProxy: true,
2011
}),
2112
cloudflare({
22-
configPath: './wrangler.jsonc',
2313
viteEnvironment: {
2414
name: 'rsc',
15+
// Define `ssr` as a child environment so that it runs in the same Worker as the parent `rsc` environment
16+
childEnvironments: ['ssr'],
2517
},
2618
}),
2719
],
2820
environments: {
29-
rsc: {
21+
ssr: {
3022
build: {
23+
// build `ssr` inside `rsc` directory so that
24+
// wrangler can deploy self-contained `dist/rsc`
25+
outDir: './dist/rsc/ssr',
3126
rollupOptions: {
32-
// ensure `default` export only in cloudflare entry output
33-
preserveEntrySignatures: 'exports-only',
27+
input: {
28+
index: './src/framework/entry.ssr.tsx',
29+
},
3430
},
3531
},
3632
optimizeDeps: {
37-
include: ['turbo-stream'],
33+
entries: ['./src/framework/entry.ssr.tsx'],
3834
},
3935
},
40-
ssr: {
41-
keepProcessEnv: false,
36+
client: {
4237
build: {
43-
// build `ssr` inside `rsc` directory so that
44-
// wrangler can deploy self-contained `dist/rsc`
45-
outDir: './dist/rsc/ssr',
46-
},
47-
resolve: {
48-
noExternal: true,
38+
rollupOptions: {
39+
input: {
40+
index: './src/framework/entry.browser.tsx',
41+
},
42+
},
4943
},
5044
},
5145
},

packages/plugin-rsc/examples/starter-cf-single/wrangler.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://www.unpkg.com/wrangler@4.19.1/config-schema.json",
2+
"$schema": "./node_modules/wrangler/config-schema.json",
33
"name": "vite-rsc-starter",
44
"main": "./src/framework/entry.rsc.tsx",
55
"workers_dev": true,

0 commit comments

Comments
 (0)