From a66602babbd96299c85bf54700798acd699c82b0 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Wed, 9 Oct 2024 13:36:37 +0200 Subject: [PATCH 1/3] Support for react-router v7 --- src/dev-build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev-build.ts b/src/dev-build.ts index 1b8ac05..5bd4b0b 100644 --- a/src/dev-build.ts +++ b/src/dev-build.ts @@ -14,5 +14,5 @@ const viteDevServer = * @returns The server build */ export async function importDevBuild() { - return viteDevServer?.ssrLoadModule("virtual:remix/server-build"); + return viteDevServer?.ssrLoadModule("virtual:react-router/server-build"); } From 9a899704b04b3bf0e81339a2eb61f238872f2d2b Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Wed, 9 Oct 2024 13:41:48 +0200 Subject: [PATCH 2/3] more changes --- .gitignore | 3 ++- package-lock.json | 55 +++++++++++++++++++++++++++++++++++++++++------ package.json | 3 ++- src/node.ts | 2 +- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 2d15ca5..962a7a1 100644 --- a/.gitignore +++ b/.gitignore @@ -128,4 +128,5 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* -/dist \ No newline at end of file +/dist +.history \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0a66174..edea3e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,12 +20,12 @@ }, "devDependencies": { "@biomejs/biome": "^1.8.3", - "@remix-run/node": "^2.11.1", "@types/node": "^20.12.7", "@vitest/coverage-v8": "^1.5.2", "happy-dom": "^14.7.1", "lefthook": "^1.7.2", "npm-run-all": "^4.1.5", + "react-router": "^7.0.0-pre.0", "tsup": "^8.0.2", "typescript": "^5.4.5", "vitest": "^1.5.2" @@ -2502,6 +2502,20 @@ } } }, + "node_modules/@remix-run/react/node_modules/react-router": { + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.26.2.tgz", + "integrity": "sha512-tvN1iuT03kHgOFnLPfLJ8V95eijteveqdOSk+srqfePtQvqCExB8eHOYnlilbOcyJyKnYkr1vJvf7YqotAJu1A==", + "dependencies": { + "@remix-run/router": "1.19.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, "node_modules/@remix-run/router": { "version": "1.19.2", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.19.2.tgz", @@ -11178,17 +11192,30 @@ } }, "node_modules/react-router": { - "version": "6.26.2", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.26.2.tgz", - "integrity": "sha512-tvN1iuT03kHgOFnLPfLJ8V95eijteveqdOSk+srqfePtQvqCExB8eHOYnlilbOcyJyKnYkr1vJvf7YqotAJu1A==", + "version": "7.0.0-pre.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.0.0-pre.0.tgz", + "integrity": "sha512-1XbOUjY2LifGmcELxjvQPhCkAZ8dzzV/0Re0pCy3y+fXJePRxTKdU5Q0kyQx5QZpLVwACtKDX9NkpA02GFZr6Q==", + "dev": true, "dependencies": { - "@remix-run/router": "1.19.2" + "@types/cookie": "^0.6.0", + "@web3-storage/multipart-parser": "^1.0.0", + "cookie": "^0.6.0", + "react-router": "7.0.0-pre.0", + "set-cookie-parser": "^2.6.0", + "source-map": "^0.7.3", + "turbo-stream": "2.4.0" }, "engines": { - "node": ">=14.0.0" + "node": ">=18.0.0" }, "peerDependencies": { - "react": ">=16.8" + "react": ">=18", + "react-dom": ">=18" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } } }, "node_modules/react-router-dom": { @@ -11207,6 +11234,20 @@ "react-dom": ">=16.8" } }, + "node_modules/react-router-dom/node_modules/react-router": { + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.26.2.tgz", + "integrity": "sha512-tvN1iuT03kHgOFnLPfLJ8V95eijteveqdOSk+srqfePtQvqCExB8eHOYnlilbOcyJyKnYkr1vJvf7YqotAJu1A==", + "dependencies": { + "@remix-run/router": "1.19.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, "node_modules/react-router-hono-server": { "resolved": "", "link": true diff --git a/package.json b/package.json index add3210..749e61a 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ }, "devDependencies": { "@biomejs/biome": "^1.8.3", - "@remix-run/node": "^2.11.1", + "react-router": "^7.0.0-pre.0", "@types/node": "^20.12.7", "@vitest/coverage-v8": "^1.5.2", "happy-dom": "^14.7.1", @@ -71,6 +71,7 @@ }, "peerDependencies": { "@remix-run/node": "^2.0.0", + "react-router": "^7.0.0-pre.0", "remix-hono": "^0.0.16", "hono": "^4.5.3", "vite": "^5.0.0" diff --git a/src/node.ts b/src/node.ts index 9f728c2..28ea860 100644 --- a/src/node.ts +++ b/src/node.ts @@ -2,11 +2,11 @@ import path from "node:path"; import url from "node:url"; import { serve } from "@hono/node-server"; import { serveStatic } from "@hono/node-server/serve-static"; -import type { AppLoadContext, ServerBuild } from "@remix-run/node"; import { type Context, type Env, Hono } from "hono"; import type { HonoOptions } from "hono/hono-base"; import { logger } from "hono/logger"; import type { BlankEnv } from "hono/types"; +import type { AppLoadContext, ServerBuild } from "react-router"; import { type RemixMiddlewareOptions, remix } from "remix-hono/handler"; import { importDevBuild } from "./dev-build"; import { cache } from "./middleware"; From e8bde0994c214ccb19eb15dc682b24d7889c53b7 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Wed, 9 Oct 2024 13:48:06 +0200 Subject: [PATCH 3/3] more changes --- src/node.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/node.ts b/src/node.ts index 28ea860..80f087a 100644 --- a/src/node.ts +++ b/src/node.ts @@ -165,13 +165,16 @@ export async function createHonoServer(options: HonoSe ) as ServerBuild; return remix({ - build, - mode, + // biome-ignore lint/suspicious/noExplicitAny: temp + build: build as any, + // biome-ignore lint/suspicious/noExplicitAny: temp + mode: mode as any, getLoadContext(c) { if (!mergedOptions.getLoadContext) { return {}; } - return mergedOptions.getLoadContext(c, { build }); + // biome-ignore lint/suspicious/noExplicitAny: temp + return mergedOptions.getLoadContext(c, { build: build as any }); }, })(c, next); });