Skip to content

Commit a3bbc68

Browse files
authored
Merge pull request #9 from forge-42/rr7
Migration from remix to rr7
2 parents cbad207 + 63ef8ca commit a3bbc68

31 files changed

+7659
-11801
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ dist
129129
.yarn/install-state.gz
130130
.pnp.*
131131
/dist
132-
.history
132+
.history
133+
.react-router

package-lock.json

+7,528-11,644
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
"test:cov": "vitest run --coverage",
2626
"postbuild": "npm run check:exports",
2727
"build": "tsup src/index.ts --config tsup.config.ts",
28-
"remix:dev": "npm run dev -w test-apps/remix-vite",
29-
"remix:cjs:dev": "npm run dev -w test-apps/remix-vite-cjs",
28+
"react-router:esm:dev": "npm run dev -w test-apps/react-router-esm",
29+
"react-router:cjs:dev": "npm run dev -w test-apps/react-router-cjs",
3030
"build:dev": "tsup src/index.ts --config tsup.dev.config.ts",
3131
"build:dev:watch": "npm run build:dev -- --watch",
3232
"build:dev:cjs:watch": "npm run build:dev -- --watch",
33-
"dev": "npm-run-all -s build:dev -p remix:dev build:dev:watch",
34-
"dev:cjs": "npm-run-all -s build:dev -p remix:cjs:dev build:dev:cjs:watch",
33+
"dev": "npm-run-all -s build:dev -p react-router:esm:dev build:dev:watch",
34+
"dev:cjs": "npm-run-all -s build:dev -p react-router:cjs:dev build:dev:cjs:watch",
3535
"prepublishOnly": "npm run build",
3636
"check": "biome check .",
3737
"check:fix": "biome check --fix .",
3838
"typecheck": "tsc",
39-
"validate": "npm run check && npm run tsc && npm run test",
39+
"validate": "npm run check && npm run typecheck && npm run test",
4040
"check:exports": "attw --pack .",
4141
"local-release": "changeset version && changeset publish"
4242
},
File renamed without changes.
File renamed without changes.

test-apps/remix-vite-cjs/app/entry.client.tsx test-apps/react-router-cjs/app/entry.client.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* For more information, see https://remix.run/file-conventions/entry.client
55
*/
66

7-
import { RemixBrowser } from "@remix-run/react";
7+
import { HydratedRouter } from "react-router/dom"
88
import { startTransition, StrictMode } from "react";
99
import { hydrateRoot } from "react-dom/client";
1010

1111
startTransition(() => {
1212
hydrateRoot(
1313
document,
1414
<StrictMode>
15-
<RemixBrowser />
15+
<HydratedRouter />
1616
</StrictMode>
1717
);
1818
});

test-apps/remix-vite/app/entry.server.tsx test-apps/react-router-cjs/app/entry.server.tsx

+9-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
*/
66

77
import { PassThrough } from "node:stream";
8-
9-
import type { AppLoadContext, EntryContext } from "@remix-run/node";
10-
import { createReadableStreamFromReadable } from "@remix-run/node";
11-
import { RemixServer } from "@remix-run/react";
8+
import { createReadableStreamFromReadable } from "@react-router/node";
9+
import { type AppLoadContext, type EntryContext, ServerRouter } from "react-router"
1210
import { isbot } from "isbot";
1311
import { renderToPipeableStream } from "react-dom/server";
1412

@@ -18,7 +16,7 @@ export default function handleRequest(
1816
request: Request,
1917
responseStatusCode: number,
2018
responseHeaders: Headers,
21-
remixContext: EntryContext,
19+
reactRouterContext: EntryContext,
2220
// This is ignored so we can keep it in the template for visibility. Feel
2321
// free to delete this parameter in your app if you're not using it!
2422
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -29,30 +27,26 @@ export default function handleRequest(
2927
request,
3028
responseStatusCode,
3129
responseHeaders,
32-
remixContext
30+
reactRouterContext
3331
)
3432
: handleBrowserRequest(
3533
request,
3634
responseStatusCode,
3735
responseHeaders,
38-
remixContext
36+
reactRouterContext
3937
);
4038
}
4139

4240
function handleBotRequest(
4341
request: Request,
4442
responseStatusCode: number,
4543
responseHeaders: Headers,
46-
remixContext: EntryContext
44+
reactRouterContext: EntryContext
4745
) {
4846
return new Promise((resolve, reject) => {
4947
let shellRendered = false;
5048
const { pipe, abort } = renderToPipeableStream(
51-
<RemixServer
52-
context={remixContext}
53-
url={request.url}
54-
abortDelay={ABORT_DELAY}
55-
/>,
49+
<ServerRouter context={reactRouterContext} url={request.url} />,
5650
{
5751
onAllReady() {
5852
shellRendered = true;
@@ -93,16 +87,12 @@ function handleBrowserRequest(
9387
request: Request,
9488
responseStatusCode: number,
9589
responseHeaders: Headers,
96-
remixContext: EntryContext
90+
reactRouterContext: EntryContext
9791
) {
9892
return new Promise((resolve, reject) => {
9993
let shellRendered = false;
10094
const { pipe, abort } = renderToPipeableStream(
101-
<RemixServer
102-
context={remixContext}
103-
url={request.url}
104-
abortDelay={ABORT_DELAY}
105-
/>,
95+
<ServerRouter context={reactRouterContext} url={request.url} />,
10696
{
10797
onShellReady() {
10898
shellRendered = true;

test-apps/remix-vite/app/root.tsx test-apps/react-router-cjs/app/root.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Outlet,
55
Scripts,
66
ScrollRestoration,
7-
} from "@remix-run/react";
7+
} from "react-router";
88

99
export function Layout({ children }: { children: React.ReactNode }) {
1010
return (
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @ts-ignore
2+
import { route } from "@react-router/dev/routes";
3+
4+
export default [
5+
route("/", "./routes/_index.tsx")
6+
]

test-apps/remix-vite-cjs/app/routes/_index.tsx test-apps/react-router-cjs/app/routes/_index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { MetaFunction } from "@remix-run/node";
2-
import { test } from "open-source-stack";
1+
import type { MetaFunction } from "react-router";
32

43
export const meta: MetaFunction = () => {
54
return [{ title: "New Remix App" }, { name: "description", content: "Welcome to Remix!" }];
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "react-router-cjs",
3+
"private": true,
4+
"sideEffects": false,
5+
"type": "commonjs",
6+
"scripts": {
7+
"build": "react-router build",
8+
"dev": "react-router dev",
9+
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
10+
"start": "react-router-serve ./build/server/index.js",
11+
"typecheck": "tsc"
12+
},
13+
"dependencies": {
14+
"@react-router/node": "^7.1.5",
15+
"react-router": "^7.1.5",
16+
"@react-router/serve": "^7.1.5",
17+
"isbot": "^4.1.0",
18+
"react": "^18.2.0",
19+
"react-dom": "^18.2.0",
20+
"open-source-stack": "*"
21+
},
22+
"devDependencies": {
23+
"@react-router/dev": "^7.1.5",
24+
"@types/react": "^18.2.20",
25+
"@types/react-dom": "^18.2.7",
26+
"@types/node": "22.13.1",
27+
"typescript": "^5.1.6",
28+
"vite": "^5.1.0",
29+
"vite-tsconfig-paths": "^4.2.1"
30+
},
31+
"engines": {
32+
"node": ">=22.0.0"
33+
}
34+
}

test-apps/remix-vite-cjs/tsconfig.json test-apps/react-router-cjs/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"compilerOptions": {
1111
"lib": ["DOM", "DOM.Iterable", "ES2022"],
12-
"types": ["@remix-run/node", "vite/client"],
12+
"types": ["@react-router/node", "vite/client"],
1313
"isolatedModules": true,
1414
"esModuleInterop": true,
1515
"jsx": "react-jsx",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @ts-ignore
2+
import { reactRouter } from "@react-router/dev/vite";
3+
import { defineConfig } from "vite";
4+
import tsconfigPaths from "vite-tsconfig-paths";
5+
6+
export default defineConfig({
7+
plugins: [reactRouter(), tsconfigPaths()],
8+
});
File renamed without changes.
File renamed without changes.
File renamed without changes.

test-apps/remix-vite/app/entry.client.tsx test-apps/react-router-esm/app/entry.client.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* For more information, see https://remix.run/file-conventions/entry.client
55
*/
66

7-
import { RemixBrowser } from "@remix-run/react";
7+
import { HydratedRouter } from "react-router/dom"
88
import { startTransition, StrictMode } from "react";
99
import { hydrateRoot } from "react-dom/client";
1010

1111
startTransition(() => {
1212
hydrateRoot(
1313
document,
1414
<StrictMode>
15-
<RemixBrowser />
15+
<HydratedRouter />
1616
</StrictMode>
1717
);
1818
});

test-apps/remix-vite-cjs/app/entry.server.tsx test-apps/react-router-esm/app/entry.server.tsx

+9-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
*/
66

77
import { PassThrough } from "node:stream";
8-
9-
import type { AppLoadContext, EntryContext } from "@remix-run/node";
10-
import { createReadableStreamFromReadable } from "@remix-run/node";
11-
import { RemixServer } from "@remix-run/react";
8+
import { createReadableStreamFromReadable } from "@react-router/node";
9+
import { type AppLoadContext, type EntryContext, ServerRouter } from "react-router"
1210
import { isbot } from "isbot";
1311
import { renderToPipeableStream } from "react-dom/server";
1412

@@ -18,7 +16,7 @@ export default function handleRequest(
1816
request: Request,
1917
responseStatusCode: number,
2018
responseHeaders: Headers,
21-
remixContext: EntryContext,
19+
reactRouterContext: EntryContext,
2220
// This is ignored so we can keep it in the template for visibility. Feel
2321
// free to delete this parameter in your app if you're not using it!
2422
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -29,30 +27,26 @@ export default function handleRequest(
2927
request,
3028
responseStatusCode,
3129
responseHeaders,
32-
remixContext
30+
reactRouterContext
3331
)
3432
: handleBrowserRequest(
3533
request,
3634
responseStatusCode,
3735
responseHeaders,
38-
remixContext
36+
reactRouterContext
3937
);
4038
}
4139

4240
function handleBotRequest(
4341
request: Request,
4442
responseStatusCode: number,
4543
responseHeaders: Headers,
46-
remixContext: EntryContext
44+
reactRouterContext: EntryContext
4745
) {
4846
return new Promise((resolve, reject) => {
4947
let shellRendered = false;
5048
const { pipe, abort } = renderToPipeableStream(
51-
<RemixServer
52-
context={remixContext}
53-
url={request.url}
54-
abortDelay={ABORT_DELAY}
55-
/>,
49+
<ServerRouter context={reactRouterContext} url={request.url} />,
5650
{
5751
onAllReady() {
5852
shellRendered = true;
@@ -93,16 +87,12 @@ function handleBrowserRequest(
9387
request: Request,
9488
responseStatusCode: number,
9589
responseHeaders: Headers,
96-
remixContext: EntryContext
90+
reactRouterContext: EntryContext
9791
) {
9892
return new Promise((resolve, reject) => {
9993
let shellRendered = false;
10094
const { pipe, abort } = renderToPipeableStream(
101-
<RemixServer
102-
context={remixContext}
103-
url={request.url}
104-
abortDelay={ABORT_DELAY}
105-
/>,
95+
<ServerRouter context={reactRouterContext} url={request.url} />,
10696
{
10797
onShellReady() {
10898
shellRendered = true;

test-apps/remix-vite-cjs/app/root.tsx test-apps/react-router-esm/app/root.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Outlet,
55
Scripts,
66
ScrollRestoration,
7-
} from "@remix-run/react";
7+
} from "react-router";
88

99
export function Layout({ children }: { children: React.ReactNode }) {
1010
return (
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { route } from "@react-router/dev/routes";
2+
3+
export default [
4+
route("/", "./routes/_index.tsx")
5+
]

test-apps/remix-vite/app/routes/_index.tsx test-apps/react-router-esm/app/routes/_index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { MetaFunction } from "@remix-run/node";
1+
import type { MetaFunction } from "react-router";
22
// Import and test your package
33
import { test } from "open-source-stack";
44

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "react-router-esm",
3+
"private": true,
4+
"sideEffects": false,
5+
"type": "module",
6+
"scripts": {
7+
"build": "react-router build",
8+
"dev": "react-router dev",
9+
"start": "react-router-serve ./build/server/index.js",
10+
"typecheck": "tsc"
11+
},
12+
"dependencies": {
13+
"@react-router/node": "^7.1.5",
14+
"react-router": "^7.1.5",
15+
"@react-router/serve": "^7.1.5",
16+
"isbot": "^4.1.0",
17+
"react": "^18.2.0",
18+
"react-dom": "^18.2.0",
19+
"open-source-stack": "*"
20+
},
21+
"devDependencies": {
22+
"@react-router/dev": "^7.1.5",
23+
"@types/react": "^18.2.20",
24+
"@types/react-dom": "^18.2.7",
25+
"@types/node": "22.13.1",
26+
"typescript": "^5.1.6",
27+
"vite": "^5.1.0",
28+
"vite-tsconfig-paths": "^4.2.1",
29+
"react-router-devtools": "1.1.4"
30+
},
31+
"engines": {
32+
"node": ">=22.0.0"
33+
}
34+
}

test-apps/remix-vite/tsconfig.json test-apps/react-router-esm/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"compilerOptions": {
1111
"lib": ["DOM", "DOM.Iterable", "ES2022"],
12-
"types": ["@remix-run/node", "vite/client"],
12+
"types": ["@react-router/node", "vite/client"],
1313
"isolatedModules": true,
1414
"esModuleInterop": true,
1515
"jsx": "react-jsx",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @ts-ignore
2+
import { reactRouter } from "@react-router/dev/vite";
3+
import { defineConfig } from "vite";
4+
import tsconfigPaths from "vite-tsconfig-paths";
5+
import { reactRouterDevTools } from "react-router-devtools";
6+
7+
export default defineConfig({
8+
plugins: [ reactRouterDevTools(),reactRouter(), tsconfigPaths()],
9+
});

0 commit comments

Comments
 (0)