react-router-hono-server 0.0.2 → 0.0.3

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 CHANGED
@@ -31,7 +31,7 @@ Install the following npm package. NOTE: This is not a dev dependency, as it
31
31
  creates the Hono server used in production.
32
32
 
33
33
  ```bash
34
- npm install hono remix-hono react-router-hono-server
34
+ npm install react-router-hono-server
35
35
  ```
36
36
 
37
37
  ## Configuration
@@ -0,0 +1,13 @@
1
+ // src/middlewares.ts
2
+ import { createMiddleware as t } from "hono/factory";
3
+ function n(a) {
4
+ return t(async (e, r) => {
5
+ if (!e.req.path.match(/\.[a-zA-Z0-9]+$/) || e.req.path.endsWith(".data"))
6
+ return r();
7
+ await r(), e.res.ok && e.res.headers.set("cache-control", `public, max-age=${a}`);
8
+ });
9
+ }
10
+
11
+ export {
12
+ n as a
13
+ };
package/dist/dev.mjs CHANGED
@@ -1 +1,27 @@
1
- import t from"@hono/vite-dev-server";var o={entry:"app/entry.server.tsx",exportName:"server",appDirectory:"app",exclude:[]};function p(r){let e={...o,...r};return t({injectClientScript:!1,entry:e.entry,export:e.exportName,exclude:[`/${e.appDirectory}/**`,/^\/@.+$/,/^\/node_modules\/.*/,...e.exclude]})}export{p as devServer};
1
+ // src/dev.ts
2
+ import t from "@hono/vite-dev-server";
3
+ var o = {
4
+ entry: "app/entry.server.tsx",
5
+ exportName: "server",
6
+ appDirectory: "app",
7
+ exclude: []
8
+ };
9
+ function p(r) {
10
+ let e = { ...o, ...r };
11
+ return t({
12
+ injectClientScript: !1,
13
+ entry: e.entry,
14
+ // The file path of your server.
15
+ export: e.exportName,
16
+ exclude: [
17
+ `/${e.appDirectory}/**/*`,
18
+ `/${e.appDirectory}/**/.*/**`,
19
+ /^\/@.+$/,
20
+ /^\/node_modules\/.*/,
21
+ ...e.exclude
22
+ ]
23
+ });
24
+ }
25
+ export {
26
+ p as devServer
27
+ };
@@ -1 +1,6 @@
1
- import{a}from"./chunk-4CKI2DYM.mjs";export{a as cache};
1
+ import {
2
+ a
3
+ } from "./chunk-GCTZCGY2.mjs";
4
+ export {
5
+ a as cache
6
+ };
package/dist/node.mjs CHANGED
@@ -1 +1,73 @@
1
- import{a as i}from"./chunk-4CKI2DYM.mjs";import d from"node:path";import v from"node:url";import{serve as g}from"@hono/node-server";import{serveStatic as u}from"@hono/node-server/serve-static";import{Hono as f}from"hono";import{logger as x}from"hono/logger";import{remix as L}from"remix-hono/handler";var c=process.env.NODE_ENV==="production"?void 0:await import("vite").then(o=>o.createServer({server:{middlewareMode:!0},appType:"custom"}));async function p(){return c?.ssrLoadModule("virtual:remix/server-build")}var b={defaultLogger:!0,port:Number(process.env.PORT)||3e3,buildDirectory:"build/server",serverBuildFile:"index.js",assetsDir:"assets",listeningListener:o=>{console.log(`\u{1F680} Server started on port ${o.port}`)}};async function M(o={}){let e={...b,...o,defaultLogger:o.defaultLogger??!0},n=process.env.NODE_ENV==="test"?"development":process.env.NODE_ENV,t=n==="production",r=new f;return r.use(`/${e.assetsDir}/*`,i(60*60*24*365),u({root:"./build/client"})),r.use("*",i(60*60),u({root:t?"./build/client":"./public"})),e.defaultLogger&&r.use("*",x()),e.configure&&await e.configure(r),r.use(async(l,a)=>{let s=t?await import(v.pathToFileURL(d.resolve(d.join(process.cwd(),`./${e.buildDirectory}/${e.serverBuildFile}`))).toString()):await p();return L({build:s,mode:n,getLoadContext(m){return e.getLoadContext?e.getLoadContext(m,{build:s}):{}}})(l,a)}),t&&g({...r,port:e.port},e.listeningListener),r}export{M as createHonoServer};
1
+ import {
2
+ a as i
3
+ } from "./chunk-GCTZCGY2.mjs";
4
+
5
+ // src/node.ts
6
+ import d from "node:path";
7
+ import v from "node:url";
8
+ import { serve as g } from "@hono/node-server";
9
+ import { serveStatic as u } from "@hono/node-server/serve-static";
10
+ import { Hono as f } from "hono";
11
+ import { logger as x } from "hono/logger";
12
+ import { remix as L } from "remix-hono/handler";
13
+
14
+ // src/dev-build.ts
15
+ var c = process.env.NODE_ENV === "production" ? void 0 : await import("vite").then(
16
+ (o) => o.createServer({
17
+ server: { middlewareMode: !0 },
18
+ appType: "custom"
19
+ })
20
+ );
21
+ async function p() {
22
+ return c?.ssrLoadModule("virtual:remix/server-build");
23
+ }
24
+
25
+ // src/node.ts
26
+ var b = {
27
+ defaultLogger: !0,
28
+ port: Number(process.env.PORT) || 3e3,
29
+ buildDirectory: "build/server",
30
+ serverBuildFile: "index.js",
31
+ assetsDir: "assets",
32
+ listeningListener: (o) => {
33
+ console.log(`\u{1F680} Server started on port ${o.port}`);
34
+ }
35
+ };
36
+ async function M(o = {}) {
37
+ let e = {
38
+ ...b,
39
+ ...o,
40
+ defaultLogger: o.defaultLogger ?? !0
41
+ }, n = process.env.NODE_ENV === "test" ? "development" : process.env.NODE_ENV, t = n === "production", r = new f();
42
+ return r.use(
43
+ `/${e.assetsDir}/*`,
44
+ i(60 * 60 * 24 * 365),
45
+ // 1 year
46
+ u({ root: "./build/client" })
47
+ ), r.use("*", i(60 * 60), u({ root: t ? "./build/client" : "./public" })), e.defaultLogger && r.use("*", x()), e.configure && await e.configure(r), r.use(async (l, a) => {
48
+ let s = t ? await import(
49
+ /* @vite-ignore */
50
+ v.pathToFileURL(
51
+ d.resolve(
52
+ d.join(process.cwd(), `./${e.buildDirectory}/${e.serverBuildFile}`)
53
+ )
54
+ ).toString()
55
+ ) : await p();
56
+ return L({
57
+ build: s,
58
+ mode: n,
59
+ getLoadContext(m) {
60
+ return e.getLoadContext ? e.getLoadContext(m, { build: s }) : {};
61
+ }
62
+ })(l, a);
63
+ }), t && g(
64
+ {
65
+ ...r,
66
+ port: e.port
67
+ },
68
+ e.listeningListener
69
+ ), r;
70
+ }
71
+ export {
72
+ M as createHonoServer
73
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-hono-server",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
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": {
@@ -28,8 +28,8 @@
28
28
  "scripts": {
29
29
  "test": "vitest run",
30
30
  "test:cov": "vitest run --coverage",
31
- "build": "tsup src/node.ts src/dev.ts src/middlewares.ts --dts --format esm --outDir dist --minify --clean --external '../build/server/index.js'",
32
- "remix:dev": "npm run dev -w example",
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",
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",
@@ -49,18 +49,17 @@
49
49
  "url": "https://github.com/rphlmr/react-router-hono-server/issues"
50
50
  },
51
51
  "files": ["dist"],
52
- "workspaces": [".", "example"],
52
+ "workspaces": [".", "examples/*"],
53
53
  "homepage": "https://github.com/rphlmr/react-router-hono-server#readme",
54
54
  "dependencies": {
55
55
  "@hono/node-server": "^1.12.0",
56
56
  "@hono/vite-dev-server": "^0.13.1",
57
- "@remix-run/node": "^2.11.0",
58
57
  "hono": "^4.5.3",
59
- "remix-hono": "^0.0.16",
60
- "vite": "^5.3.5"
58
+ "remix-hono": "^0.0.16"
61
59
  },
62
60
  "devDependencies": {
63
61
  "@biomejs/biome": "^1.8.3",
62
+ "@remix-run/node": "^2.11.1",
64
63
  "@types/node": "^20.12.7",
65
64
  "@vitest/coverage-v8": "^1.5.2",
66
65
  "happy-dom": "^14.7.1",
@@ -70,6 +69,12 @@
70
69
  "typescript": "^5.4.5",
71
70
  "vitest": "^1.5.2"
72
71
  },
72
+ "peerDependencies": {
73
+ "@remix-run/node": "^2.0.0",
74
+ "remix-hono": "^0.0.16",
75
+ "hono": "^4.5.3",
76
+ "vite": "^5.0.0"
77
+ },
73
78
  "optionalDependencies": {
74
79
  "@rollup/rollup-darwin-x64-gnu": "4.18.1",
75
80
  "@rollup/rollup-darwin-x64-musl": "4.18.1",
@@ -1 +0,0 @@
1
- import{createMiddleware as t}from"hono/factory";function n(a){return t(async(e,r)=>{if(!e.req.path.match(/\.[a-zA-Z0-9]+$/)||e.req.path.endsWith(".data"))return r();await r(),e.res.ok&&e.res.headers.set("cache-control",`public, max-age=${a}`)})}export{n as a};