Skip to content

Commit beb43fc

Browse files
Add rolldown-vite playground (#13333)
1 parent c0f766f commit beb43fc

File tree

11 files changed

+617
-65
lines changed

11 files changed

+617
-65
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
3+
/build
4+
.env
5+
6+
.react-router/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
2+
3+
export function Layout({ children }: { children: React.ReactNode }) {
4+
return (
5+
<html lang="en">
6+
<head>
7+
<meta charSet="utf-8" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
9+
<Meta />
10+
<Links />
11+
</head>
12+
<body>
13+
{children}
14+
<ScrollRestoration />
15+
<Scripts />
16+
</body>
17+
</html>
18+
);
19+
}
20+
21+
export default function App() {
22+
return <Outlet />;
23+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { type RouteConfig, index, route } from "@react-router/dev/routes";
2+
3+
export default [
4+
index("routes/_index.tsx"),
5+
route("products/:id", "routes/product.tsx"),
6+
] satisfies RouteConfig;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Route } from "./+types/_index";
2+
3+
export function loader({ params }: Route.LoaderArgs) {
4+
return { planet: "world", date: new Date(), fn: () => 1 };
5+
}
6+
7+
export default function Index({ loaderData }: Route.ComponentProps) {
8+
return <h1>Hello, {loaderData.planet}!</h1>;
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Route } from "./+types/product";
2+
3+
export function loader({ params }: Route.LoaderArgs) {
4+
return { name: `Super cool product #${params.id}` };
5+
}
6+
7+
export default function Component({ loaderData }: Route.ComponentProps) {
8+
return <h1>{loaderData.name}</h1>;
9+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@playground/framework-rolldown-vite",
3+
"version": "0.0.0",
4+
"private": true,
5+
"sideEffects": false,
6+
"type": "module",
7+
"scripts": {
8+
"build": "cross-env ROLLDOWN_OPTIONS_VALIDATION=loose react-router build",
9+
"dev": "react-router dev",
10+
"start": "react-router-serve ./build/server/index.js",
11+
"typecheck": "react-router typegen && tsc"
12+
},
13+
"dependencies": {
14+
"@react-router/node": "workspace:*",
15+
"@react-router/serve": "workspace:*",
16+
"cross-env": "^7.0.3",
17+
"isbot": "^5.1.11",
18+
"react": "^18.2.0",
19+
"react-dom": "^18.2.0",
20+
"react-router": "workspace:*"
21+
},
22+
"devDependencies": {
23+
"@react-router/dev": "workspace:*",
24+
"@types/react": "^18.2.20",
25+
"@types/react-dom": "^18.2.7",
26+
"typescript": "^5.1.6",
27+
"vite": "npm:[email protected]",
28+
"vite-tsconfig-paths": "^4.2.1"
29+
},
30+
"overrides": {
31+
"vite": "npm:[email protected]"
32+
},
33+
"engines": {
34+
"node": ">=20.0.0"
35+
}
36+
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { Config } from "@react-router/dev/config";
2+
3+
export default {} satisfies Config;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"include": [
3+
"**/*.ts",
4+
"**/*.tsx",
5+
"**/.server/**/*.ts",
6+
"**/.server/**/*.tsx",
7+
"**/.client/**/*.ts",
8+
"**/.client/**/*.tsx",
9+
"./.react-router/types/**/*"
10+
],
11+
"compilerOptions": {
12+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
13+
"types": ["@react-router/node", "vite/client"],
14+
"verbatimModuleSyntax": true,
15+
"esModuleInterop": true,
16+
"jsx": "react-jsx",
17+
"module": "ESNext",
18+
"moduleResolution": "Bundler",
19+
"resolveJsonModule": true,
20+
"target": "ES2022",
21+
"strict": true,
22+
"allowJs": true,
23+
"skipLibCheck": true,
24+
"baseUrl": ".",
25+
"paths": {
26+
"~/*": ["./app/*"]
27+
},
28+
"noEmit": true,
29+
"rootDirs": [".", "./.react-router/types"]
30+
}
31+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { reactRouter } from "@react-router/dev/vite";
2+
import { defineConfig } from "vite";
3+
import tsconfigPaths from "vite-tsconfig-paths";
4+
5+
export default defineConfig({
6+
plugins: [
7+
// @ts-expect-error `dev` depends on Vite 6, Plugin type is mismatched.
8+
reactRouter(),
9+
tsconfigPaths(),
10+
],
11+
});

0 commit comments

Comments
 (0)