Skip to content

Commit b5ae784

Browse files
committed
Merge branch 'release-next'
2 parents ad363e1 + 5dd7c15 commit b5ae784

File tree

79 files changed

+4399
-2690
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4399
-2690
lines changed

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules/
33
pnpm-lock.yaml
44
/docs/api
55
examples/**/dist/
6+
/integration/helpers/vite-plugin-cloudflare-template/worker-configuration.d.ts
67
/playground/
78
/playground-local/
89
packages/**/dist/

Diff for: CHANGELOG.md

+127-80
Large diffs are not rendered by default.

Diff for: integration/action-test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ test.describe("actions", () => {
7474
`,
7575

7676
[`app/routes/${THROWS_REDIRECT}.jsx`]: js`
77-
import { redirect } from "react-router";
78-
import { Form } from "react-router";
77+
import { redirect, Form } from "react-router";
7978
8079
export function action() {
8180
throw redirect("/${REDIRECT_TARGET}")

Diff for: integration/blocking-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test("handles synchronous proceeding correctly", async ({ page }) => {
4040
`,
4141
"app/routes/b.tsx": js`
4242
import * as React from "react";
43-
import { Form, useAction, useBlocker } from "react-router";
43+
import { Form, useBlocker } from "react-router";
4444
export default function Component() {
4545
return (
4646
<div>

Diff for: integration/client-data-test.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ test.describe("Client Data", () => {
335335
}),
336336
"app/routes/parent.child.tsx": js`
337337
import * as React from 'react';
338-
import { json } from "react-router"
339338
import { Await, useLoaderData } from "react-router"
340339
export function loader() {
341340
return {
@@ -685,7 +684,6 @@ test.describe("Client Data", () => {
685684
}),
686685
"app/routes/parent.child.tsx": js`
687686
import * as React from 'react';
688-
import { json } from "react-router";
689687
import { useLoaderData, useRevalidator } from "react-router";
690688
let isFirstCall = true;
691689
export async function loader({ serverLoader }) {
@@ -763,7 +761,7 @@ test.describe("Client Data", () => {
763761
childClientLoaderHydrate: false,
764762
}),
765763
"app/routes/parent.child.tsx": js`
766-
import { ClientLoaderFunctionArgs, useRouteError } from "react-router";
764+
import { useRouteError } from "react-router";
767765
768766
export function loader() {
769767
throw new Error("Broken!")
@@ -1286,7 +1284,6 @@ test.describe("Client Data", () => {
12861284
}),
12871285
"app/routes/parent.child.tsx": js`
12881286
import * as React from 'react';
1289-
import { json } from "react-router";
12901287
import { Form, useRouteError } from "react-router";
12911288
export async function clientAction({ serverAction }) {
12921289
return await serverAction();
@@ -1508,7 +1505,6 @@ test.describe("Client Data", () => {
15081505
}),
15091506
"app/routes/parent.child.tsx": js`
15101507
import * as React from 'react';
1511-
import { json } from "react-router";
15121508
import { Form, useRouteError } from "react-router";
15131509
export async function clientAction({ serverAction }) {
15141510
return await serverAction();

Diff for: integration/error-boundary-test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ test("Allows back-button out of an error boundary after a hard reload", async ({
971971
`,
972972

973973
"app/routes/boom.tsx": js`
974-
import { json } from "react-router";
975974
export function loader() { return boom(); }
976975
export default function() { return <b>my page</b>; }
977976
`,

Diff for: integration/fetch-globals-test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ test.beforeAll(async () => {
1414
fixture = await createFixture({
1515
files: {
1616
"app/routes/_index.tsx": js`
17-
import { json } from "react-router";
1817
import { useLoaderData } from "react-router";
1918
export async function loader() {
2019
const resp = await fetch('https://reqres.in/api/users?page=2');

Diff for: integration/fetcher-test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ test.describe("useFetcher", () => {
2323
fixture = await createFixture({
2424
files: {
2525
"app/routes/resource-route-action-only.ts": js`
26-
import { json } from "react-router";
2726
export function action() {
2827
return new Response("${CHEESESTEAK}");
2928
}

Diff for: integration/fs-routes-test.ts

-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ test.describe("fs-routes", () => {
1919
test.beforeAll(async () => {
2020
fixture = await createFixture({
2121
files: {
22-
"vite.config.js": js`
23-
import { defineConfig } from "vite";
24-
import { reactRouter } from "@react-router/dev/vite";
25-
26-
export default defineConfig({
27-
plugins: [reactRouter()],
28-
});
29-
`,
3022
"app/routes.ts": js`
3123
import { type RouteConfig } from "@react-router/dev/routes";
3224
import { flatRoutes } from "@react-router/fs-routes";

Diff for: integration/helpers/create-fixture.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { createRequestHandler as createExpressHandler } from "@react-router/express";
1919
import { createReadableStreamFromReadable } from "@react-router/node";
2020

21-
import { viteConfig, reactRouterConfig } from "./vite.js";
21+
import { type TemplateName, viteConfig, reactRouterConfig } from "./vite.js";
2222

2323
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
2424
const root = path.join(__dirname, "../..");
@@ -31,6 +31,7 @@ export interface FixtureInit {
3131
spaMode?: boolean;
3232
prerender?: boolean;
3333
port?: number;
34+
templateName?: TemplateName;
3435
}
3536

3637
export type Fixture = Awaited<ReturnType<typeof createFixture>>;
@@ -362,7 +363,7 @@ export async function createFixtureProject(
362363
init: FixtureInit = {},
363364
mode?: ServerMode
364365
): Promise<string> {
365-
let template = "vite-5-template";
366+
let template = init.templateName ?? "vite-5-template";
366367
let integrationTemplateDir = path.resolve(__dirname, template);
367368
let projectName = `rr-${template}-${Math.random().toString(32).slice(2)}`;
368369
let projectDir = path.join(TMP_DIR, projectName);
@@ -424,6 +425,9 @@ function build(projectDir: string, buildStdio?: Writable, mode?: ServerMode) {
424425
env: {
425426
...process.env,
426427
NODE_ENV: mode || ServerMode.Production,
428+
// Ensure build can pass in Rolldown. This can be removed once
429+
// "preserveEntrySignatures" is supported in rolldown-vite.
430+
ROLLDOWN_OPTIONS_VALIDATION: "loose",
427431
},
428432
});
429433

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
3+
/.cache
4+
/build
5+
.env
6+
.react-router
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
2+
3+
export default function App() {
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+
<Outlet />
14+
<ScrollRestoration />
15+
<Scripts />
16+
</body>
17+
</html>
18+
);
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { type RouteConfig } from "@react-router/dev/routes";
2+
import { flatRoutes } from "@react-router/fs-routes";
3+
4+
export default flatRoutes() satisfies RouteConfig;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { MetaFunction } from "react-router";
2+
3+
export const meta: MetaFunction = () => {
4+
return [
5+
{ title: "New React Router App" },
6+
{ name: "description", content: "Welcome to React Router!" },
7+
];
8+
};
9+
10+
export default function Index() {
11+
return (
12+
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
13+
<h1>Welcome to React Router</h1>
14+
</div>
15+
);
16+
}

Diff for: integration/helpers/vite-rolldown-template/env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="@react-router/node" />
2+
/// <reference types="vite/client" />
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "integration-vite-rolldown-template",
3+
"version": "0.0.0",
4+
"private": true,
5+
"sideEffects": false,
6+
"type": "module",
7+
"scripts": {
8+
"dev": "react-router dev",
9+
"build": "cross-env ROLLDOWN_OPTIONS_VALIDATION=loose react-router build",
10+
"start": "react-router-serve ./build/server/index.js",
11+
"typecheck": "react-router typegen && tsc"
12+
},
13+
"dependencies": {
14+
"@react-router/express": "workspace:*",
15+
"@react-router/node": "workspace:*",
16+
"@react-router/serve": "workspace:*",
17+
"@vanilla-extract/css": "^1.10.0",
18+
"@vanilla-extract/vite-plugin": "^3.9.2",
19+
"express": "^4.19.2",
20+
"isbot": "^5.1.11",
21+
"react": "^18.2.0",
22+
"react-dom": "^18.2.0",
23+
"react-router": "workspace:*",
24+
"serialize-javascript": "^6.0.1"
25+
},
26+
"devDependencies": {
27+
"@react-router/dev": "workspace:*",
28+
"@react-router/fs-routes": "workspace:*",
29+
"@react-router/remix-routes-option-adapter": "workspace:*",
30+
"@types/react": "^18.2.20",
31+
"@types/react-dom": "^18.2.7",
32+
"cross-env": "^7.0.3",
33+
"eslint": "^8.38.0",
34+
"typescript": "^5.1.6",
35+
"vite": "npm:[email protected]",
36+
"vite-env-only": "^3.0.1",
37+
"vite-tsconfig-paths": "^4.2.1"
38+
},
39+
"overrides": {
40+
"vite": "npm:[email protected]"
41+
},
42+
"engines": {
43+
"node": ">=20.0.0"
44+
}
45+
}
14.7 KB
Binary file not shown.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"include": ["env.d.ts", "**/*.ts", "**/*.tsx", ".react-router/types/**/*"],
3+
"compilerOptions": {
4+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
5+
"verbatimModuleSyntax": true,
6+
"esModuleInterop": true,
7+
"jsx": "react-jsx",
8+
"module": "ESNext",
9+
"moduleResolution": "Bundler",
10+
"resolveJsonModule": true,
11+
"target": "ES2022",
12+
"strict": true,
13+
"allowJs": true,
14+
"skipLibCheck": true,
15+
"baseUrl": ".",
16+
"paths": {
17+
"~/*": ["./app/*"]
18+
},
19+
"noEmit": true,
20+
"rootDirs": [".", ".react-router/types/"]
21+
}
22+
}
+11
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+
});

Diff for: integration/helpers/vite.ts

+51-7
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,29 @@ export const reactRouterConfig = ({
6161
`;
6262
};
6363

64-
type ViteConfigArgs = {
64+
type ViteConfigServerArgs = {
6565
port: number;
6666
fsAllow?: string[];
67+
};
68+
69+
type ViteConfigBuildArgs = {
70+
assetsInlineLimit?: number;
71+
assetsDir?: string;
72+
};
73+
74+
type ViteConfigBaseArgs = {
6775
envDir?: string;
6876
};
6977

78+
type ViteConfigArgs = (
79+
| ViteConfigServerArgs
80+
| { [K in keyof ViteConfigServerArgs]?: never }
81+
) &
82+
ViteConfigBuildArgs &
83+
ViteConfigBaseArgs;
84+
7085
export const viteConfig = {
71-
server: async (args: ViteConfigArgs) => {
86+
server: async (args: ViteConfigServerArgs) => {
7287
let { port, fsAllow } = args;
7388
let hmrPort = await getPort();
7489
let text = dedent`
@@ -81,21 +96,42 @@ export const viteConfig = {
8196
`;
8297
return text;
8398
},
99+
build: ({ assetsInlineLimit, assetsDir }: ViteConfigBuildArgs = {}) => {
100+
return dedent`
101+
build: {
102+
// Detect rolldown-vite. This should ideally use "rolldownVersion"
103+
// but that's not exported. Once that's available, this
104+
// check should be updated to use it.
105+
rollupOptions: "transformWithOxc" in (await import("vite"))
106+
? {
107+
onwarn(warning, warn) {
108+
// Ignore "The built-in minifier is still under development." warning
109+
if (warning.code === "MINIFY_WARNING") return;
110+
warn(warning);
111+
},
112+
}
113+
: undefined,
114+
assetsInlineLimit: ${assetsInlineLimit ?? "undefined"},
115+
assetsDir: ${assetsDir ? `"${assetsDir}"` : "undefined"},
116+
},
117+
`;
118+
},
84119
basic: async (args: ViteConfigArgs) => {
85120
return dedent`
86121
import { reactRouter } from "@react-router/dev/vite";
87122
import { envOnlyMacros } from "vite-env-only";
88123
import tsconfigPaths from "vite-tsconfig-paths";
89124
90-
export default {
91-
${await viteConfig.server(args)}
125+
export default async () => ({
126+
${args.port ? await viteConfig.server(args) : ""}
127+
${viteConfig.build(args)}
92128
envDir: ${args.envDir ? `"${args.envDir}"` : "undefined"},
93129
plugins: [
94130
reactRouter(),
95131
envOnlyMacros(),
96132
tsconfigPaths()
97133
],
98-
};
134+
});
99135
`;
100136
},
101137
};
@@ -145,14 +181,19 @@ export const EXPRESS_SERVER = (args: {
145181
`;
146182

147183
export type TemplateName =
184+
| "cloudflare-dev-proxy-template"
148185
| "vite-5-template"
149186
| "vite-6-template"
150-
| "cloudflare-dev-proxy-template"
151-
| "vite-plugin-cloudflare-template";
187+
| "vite-plugin-cloudflare-template"
188+
| "vite-rolldown-template";
152189

153190
export const viteMajorTemplates = [
154191
{ templateName: "vite-5-template", templateDisplayName: "Vite 5" },
155192
{ templateName: "vite-6-template", templateDisplayName: "Vite 6" },
193+
{
194+
templateName: "vite-rolldown-template",
195+
templateDisplayName: "Vite Rolldown",
196+
},
156197
] as const satisfies Array<{
157198
templateName: TemplateName;
158199
templateDisplayName: string;
@@ -205,6 +246,9 @@ export const build = ({
205246
...process.env,
206247
...colorEnv,
207248
...env,
249+
// Ensure build can pass in Rolldown. This can be removed once
250+
// "preserveEntrySignatures" is supported in rolldown-vite.
251+
ROLLDOWN_OPTIONS_VALIDATION: "loose",
208252
},
209253
});
210254
};

Diff for: integration/link-test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ test.describe("route module link export", () => {
357357
`,
358358

359359
"app/routes/gists.$username.tsx": js`
360-
import { data, redirect } from "react-router";
361-
import { Link, useLoaderData, useParams } from "react-router";
360+
import { data, redirect, Link, useLoaderData, useParams } from "react-router";
362361
export async function loader({ params }) {
363362
let { username } = params;
364363
if (username === "mjijackson") {

0 commit comments

Comments
 (0)