Skip to content

Commit 22f6538

Browse files
authored
chore(rsc): simplify react-router example (#763)
1 parent a46bdf4 commit 22f6538

File tree

13 files changed

+28
-770
lines changed

13 files changed

+28
-770
lines changed

.github/renovate.json5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,5 @@
4141
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)
4242

4343
"prettier", // waiting for stable choice on ternaries
44-
45-
// plugin-rsc
46-
"react-router",
47-
"@react-router/dev",
4844
],
4945
}

packages/plugin-rsc/examples/react-router/app/root.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import './styles.css'
22
import { Link, Outlet } from 'react-router'
3-
import { ServerHmr } from '../react-router-vite/server-hmr'
43
import { TestClientState, TestHydrated } from './routes/client'
54
import { DumpError, GlobalNavigationLoadingBar } from './routes/root.client'
65

@@ -35,7 +34,6 @@ export function Layout({ children }: { children: React.ReactNode }) {
3534
</nav>
3635
</header>
3736
<GlobalNavigationLoadingBar />
38-
<ServerHmr />
3937
{children}
4038
</body>
4139
</html>
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
import { type RouteConfig, index, route } from '@react-router/dev/routes'
1+
import type { unstable_RSCRouteConfigEntry } from 'react-router'
22

3-
export default [
4-
index('routes/home.tsx'),
5-
route('about', 'routes/about.tsx'),
6-
] satisfies RouteConfig
3+
export const routes: unstable_RSCRouteConfigEntry[] = [
4+
{
5+
id: 'root',
6+
path: '',
7+
lazy: () => import('./root'),
8+
children: [
9+
{
10+
id: 'home',
11+
index: true,
12+
lazy: () => import('./routes/home'),
13+
},
14+
{
15+
id: 'about',
16+
path: 'about',
17+
lazy: () => import('./routes/about'),
18+
},
19+
],
20+
},
21+
]

packages/plugin-rsc/examples/react-router/cf/vite.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import tailwindcss from '@tailwindcss/vite'
44
import react from '@vitejs/plugin-react'
55
import { defineConfig } from 'vite'
66
// import inspect from 'vite-plugin-inspect'
7-
import { reactRouter } from '../react-router-vite/plugin'
87

98
export default defineConfig({
109
clearScreen: false,
@@ -15,7 +14,6 @@ export default defineConfig({
1514
// inspect(),
1615
tailwindcss(),
1716
react(),
18-
reactRouter(),
1917
rsc({
2018
entries: {
2119
client: './react-router-vite/entry.browser.tsx',

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
},
2020
"devDependencies": {
2121
"@cloudflare/vite-plugin": "^1.11.5",
22-
"@react-router/dev": "7.7.0",
2322
"@tailwindcss/typography": "^0.5.16",
2423
"@tailwindcss/vite": "^4.1.12",
2524
"@types/react": "^19.1.10",

packages/plugin-rsc/examples/react-router/react-router-vite/entry.browser.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
unstable_createCallServer as createCallServer,
1111
unstable_getRSCStream as getRSCStream,
1212
unstable_RSCHydratedRouter as RSCHydratedRouter,
13+
type DataRouter,
1314
type unstable_RSCPayload as RSCServerPayload,
1415
} from 'react-router'
1516

@@ -43,3 +44,9 @@ createFromReadableStream<RSCServerPayload>(getRSCStream()).then((payload) => {
4344
)
4445
})
4546
})
47+
48+
if (import.meta.hot) {
49+
import.meta.hot.on('rsc:update', () => {
50+
;(window as unknown as { __router: DataRouter }).__router.revalidate()
51+
})
52+
}

packages/plugin-rsc/examples/react-router/react-router-vite/entry.rsc.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
renderToReadableStream,
88
} from '@vitejs/plugin-rsc/rsc'
99
import { unstable_matchRSCServerRequest as matchRSCServerRequest } from 'react-router'
10-
11-
import routes from 'virtual:react-router-routes'
10+
import { routes } from '../app/routes'
1211

1312
export function fetchServer(request: Request) {
1413
return matchRSCServerRequest({

packages/plugin-rsc/examples/react-router/react-router-vite/plugin.ts

Lines changed: 0 additions & 123 deletions
This file was deleted.

packages/plugin-rsc/examples/react-router/react-router-vite/server-hmr.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
/// <reference types="vite/client" />
22
/// <reference types="@vitejs/plugin-rsc/types" />
3-
4-
declare module 'virtual:react-router-routes' {
5-
const routes: any
6-
export default routes
7-
}

0 commit comments

Comments
 (0)