react-router-hono-server 2.8.0 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/dist/adapters/aws-lambda.d.ts +2 -2
- package/dist/adapters/bun.d.ts +2 -2
- package/dist/adapters/cloudflare.d.ts +2 -2
- package/dist/adapters/node.d.ts +2 -2
- package/dist/dev.js +20 -2
- package/dist/{helpers-BboEKLhp.d.ts → helpers-DZ1r-Y-D.d.ts} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -840,6 +840,7 @@ export default await createHonoServer({
|
|
|
840
840
|
## Pre-rendering
|
|
841
841
|
You should be able to use pre-rendering with this package.
|
|
842
842
|
|
|
843
|
+
### Node and Bun
|
|
843
844
|
> [!TIP]
|
|
844
845
|
> Check this [example](./examples/node/with-pre-render/) to see how to use it.
|
|
845
846
|
|
|
@@ -848,7 +849,7 @@ You should be able to use pre-rendering with this package.
|
|
|
848
849
|
>
|
|
849
850
|
> The file path is fixed to `assets/server-build.js`.
|
|
850
851
|
|
|
851
|
-
Add the
|
|
852
|
+
Add the pre-render option to your `react-router.config.ts`
|
|
852
853
|
|
|
853
854
|
```ts
|
|
854
855
|
import type { Config } from "@react-router/dev/config";
|
|
@@ -859,6 +860,21 @@ export default {
|
|
|
859
860
|
} satisfies Config;
|
|
860
861
|
```
|
|
861
862
|
|
|
863
|
+
### Cloudflare
|
|
864
|
+
> [!TIP]
|
|
865
|
+
> Check this [example](./examples/cloudflare/with-pre-render/) to see how to use it.
|
|
866
|
+
|
|
867
|
+
Add the pre-render option to your `react-router.config.ts`
|
|
868
|
+
|
|
869
|
+
```ts
|
|
870
|
+
import type { Config } from "@react-router/dev/config";
|
|
871
|
+
|
|
872
|
+
export default {
|
|
873
|
+
prerender: ["/"],
|
|
874
|
+
} satisfies Config;
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
|
|
862
878
|
## Migrate from v1
|
|
863
879
|
_You should not expect any breaking changes._
|
|
864
880
|
|
|
@@ -2,8 +2,8 @@ import * as hono_aws_lambda from 'hono/aws-lambda';
|
|
|
2
2
|
import * as hono_types from 'hono/types';
|
|
3
3
|
import { BlankEnv } from 'hono/types';
|
|
4
4
|
import { Env, Hono } from 'hono';
|
|
5
|
-
import { W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-
|
|
6
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
5
|
+
import { W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-DZ1r-Y-D.js';
|
|
6
|
+
export { c as createGetLoadContext } from '../helpers-DZ1r-Y-D.js';
|
|
7
7
|
import 'react-router';
|
|
8
8
|
import 'hono/ws';
|
|
9
9
|
|
package/dist/adapters/bun.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Serve, ServeOptions } from 'bun';
|
|
2
2
|
import { Env } from 'hono';
|
|
3
3
|
import { BlankEnv } from 'hono/types';
|
|
4
|
-
import { a as WithWebsocket, W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-
|
|
5
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
4
|
+
import { a as WithWebsocket, W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-DZ1r-Y-D.js';
|
|
5
|
+
export { c as createGetLoadContext } from '../helpers-DZ1r-Y-D.js';
|
|
6
6
|
import 'react-router';
|
|
7
7
|
import 'hono/ws';
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as hono_types from 'hono/types';
|
|
2
2
|
import { BlankEnv } from 'hono/types';
|
|
3
3
|
import { Env, Hono } from 'hono';
|
|
4
|
-
import { W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-
|
|
5
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
4
|
+
import { W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-DZ1r-Y-D.js';
|
|
5
|
+
export { c as createGetLoadContext } from '../helpers-DZ1r-Y-D.js';
|
|
6
6
|
import 'react-router';
|
|
7
7
|
import 'hono/ws';
|
|
8
8
|
|
package/dist/adapters/node.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { AddressInfo } from 'node:net';
|
|
|
2
2
|
import { ServerType } from '@hono/node-server';
|
|
3
3
|
import { Env, Hono } from 'hono';
|
|
4
4
|
import { BlankEnv } from 'hono/types';
|
|
5
|
-
import { a as WithWebsocket, W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-
|
|
6
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
5
|
+
import { a as WithWebsocket, W as WithoutWebsocket, H as HonoServerOptionsBase } from '../helpers-DZ1r-Y-D.js';
|
|
6
|
+
export { c as createGetLoadContext } from '../helpers-DZ1r-Y-D.js';
|
|
7
7
|
import { ServerOptions, createServer } from 'node:http';
|
|
8
8
|
import { ServerOptions as ServerOptions$2, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
|
|
9
9
|
import { ServerOptions as ServerOptions$1, createServer as createServer$1 } from 'node:https';
|
package/dist/dev.js
CHANGED
|
@@ -5,6 +5,7 @@ import honoDevServer from "@hono/vite-dev-server";
|
|
|
5
5
|
import bunAdapter from "@hono/vite-dev-server/bun";
|
|
6
6
|
import nodeAdapter from "@hono/vite-dev-server/node";
|
|
7
7
|
var virtualModuleId = "\0virtual:react-router-hono-server/server";
|
|
8
|
+
var reactRouterExport = "export {serverManifest as assets, assetsBuildDirectory, basename, entry, future, isSpaMode, publicPath, routes };";
|
|
8
9
|
function reactRouterHonoServer(options = {}) {
|
|
9
10
|
const runtime = options.runtime || "node";
|
|
10
11
|
let pluginConfig;
|
|
@@ -63,6 +64,11 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
63
64
|
}
|
|
64
65
|
return {
|
|
65
66
|
...baseConfig,
|
|
67
|
+
resolve: {
|
|
68
|
+
alias: runtime === "cloudflare" ? {
|
|
69
|
+
"react-dom/server": "react-dom/server.browser"
|
|
70
|
+
} : void 0
|
|
71
|
+
},
|
|
66
72
|
build: {
|
|
67
73
|
// https://vite.dev/config/build-options#build-target
|
|
68
74
|
cssTarget: ["es2020", "edge88", "firefox78", "chrome87", "safari14"],
|
|
@@ -76,12 +82,24 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
76
82
|
return reactRouterBuildFile;
|
|
77
83
|
}
|
|
78
84
|
return "assets/[name]-[hash].js";
|
|
79
|
-
}
|
|
85
|
+
},
|
|
86
|
+
footer: runtime === "cloudflare" ? reactRouterExport : void 0
|
|
80
87
|
}
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
90
|
};
|
|
84
91
|
},
|
|
92
|
+
async closeBundle() {
|
|
93
|
+
if (!pluginConfig || !pluginConfig.isSsrBuild || runtime !== "cloudflare") {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
console.log("Cleaning up server exports...");
|
|
97
|
+
const buildPath = path.join(pluginConfig.rootDirectory, pluginConfig.buildDirectory, "server", "index.js");
|
|
98
|
+
let content = await fs.promises.readFile(buildPath, "utf-8");
|
|
99
|
+
content = content.replace(reactRouterExport, "");
|
|
100
|
+
await fs.promises.writeFile(buildPath, content);
|
|
101
|
+
console.log("\x1B[32mAll done!\x1B[0m");
|
|
102
|
+
},
|
|
85
103
|
async configureServer(server) {
|
|
86
104
|
globalThis.__viteDevServer = server;
|
|
87
105
|
if (!pluginConfig) {
|
|
@@ -105,7 +123,7 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
105
123
|
export: options.dev?.export || "default",
|
|
106
124
|
exclude: [
|
|
107
125
|
new RegExp(
|
|
108
|
-
`^(?=\\/${pluginConfig.appDirectory.replaceAll("/", "")}\\/)((?!.*\\.data(\\?|$)).*\\..*(\\?.*)?$)`
|
|
126
|
+
`^(?=\\/${pluginConfig.appDirectory.replace(/^\/+|\/+$/g, "").replaceAll("/", "\\/")}\\/)((?!.*\\.data(\\?|$)).*\\..*(\\?.*)?$)`
|
|
109
127
|
),
|
|
110
128
|
/\?import(\?.*)?$/,
|
|
111
129
|
/^\/@.+$/,
|
|
@@ -41,7 +41,7 @@ interface HonoServerOptionsBase<E extends Env> {
|
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
43
|
getLoadContext?: (
|
|
44
|
-
c: Context
|
|
44
|
+
c: Context<E>,
|
|
45
45
|
options: {
|
|
46
46
|
build: ServerBuild;
|
|
47
47
|
mode: string;
|
|
@@ -92,7 +92,7 @@ interface WithoutWebsocket<E extends Env> {
|
|
|
92
92
|
/**
|
|
93
93
|
* Helper to create a getLoadContext function fully typed
|
|
94
94
|
*/
|
|
95
|
-
declare function createGetLoadContext(getLoadContext: HonoServerOptionsBase<Env>["getLoadContext"]): ((c: hono.Context, options: {
|
|
95
|
+
declare function createGetLoadContext(getLoadContext: HonoServerOptionsBase<Env>["getLoadContext"]): ((c: hono.Context<Env, any, {}>, options: {
|
|
96
96
|
build: ServerBuild;
|
|
97
97
|
mode: string;
|
|
98
98
|
}) => Promise<react_router.AppLoadContext> | react_router.AppLoadContext) | undefined;
|