react-router-hono-server 0.3.0 → 0.5.0

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/dist/dev.mjs CHANGED
@@ -18,6 +18,7 @@ function p(r) {
18
18
  `/${e.appDirectory}/**/.*/**`,
19
19
  /^\/@.+$/,
20
20
  /^\/node_modules\/.*/,
21
+ /\?import$/,
21
22
  ...e.exclude
22
23
  ]
23
24
  });
package/dist/node.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as hono_types from 'hono/types';
2
2
  import { BlankEnv } from 'hono/types';
3
+ import { AddressInfo } from 'node:net';
3
4
  import { AppLoadContext } from '@remix-run/node';
4
5
  import { Env, Hono, Context } from 'hono';
5
6
  import { HonoOptions } from 'hono/hono-base';
@@ -21,7 +22,7 @@ type HonoServerOptions<E extends Env = BlankEnv> = {
21
22
  /**
22
23
  * The directory where the server build files are located (defined in vite.config)
23
24
  *
24
- * Defaults to `build/server`
25
+ * Defaults to `build`
25
26
  *
26
27
  * See https://remix.run/docs/en/main/file-conventions/vite-config#builddirectory
27
28
  */
@@ -69,9 +70,7 @@ type HonoServerOptions<E extends Env = BlankEnv> = {
69
70
  *
70
71
  * Defaults log the port
71
72
  */
72
- listeningListener?: (info: {
73
- port: number;
74
- }) => void;
73
+ listeningListener?: (info: AddressInfo) => void;
75
74
  /**
76
75
  * Hono constructor options
77
76
  *
package/dist/node.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  // src/node.ts
2
2
  import a from "node:path";
3
- import f from "node:url";
4
- import { serve as g } from "@hono/node-server";
5
- import { serveStatic as d } from "@hono/node-server/serve-static";
6
- import { Hono as E } from "hono";
7
- import { logger as x } from "hono/logger";
8
- import { remix as b } from "remix-hono/handler";
3
+ import E from "node:url";
4
+ import { serve as x } from "@hono/node-server";
5
+ import { serveStatic as u } from "@hono/node-server/serve-static";
6
+ import { Hono as h } from "hono";
7
+ import { logger as y } from "hono/logger";
8
+ import { remix as L } from "remix-hono/handler";
9
9
 
10
10
  // src/dev-build.ts
11
- var c = process.env.NODE_ENV === "production" ? void 0 : await import("vite").then(
11
+ var f = process.env.NODE_ENV === "production" ? void 0 : await import("vite").then(
12
12
  (o) => o.createServer({
13
13
  server: { middlewareMode: !0 },
14
14
  appType: "custom"
15
15
  })
16
16
  );
17
- async function p() {
18
- return c?.ssrLoadModule("virtual:remix/server-build");
17
+ async function d() {
18
+ return f?.ssrLoadModule("virtual:remix/server-build");
19
19
  }
20
20
 
21
21
  // src/middleware.ts
22
- import { createMiddleware as v } from "hono/factory";
22
+ import { createMiddleware as g } from "hono/factory";
23
23
  function i(o) {
24
- return v(async (e, t) => {
24
+ return g(async (e, t) => {
25
25
  if (!e.req.path.match(/\.[a-zA-Z0-9]+$/) || e.req.path.endsWith(".data"))
26
26
  return t();
27
27
  await t(), e.res.ok && e.res.headers.set("cache-control", `public, max-age=${o}`);
@@ -29,10 +29,10 @@ function i(o) {
29
29
  }
30
30
 
31
31
  // src/node.ts
32
- var L = {
32
+ var O = {
33
33
  defaultLogger: !0,
34
34
  port: Number(process.env.PORT) || 3e3,
35
- buildDirectory: "build/server",
35
+ buildDirectory: "build",
36
36
  serverBuildFile: "index.js",
37
37
  assetsDir: "assets",
38
38
  listeningListener: (o) => {
@@ -41,32 +41,30 @@ var L = {
41
41
  };
42
42
  async function M(o = {}) {
43
43
  let e = {
44
- ...L,
44
+ ...O,
45
45
  ...o,
46
46
  defaultLogger: o.defaultLogger ?? !0
47
- }, t = process.env.NODE_ENV === "test" ? "development" : process.env.NODE_ENV, n = t === "production", r = new E(e.honoOptions);
47
+ }, t = process.env.NODE_ENV === "test" ? "development" : process.env.NODE_ENV, n = t === "production", r = new h(e.honoOptions), l = `./${e.buildDirectory}/server`, s = `./${e.buildDirectory}/client`;
48
48
  return r.use(
49
49
  `/${e.assetsDir}/*`,
50
50
  i(60 * 60 * 24 * 365),
51
51
  // 1 year
52
- d({ root: "./build/client" })
53
- ), r.use("*", i(60 * 60), d({ root: n ? "./build/client" : "./public" })), e.defaultLogger && r.use("*", x()), e.configure && await e.configure(r), r.use(async (u, l) => {
54
- let s = n ? await import(
52
+ u({ root: s })
53
+ ), r.use("*", i(60 * 60), u({ root: n ? s : "./public" })), e.defaultLogger && r.use("*", y()), e.configure && await e.configure(r), r.use(async (m, c) => {
54
+ let p = n ? await import(
55
55
  /* @vite-ignore */
56
- f.pathToFileURL(
57
- a.resolve(
58
- a.join(process.cwd(), `./${e.buildDirectory}/${e.serverBuildFile}`)
59
- )
56
+ E.pathToFileURL(
57
+ a.resolve(a.join(process.cwd(), `${l}/${e.serverBuildFile}`))
60
58
  ).toString()
61
- ) : await p();
62
- return b({
63
- build: s,
59
+ ) : await d();
60
+ return L({
61
+ build: p,
64
62
  mode: t,
65
- getLoadContext(m) {
66
- return e.getLoadContext ? e.getLoadContext(m, { build: s }) : {};
63
+ getLoadContext(v) {
64
+ return e.getLoadContext ? e.getLoadContext(v, { build: p }) : {};
67
65
  }
68
- })(u, l);
69
- }), n && g(
66
+ })(m, c);
67
+ }), n && x(
70
68
  {
71
69
  ...r,
72
70
  port: e.port
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-hono-server",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "This package includes helper function to create an Hono app in your entry.server.tsx file. It allows you to customize your server.",
5
5
  "exports": {
6
6
  "./node": {
@@ -29,7 +29,7 @@
29
29
  "test": "vitest run",
30
30
  "test:cov": "vitest run --coverage",
31
31
  "build": "tsup src/node.ts src/dev.ts src/middlewares.ts --dts --format esm --outDir dist --clean --minifyIdentifiers --minifySyntax --external '../build/server/index.js'",
32
- "remix:dev": "npm run dev -w remix-stable",
32
+ "remix:dev": "npm run dev -w remix-unstable",
33
33
  "build:dev": "tsup src/node.ts src/dev.ts src/middlewares.ts --dts --format esm --outDir dist --external '../build/server/index.js'",
34
34
  "build:dev:watch": "npm run build:dev -- --watch",
35
35
  "dev": "npm-run-all -s build:dev -p remix:dev build:dev:watch",