@rshono/core 1.0.0-rc.12 → 1.0.0-rc.13

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.
Files changed (143) hide show
  1. package/bin/rshono.mjs +3 -4
  2. package/dist/builder/env-shadow-loader.cjs +5 -5
  3. package/dist/builder/page-files.js +5 -5
  4. package/dist/builder/page-files.js.map +1 -1
  5. package/dist/builder/public-env.d.ts +5 -4
  6. package/dist/builder/public-env.d.ts.map +1 -1
  7. package/dist/builder/public-env.js +5 -4
  8. package/dist/builder/public-env.js.map +1 -1
  9. package/dist/builder/rspack-config.d.ts +5 -11
  10. package/dist/builder/rspack-config.d.ts.map +1 -1
  11. package/dist/builder/rspack-config.js +28 -50
  12. package/dist/builder/rspack-config.js.map +1 -1
  13. package/dist/cli/build.js +2 -2
  14. package/dist/cli/build.js.map +1 -1
  15. package/dist/cli/dev.d.ts.map +1 -1
  16. package/dist/cli/dev.js +30 -40
  17. package/dist/cli/dev.js.map +1 -1
  18. package/dist/cli/index.js +4 -4
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/cli/start.d.ts.map +1 -1
  21. package/dist/cli/start.js +2 -3
  22. package/dist/cli/start.js.map +1 -1
  23. package/dist/config.d.ts +28 -31
  24. package/dist/config.d.ts.map +1 -1
  25. package/dist/config.js +2 -2
  26. package/dist/config.js.map +1 -1
  27. package/dist/deploy/aws-lambda/runtime.d.ts +4 -6
  28. package/dist/deploy/aws-lambda/runtime.d.ts.map +1 -1
  29. package/dist/deploy/aws-lambda/runtime.js +5 -8
  30. package/dist/deploy/aws-lambda/runtime.js.map +1 -1
  31. package/dist/deploy/build-marker.d.ts +3 -5
  32. package/dist/deploy/build-marker.d.ts.map +1 -1
  33. package/dist/deploy/build-marker.js +3 -5
  34. package/dist/deploy/build-marker.js.map +1 -1
  35. package/dist/deploy/cloudflare/build.d.ts.map +1 -1
  36. package/dist/deploy/cloudflare/build.js +6 -10
  37. package/dist/deploy/cloudflare/build.js.map +1 -1
  38. package/dist/deploy/cloudflare/runtime.d.ts +2 -5
  39. package/dist/deploy/cloudflare/runtime.d.ts.map +1 -1
  40. package/dist/deploy/cloudflare/runtime.js +19 -32
  41. package/dist/deploy/cloudflare/runtime.js.map +1 -1
  42. package/dist/deploy/contract.d.ts +25 -42
  43. package/dist/deploy/contract.d.ts.map +1 -1
  44. package/dist/deploy/contract.js.map +1 -1
  45. package/dist/deploy/filesystem.d.ts +3 -5
  46. package/dist/deploy/filesystem.d.ts.map +1 -1
  47. package/dist/deploy/filesystem.js +7 -11
  48. package/dist/deploy/filesystem.js.map +1 -1
  49. package/dist/deploy/node/runtime.d.ts +4 -5
  50. package/dist/deploy/node/runtime.d.ts.map +1 -1
  51. package/dist/deploy/node/runtime.js +9 -15
  52. package/dist/deploy/node/runtime.js.map +1 -1
  53. package/dist/deploy/presets.d.ts +19 -29
  54. package/dist/deploy/presets.d.ts.map +1 -1
  55. package/dist/deploy/presets.js +18 -25
  56. package/dist/deploy/presets.js.map +1 -1
  57. package/dist/deploy/vercel/build.d.ts.map +1 -1
  58. package/dist/deploy/vercel/build.js +9 -12
  59. package/dist/deploy/vercel/build.js.map +1 -1
  60. package/dist/deploy/vercel/runtime.d.ts +4 -7
  61. package/dist/deploy/vercel/runtime.d.ts.map +1 -1
  62. package/dist/deploy/vercel/runtime.js +4 -7
  63. package/dist/deploy/vercel/runtime.js.map +1 -1
  64. package/dist/index.d.ts +13 -9
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +15 -12
  67. package/dist/index.js.map +1 -1
  68. package/dist/router.d.ts +65 -93
  69. package/dist/router.d.ts.map +1 -1
  70. package/dist/router.js +2 -5
  71. package/dist/router.js.map +1 -1
  72. package/dist/runtime/boundaries.d.ts +24 -30
  73. package/dist/runtime/boundaries.d.ts.map +1 -1
  74. package/dist/runtime/boundaries.js +15 -22
  75. package/dist/runtime/boundaries.js.map +1 -1
  76. package/dist/runtime/client.d.ts +16 -7
  77. package/dist/runtime/client.d.ts.map +1 -1
  78. package/dist/runtime/client.js +16 -7
  79. package/dist/runtime/client.js.map +1 -1
  80. package/dist/runtime/context.d.ts +89 -118
  81. package/dist/runtime/context.d.ts.map +1 -1
  82. package/dist/runtime/context.js +107 -167
  83. package/dist/runtime/context.js.map +1 -1
  84. package/dist/runtime/control.js +3 -3
  85. package/dist/runtime/control.js.map +1 -1
  86. package/dist/runtime/dev-protocol.d.ts +4 -8
  87. package/dist/runtime/dev-protocol.d.ts.map +1 -1
  88. package/dist/runtime/dev-protocol.js.map +1 -1
  89. package/dist/runtime/entry.client.js +69 -105
  90. package/dist/runtime/entry.client.js.map +1 -1
  91. package/dist/runtime/entry.rsc.d.ts +5 -6
  92. package/dist/runtime/entry.rsc.d.ts.map +1 -1
  93. package/dist/runtime/entry.rsc.js +67 -122
  94. package/dist/runtime/entry.rsc.js.map +1 -1
  95. package/dist/runtime/entry.ssr.d.ts +7 -12
  96. package/dist/runtime/entry.ssr.d.ts.map +1 -1
  97. package/dist/runtime/entry.ssr.js +13 -24
  98. package/dist/runtime/entry.ssr.js.map +1 -1
  99. package/dist/runtime/flight-inject.d.ts +10 -17
  100. package/dist/runtime/flight-inject.d.ts.map +1 -1
  101. package/dist/runtime/flight-inject.js +35 -53
  102. package/dist/runtime/flight-inject.js.map +1 -1
  103. package/dist/runtime/hot-update.d.ts +20 -27
  104. package/dist/runtime/hot-update.d.ts.map +1 -1
  105. package/dist/runtime/hot-update.js +17 -23
  106. package/dist/runtime/hot-update.js.map +1 -1
  107. package/dist/runtime/navigation.d.ts +14 -19
  108. package/dist/runtime/navigation.d.ts.map +1 -1
  109. package/dist/runtime/navigation.js +9 -13
  110. package/dist/runtime/navigation.js.map +1 -1
  111. package/dist/runtime/request.d.ts +4 -6
  112. package/dist/runtime/request.d.ts.map +1 -1
  113. package/dist/runtime/request.js +2 -3
  114. package/dist/runtime/request.js.map +1 -1
  115. package/dist/runtime/server.d.ts +18 -10
  116. package/dist/runtime/server.d.ts.map +1 -1
  117. package/dist/runtime/server.js +21 -19
  118. package/dist/runtime/server.js.map +1 -1
  119. package/dist/server/headers.d.ts +8 -15
  120. package/dist/server/headers.d.ts.map +1 -1
  121. package/dist/server/headers.js +8 -15
  122. package/dist/server/headers.js.map +1 -1
  123. package/dist/server/load-config.d.ts +2 -2
  124. package/dist/server/load-config.d.ts.map +1 -1
  125. package/dist/server/load-config.js +6 -9
  126. package/dist/server/load-config.js.map +1 -1
  127. package/dist/server/prerendered.d.ts +30 -43
  128. package/dist/server/prerendered.d.ts.map +1 -1
  129. package/dist/server/prerendered.js +20 -29
  130. package/dist/server/prerendered.js.map +1 -1
  131. package/dist/server/server-config.d.ts +13 -28
  132. package/dist/server/server-config.d.ts.map +1 -1
  133. package/dist/server/server-config.js +5 -10
  134. package/dist/server/server-config.js.map +1 -1
  135. package/dist/server/shutdown.d.ts +2 -3
  136. package/dist/server/shutdown.d.ts.map +1 -1
  137. package/dist/server/shutdown.js +2 -3
  138. package/dist/server/shutdown.js.map +1 -1
  139. package/dist/server/ssg.d.ts +3 -6
  140. package/dist/server/ssg.d.ts.map +1 -1
  141. package/dist/server/ssg.js +11 -20
  142. package/dist/server/ssg.js.map +1 -1
  143. package/package.json +1 -1
package/dist/cli/dev.js CHANGED
@@ -16,12 +16,9 @@ function describe(error) {
16
16
  return error instanceof Error ? (error.stack ?? error.message) : String(error);
17
17
  }
18
18
  /**
19
- * Whether nothing is listening on the port yet — checked before the output directory is emptied.
20
- *
21
- * `rshono dev` clears its own output on startup, so a second one started against a running server
22
- * wipes the directory that server is still importing route chunks from, and only then exits on
23
- * EADDRINUSE. The first server keeps serving from files that no longer exist, and its watcher never
24
- * re-emits them — it believes it already wrote them — so it 500s until it is restarted.
19
+ * Whether nothing is listening on the port yet — checked before the output directory is emptied, because a
20
+ * second `rshono dev` would otherwise wipe the chunks the running one is still importing and only then exit
21
+ * on EADDRINUSE.
25
22
  */
26
23
  function portAvailable(port, hostname) {
27
24
  const { promise, resolve } = Promise.withResolvers();
@@ -33,10 +30,10 @@ function portAvailable(port, hostname) {
33
30
  export async function devCommand(options) {
34
31
  const { rootDir, config } = options;
35
32
  const port = options.port ?? SERVER_DEFAULTS.port;
36
- // Its own directory, never `dist/`: a `rshono build` in another terminal must not be able to
37
- // delete the chunks this server is still importing. See DEV_OUT_DIR.
33
+ // Its own directory, never `dist/`: a `rshono build` in another terminal must not be able to delete the
34
+ // chunks this server is still importing.
38
35
  const outDir = join(rootDir, DEV_OUT_DIR);
39
- // Before the `rm` below, not at `serve` where the bind actually happens: see {@link portAvailable}.
36
+ // Before the `rm` below, not at `serve` where the bind happens see {@link portAvailable}.
40
37
  if (!(await portAvailable(port, '127.0.0.1'))) {
41
38
  console.error(` ✗ port ${port} is already in use`);
42
39
  process.exit(1);
@@ -48,9 +45,8 @@ export async function devCommand(options) {
48
45
  let clientHash;
49
46
  const sseChunk = (data) => encoder.encode(`data: ${JSON.stringify(data)}\n\n`);
50
47
  /**
51
- * Writes one already-encoded SSE frame to every open client, dropping the ones that have gone away.
52
- * A browser that navigated or closed leaves a controller whose `enqueue` throws, and `cancel` is not
53
- * always reached first — so a failed write is what retires a client.
48
+ * Writes one already-encoded SSE frame to every open client. A failed write is what retires a client:
49
+ * `cancel` is not always reached first when a browser navigates away.
54
50
  */
55
51
  function sendToAll(chunk) {
56
52
  for (const controller of sseClients) {
@@ -70,8 +66,8 @@ export async function devCommand(options) {
70
66
  rootDir,
71
67
  isDev: true,
72
68
  config,
73
- // Always Node, whatever `deploy` says: the dev server runs the bundle in a worker thread of this
74
- // process and fronts it on one port. `deploy` is a property of `build` output, not of developing.
69
+ // Always Node, whatever `deploy` says: that is a property of `build` output, and the dev server runs the
70
+ // bundle in a worker thread of this process.
75
71
  preset: NODE_PRESET,
76
72
  onServerComponentChanges: () => {
77
73
  serverComponentsChanged = true;
@@ -95,7 +91,9 @@ export async function devCommand(options) {
95
91
  env: process.env,
96
92
  });
97
93
  const timeout = setTimeout(() => {
98
- worker.terminate();
94
+ // Nothing waits on the termination: the promise below is already being rejected, and a worker that
95
+ // never reported ready has no state left worth draining.
96
+ void worker.terminate();
99
97
  reject(new Error(`server worker did not become ready within ${WORKER_READY_TIMEOUT_MS / 1000}s`));
100
98
  }, WORKER_READY_TIMEOUT_MS);
101
99
  let ready = false;
@@ -106,9 +104,8 @@ export async function devCommand(options) {
106
104
  resolve({ worker, port: message.port });
107
105
  }
108
106
  });
109
- // `on`, not `once`: an error *after* the worker is ready has no pending promise left to reject,
110
- // and a consumed `once` would leave that error with no listener at all — which Node turns into
111
- // an uncaught exception that takes the dev server down with the worker.
107
+ // `on`, not `once`: an error after the worker is ready has no pending promise left to reject, and a
108
+ // consumed `once` would leave it unlistened — which Node turns into an uncaught exception here.
112
109
  worker.on('error', (error) => {
113
110
  if (ready) {
114
111
  console.error(' ✗ server worker crashed:', error);
@@ -121,10 +118,8 @@ export async function devCommand(options) {
121
118
  if (worker === currentWorker && code !== 0) {
122
119
  console.error(` ✗ server worker exited with code ${code} — waiting for the next rebuild`);
123
120
  currentWorker = null;
124
- // Opened with the reason rather than left closed: a request arriving before the next rebuild
125
- // parks on this gate, and an unopened one would hang the browser with only the terminal
126
- // saying why. `hooks.invalid` installs a fresh closed gate the moment a file changes, so the
127
- // next build still holds requests until the worker is back.
121
+ // Opened with the reason rather than left closed, so a request arriving before the next rebuild sees
122
+ // it instead of hanging. `hooks.invalid` installs a fresh closed gate as soon as a file changes.
128
123
  workerGate = createGate();
129
124
  workerGate.open({ error: `The server worker exited with code ${code}. See the terminal for the error it crashed with.` });
130
125
  }
@@ -162,9 +157,8 @@ export async function devCommand(options) {
162
157
  gate.open({ error: describe(error) });
163
158
  }
164
159
  });
165
- // No link in this queue may be left rejected: `.then` on a rejected promise short-circuits, and
166
- // from that point no worker is ever spawned again and no gate is ever opened — a dev server that
167
- // answers nothing and explains nothing. The `try` above covers the restart; this covers the rest.
160
+ // No link in this queue may be left rejected: `.then` on a rejected promise short-circuits, and from there
161
+ // no worker is spawned and no gate is opened again.
168
162
  restartChain = restartChain.catch((error) => {
169
163
  console.error(' ✗ dev server restart failed:', error);
170
164
  gate.open({ error: describe(error) });
@@ -194,7 +188,7 @@ export async function devCommand(options) {
194
188
  });
195
189
  const front = new Hono();
196
190
  front.route('/_static', createStaticAssetsApp({ root: join(outDir, 'static'), isDev: true }));
197
- front.get('/_rshono/hmr', (c) => {
191
+ front.get('/_rshono/hmr', () => {
198
192
  let ctrl;
199
193
  const stream = new ReadableStream({
200
194
  start(controller) {
@@ -215,8 +209,8 @@ export async function devCommand(options) {
215
209
  },
216
210
  });
217
211
  });
218
- // An SSE comment, not a message: it keeps an idle connection off a proxy's timeout without the
219
- // client having to know about a frame type that means nothing.
212
+ // An SSE comment, not a message: it keeps an idle connection off a proxy's timeout without the client
213
+ // having to know a frame type that means nothing.
220
214
  const ping = encoder.encode(': ping\n\n');
221
215
  setInterval(() => sendToAll(ping), 15_000).unref();
222
216
  front.all('*', async (c) => {
@@ -226,27 +220,23 @@ export async function devCommand(options) {
226
220
  }
227
221
  const incoming = new URL(c.req.url);
228
222
  const target = `http://127.0.0.1:${workerPort}${incoming.pathname}${incoming.search}`;
229
- // Hono's proxy helper rather than a hand-rolled `fetch`: it carries the method, the streamed body
230
- // (with the `duplex` Node requires) and the client's abort signal, so a browser that goes away
231
- // takes the worker's render with it. On the way back it strips the hop-by-hop headers. `headers`
232
- // replaces the set wholesale, so the request's own are spread back in first.
223
+ // Hono's proxy helper rather than a hand-rolled `fetch`: it carries the method, the streamed body (with
224
+ // the `duplex` Node requires) and the client's abort signal, and strips the hop-by-hop headers on the way
225
+ // back. `headers` replaces the set wholesale, so the request's own are spread back in first.
233
226
  const response = await proxy(target, {
234
227
  raw: c.req.raw,
235
- // The worker's redirects are the app's answer to this request, not something to follow here
236
- // they have to reach the browser, with the internal address rewritten off them below.
228
+ // The worker's redirects are the app's answer to this request, to be rewritten below and passed on.
237
229
  redirect: 'manual',
238
230
  headers: {
239
231
  ...c.req.header(),
240
- // This front-end *is* the proxy the app sits behind, and `trustProxy` is forced on in dev for
241
- // exactly that reason: without these the app resolves every URL against the worker's random
242
- // 127.0.0.1 port instead of the address the browser actually used.
232
+ // This front-end *is* the proxy the app sits behind, which is why `trustProxy` is forced on in dev:
233
+ // without these the app resolves every URL against the worker's random 127.0.0.1 port.
243
234
  'x-forwarded-host': incoming.host,
244
235
  'x-forwarded-proto': incoming.protocol.replace(':', ''),
245
236
  },
246
237
  });
247
- // A redirect to the worker's own address has to become a relative one, or the browser leaves the
248
- // dev server for a random port only this process knows about. `proxy` hands back a response whose
249
- // headers are still mutable, so the rewrite happens in place.
238
+ // A redirect to the worker's own address has to become a relative one, or the browser leaves the dev
239
+ // server for a random port only this process knows about.
250
240
  const location = response.headers.get('location');
251
241
  const loc = location ? URL.parse(location, target) : null;
252
242
  if (loc && loc.host === `127.0.0.1:${workerPort}`) {
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAc,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAq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AAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAClD,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1D,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,UAAU,EAAE,EAAE,CAAC;YAClD,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;QAClE,OAAO,CAAC,GAAG,CAAC,2CAA2C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { serve } from '@hono/node-server';\nimport { rspack, type Stats } from '@rspack/core';\nimport { Hono } from 'hono';\nimport { proxy } from 'hono/proxy';\nimport { mkdir, rm } from 'node:fs/promises';\nimport { createServer } from 'node:net';\nimport { join } from 'node:path';\nimport { Worker } from 'node:worker_threads';\nimport { DEV_OUT_DIR, createConfigs } from '../builder/rspack-config.js';\nimport type { RshonoConfig } from '../config.js';\nimport { NODE_PRESET } from '../deploy/presets.js';\nimport type { DevMessage } from '../runtime/dev-protocol.js';\nimport { SERVER_DEFAULTS } from '../server/server-config.js';\nimport { createStaticAssetsApp } from '../server/static.js';\n\nconst WORKER_READY_TIMEOUT_MS = 15_000;\n\n/** An error as the dev server shows it in the browser: the stack where there is one, since this is dev. */\nfunction describe(error: unknown): string {\n return error instanceof Error ? (error.stack ?? error.message) : String(error);\n}\n\n/**\n * Whether nothing is listening on the port yet — checked before the output directory is emptied.\n *\n * `rshono dev` clears its own output on startup, so a second one started against a running server\n * wipes the directory that server is still importing route chunks from, and only then exits on\n * EADDRINUSE. The first server keeps serving from files that no longer exist, and its watcher never\n * re-emits them — it believes it already wrote them — so it 500s until it is restarted.\n */\nfunction portAvailable(port: number, hostname: string): Promise<boolean> {\n const { promise, resolve } = Promise.withResolvers<boolean>();\n const probe = createServer();\n probe.once('error', () => resolve(false));\n probe.listen(port, hostname, () => probe.close(() => resolve(true)));\n return promise;\n}\n\ninterface DevOptions {\n rootDir: string;\n port?: number;\n config: RshonoConfig;\n}\n\nexport async function devCommand(options: DevOptions): Promise<void> {\n const { rootDir, config } = options;\n const port = options.port ?? SERVER_DEFAULTS.port;\n // Its own directory, never `dist/`: a `rshono build` in another terminal must not be able to\n // delete the chunks this server is still importing. See DEV_OUT_DIR.\n const outDir = join(rootDir, DEV_OUT_DIR);\n\n // Before the `rm` below, not at `serve` where the bind actually happens: see {@link portAvailable}.\n if (!(await portAvailable(port, '127.0.0.1'))) {\n console.error(` ✗ port ${port} is already in use`);\n process.exit(1);\n }\n\n await rm(outDir, { recursive: true, force: true });\n await mkdir(join(outDir, 'static'), { recursive: true });\n\n const encoder = new TextEncoder();\n const sseClients = new Set<ReadableStreamDefaultController<Uint8Array>>();\n let clientHash: string | undefined;\n\n const sseChunk = (data: unknown) => encoder.encode(`data: ${JSON.stringify(data)}\\n\\n`);\n\n /**\n * Writes one already-encoded SSE frame to every open client, dropping the ones that have gone away.\n * A browser that navigated or closed leaves a controller whose `enqueue` throws, and `cancel` is not\n * always reached first — so a failed write is what retires a client.\n */\n function sendToAll(chunk: Uint8Array): void {\n for (const controller of sseClients) {\n try {\n controller.enqueue(chunk);\n } catch {\n sseClients.delete(controller);\n }\n }\n }\n\n function broadcast(message: DevMessage): void {\n sendToAll(sseChunk(message));\n }\n\n let serverComponentsChanged = false;\n const [clientConfig, serverConfig] = createConfigs({\n rootDir,\n isDev: true,\n config,\n // Always Node, whatever `deploy` says: the dev server runs the bundle in a worker thread of this\n // process and fronts it on one port. `deploy` is a property of `build` output, not of developing.\n preset: NODE_PRESET,\n onServerComponentChanges: () => {\n serverComponentsChanged = true;\n },\n });\n const compiler = rspack([clientConfig, serverConfig]);\n const [clientCompiler, serverCompiler] = compiler.compilers;\n\n let currentWorker: Worker | null = null;\n let workerPort: number | null = null;\n let workerGate = createGate();\n let restartChain: Promise<void> = Promise.resolve();\n\n function createGate() {\n const { promise, resolve } = Promise.withResolvers<{ error?: string }>();\n return { promise, open: resolve };\n }\n\n function spawnWorker(): Promise<{ worker: Worker; port: number }> {\n return new Promise((resolve, reject) => {\n const worker = new Worker(join(outDir, 'server', 'main.mjs'), {\n workerData: { port: 0, hostname: '127.0.0.1' },\n execArgv: ['--enable-source-maps'],\n env: process.env as Record<string, string>,\n });\n const timeout = setTimeout(() => {\n worker.terminate();\n reject(new Error(`server worker did not become ready within ${WORKER_READY_TIMEOUT_MS / 1000}s`));\n }, WORKER_READY_TIMEOUT_MS);\n\n let ready = false;\n worker.once('message', (message: { type?: string; port?: number }) => {\n if (message?.type === 'ready' && typeof message.port === 'number') {\n ready = true;\n clearTimeout(timeout);\n resolve({ worker, port: message.port });\n }\n });\n // `on`, not `once`: an error *after* the worker is ready has no pending promise left to reject,\n // and a consumed `once` would leave that error with no listener at all — which Node turns into\n // an uncaught exception that takes the dev server down with the worker.\n worker.on('error', (error) => {\n if (ready) {\n console.error(' ✗ server worker crashed:', error);\n return;\n }\n clearTimeout(timeout);\n reject(error);\n });\n worker.on('exit', (code) => {\n if (worker === currentWorker && code !== 0) {\n console.error(` ✗ server worker exited with code ${code} — waiting for the next rebuild`);\n currentWorker = null;\n // Opened with the reason rather than left closed: a request arriving before the next rebuild\n // parks on this gate, and an unopened one would hang the browser with only the terminal\n // saying why. `hooks.invalid` installs a fresh closed gate the moment a file changes, so the\n // next build still holds requests until the worker is back.\n workerGate = createGate();\n workerGate.open({ error: `The server worker exited with code ${code}. See the terminal for the error it crashed with.` });\n }\n });\n });\n }\n\n serverCompiler.hooks.invalid.tap('rshono/gate', () => {\n workerGate = createGate();\n });\n\n serverCompiler.hooks.done.tapPromise('rshono/worker', async (stats: Stats) => {\n const gate = workerGate;\n restartChain = restartChain.then(async () => {\n if (stats.hasErrors()) {\n console.error(stats.toString({ preset: 'errors-warnings', colors: true }));\n gate.open({ error: stats.toString({ preset: 'errors-only', colors: false }) });\n return;\n }\n try {\n if (currentWorker) {\n const old = currentWorker;\n currentWorker = null;\n await old.terminate();\n }\n const { worker, port: newPort } = await spawnWorker();\n currentWorker = worker;\n workerPort = newPort;\n gate.open({});\n if (serverComponentsChanged) {\n serverComponentsChanged = false;\n broadcast({ type: 'rsc-update' });\n }\n } catch (error) {\n console.error(' ✗ failed to start server worker:', error);\n gate.open({ error: describe(error) });\n }\n });\n // No link in this queue may be left rejected: `.then` on a rejected promise short-circuits, and\n // from that point no worker is ever spawned again and no gate is ever opened — a dev server that\n // answers nothing and explains nothing. The `try` above covers the restart; this covers the rest.\n restartChain = restartChain.catch((error) => {\n console.error(' ✗ dev server restart failed:', error);\n gate.open({ error: describe(error) });\n });\n await restartChain;\n });\n\n clientCompiler.hooks.done.tap('rshono/hmr', (stats: Stats) => {\n if (stats.hasErrors()) {\n console.error(stats.toString({ preset: 'errors-warnings', colors: true }));\n return;\n }\n clientHash = stats.hash ?? undefined;\n if (clientHash) broadcast({ type: 'client-built', hash: clientHash });\n });\n\n let firstBuild = true;\n compiler.watch([{}, {}] as never, (err, multiStats) => {\n if (err) {\n console.error(' ✗ build failed:', err);\n return;\n }\n if (multiStats && !multiStats.hasErrors()) {\n const seconds = Math.max(...multiStats.stats.map((s) => (s.endTime ?? 0) - (s.startTime ?? 0))) / 1000;\n console.log(` ${firstBuild ? '✓ built' : '✓ rebuilt'} in ${seconds.toFixed(1)}s`);\n firstBuild = false;\n }\n });\n\n const front = new Hono();\n\n front.route('/_static', createStaticAssetsApp({ root: join(outDir, 'static'), isDev: true }));\n\n front.get('/_rshono/hmr', (c) => {\n let ctrl: ReadableStreamDefaultController<Uint8Array>;\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n ctrl = controller;\n sseClients.add(controller);\n controller.enqueue(encoder.encode('retry: 500\\n\\n'));\n controller.enqueue(sseChunk({ type: 'hello', hash: clientHash } satisfies DevMessage));\n },\n cancel() {\n sseClients.delete(ctrl);\n },\n });\n return new Response(stream, {\n headers: {\n 'content-type': 'text/event-stream',\n 'cache-control': 'no-cache',\n connection: 'keep-alive',\n },\n });\n });\n\n // An SSE comment, not a message: it keeps an idle connection off a proxy's timeout without the\n // client having to know about a frame type that means nothing.\n const ping = encoder.encode(': ping\\n\\n');\n setInterval(() => sendToAll(ping), 15_000).unref();\n\n front.all('*', async (c) => {\n const { error } = await workerGate.promise;\n if (error || workerPort === null) {\n return c.text(`Build failed:\\n\\n${error ?? 'server not running'}`, 500);\n }\n\n const incoming = new URL(c.req.url);\n const target = `http://127.0.0.1:${workerPort}${incoming.pathname}${incoming.search}`;\n\n // Hono's proxy helper rather than a hand-rolled `fetch`: it carries the method, the streamed body\n // (with the `duplex` Node requires) and the client's abort signal, so a browser that goes away\n // takes the worker's render with it. On the way back it strips the hop-by-hop headers. `headers`\n // replaces the set wholesale, so the request's own are spread back in first.\n const response = await proxy(target, {\n raw: c.req.raw,\n // The worker's redirects are the app's answer to this request, not something to follow here —\n // they have to reach the browser, with the internal address rewritten off them below.\n redirect: 'manual',\n headers: {\n ...c.req.header(),\n // This front-end *is* the proxy the app sits behind, and `trustProxy` is forced on in dev for\n // exactly that reason: without these the app resolves every URL against the worker's random\n // 127.0.0.1 port instead of the address the browser actually used.\n 'x-forwarded-host': incoming.host,\n 'x-forwarded-proto': incoming.protocol.replace(':', ''),\n },\n });\n\n // A redirect to the worker's own address has to become a relative one, or the browser leaves the\n // dev server for a random port only this process knows about. `proxy` hands back a response whose\n // headers are still mutable, so the rewrite happens in place.\n const location = response.headers.get('location');\n const loc = location ? URL.parse(location, target) : null;\n if (loc && loc.host === `127.0.0.1:${workerPort}`) {\n response.headers.set('location', `${loc.pathname}${loc.search}${loc.hash}`);\n }\n return response;\n });\n\n serve({ fetch: front.fetch, port, hostname: '127.0.0.1' }, (info) => {\n console.log(` ➜ rshono dev server: http://localhost:${info.port}`);\n });\n}\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAc,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,2GAA2G;AAC3G,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjF,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAY,EAAE,QAAgB;IACnD,MAAM,EAAE,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Q,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;QAClE,OAAO,CAAC,GAAG,CAAC,2CAA2C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { serve } from '@hono/node-server';\nimport { rspack, type Stats } from '@rspack/core';\nimport { Hono } from 'hono';\nimport { proxy } from 'hono/proxy';\nimport { mkdir, rm } from 'node:fs/promises';\nimport { createServer } from 'node:net';\nimport { join } from 'node:path';\nimport { Worker } from 'node:worker_threads';\nimport { DEV_OUT_DIR, createConfigs } from '../builder/rspack-config.js';\nimport type { RshonoConfig } from '../config.js';\nimport { NODE_PRESET } from '../deploy/presets.js';\nimport type { DevMessage } from '../runtime/dev-protocol.js';\nimport { SERVER_DEFAULTS } from '../server/server-config.js';\nimport { createStaticAssetsApp } from '../server/static.js';\n\nconst WORKER_READY_TIMEOUT_MS = 15_000;\n\n/** An error as the dev server shows it in the browser: the stack where there is one, since this is dev. */\nfunction describe(error: unknown): string {\n return error instanceof Error ? (error.stack ?? error.message) : String(error);\n}\n\n/**\n * Whether nothing is listening on the port yet — checked before the output directory is emptied, because a\n * second `rshono dev` would otherwise wipe the chunks the running one is still importing and only then exit\n * on EADDRINUSE.\n */\nfunction portAvailable(port: number, hostname: string): Promise<boolean> {\n const { promise, resolve } = Promise.withResolvers<boolean>();\n const probe = createServer();\n probe.once('error', () => resolve(false));\n probe.listen(port, hostname, () => probe.close(() => resolve(true)));\n return promise;\n}\n\ninterface DevOptions {\n rootDir: string;\n port?: number;\n config: RshonoConfig;\n}\n\nexport async function devCommand(options: DevOptions): Promise<void> {\n const { rootDir, config } = options;\n const port = options.port ?? SERVER_DEFAULTS.port;\n // Its own directory, never `dist/`: a `rshono build` in another terminal must not be able to delete the\n // chunks this server is still importing.\n const outDir = join(rootDir, DEV_OUT_DIR);\n\n // Before the `rm` below, not at `serve` where the bind happens — see {@link portAvailable}.\n if (!(await portAvailable(port, '127.0.0.1'))) {\n console.error(` ✗ port ${port} is already in use`);\n process.exit(1);\n }\n\n await rm(outDir, { recursive: true, force: true });\n await mkdir(join(outDir, 'static'), { recursive: true });\n\n const encoder = new TextEncoder();\n const sseClients = new Set<ReadableStreamDefaultController<Uint8Array>>();\n let clientHash: string | undefined;\n\n const sseChunk = (data: unknown) => encoder.encode(`data: ${JSON.stringify(data)}\\n\\n`);\n\n /**\n * Writes one already-encoded SSE frame to every open client. A failed write is what retires a client:\n * `cancel` is not always reached first when a browser navigates away.\n */\n function sendToAll(chunk: Uint8Array): void {\n for (const controller of sseClients) {\n try {\n controller.enqueue(chunk);\n } catch {\n sseClients.delete(controller);\n }\n }\n }\n\n function broadcast(message: DevMessage): void {\n sendToAll(sseChunk(message));\n }\n\n let serverComponentsChanged = false;\n const [clientConfig, serverConfig] = createConfigs({\n rootDir,\n isDev: true,\n config,\n // Always Node, whatever `deploy` says: that is a property of `build` output, and the dev server runs the\n // bundle in a worker thread of this process.\n preset: NODE_PRESET,\n onServerComponentChanges: () => {\n serverComponentsChanged = true;\n },\n });\n const compiler = rspack([clientConfig, serverConfig]);\n const [clientCompiler, serverCompiler] = compiler.compilers;\n\n let currentWorker: Worker | null = null;\n let workerPort: number | null = null;\n let workerGate = createGate();\n let restartChain: Promise<void> = Promise.resolve();\n\n function createGate() {\n const { promise, resolve } = Promise.withResolvers<{ error?: string }>();\n return { promise, open: resolve };\n }\n\n function spawnWorker(): Promise<{ worker: Worker; port: number }> {\n return new Promise((resolve, reject) => {\n const worker = new Worker(join(outDir, 'server', 'main.mjs'), {\n workerData: { port: 0, hostname: '127.0.0.1' },\n execArgv: ['--enable-source-maps'],\n env: process.env as Record<string, string>,\n });\n const timeout = setTimeout(() => {\n // Nothing waits on the termination: the promise below is already being rejected, and a worker that\n // never reported ready has no state left worth draining.\n void worker.terminate();\n reject(new Error(`server worker did not become ready within ${WORKER_READY_TIMEOUT_MS / 1000}s`));\n }, WORKER_READY_TIMEOUT_MS);\n\n let ready = false;\n worker.once('message', (message: { type?: string; port?: number }) => {\n if (message?.type === 'ready' && typeof message.port === 'number') {\n ready = true;\n clearTimeout(timeout);\n resolve({ worker, port: message.port });\n }\n });\n // `on`, not `once`: an error after the worker is ready has no pending promise left to reject, and a\n // consumed `once` would leave it unlistened — which Node turns into an uncaught exception here.\n worker.on('error', (error: Error) => {\n if (ready) {\n console.error(' ✗ server worker crashed:', error);\n return;\n }\n clearTimeout(timeout);\n reject(error);\n });\n worker.on('exit', (code) => {\n if (worker === currentWorker && code !== 0) {\n console.error(` ✗ server worker exited with code ${code} — waiting for the next rebuild`);\n currentWorker = null;\n // Opened with the reason rather than left closed, so a request arriving before the next rebuild sees\n // it instead of hanging. `hooks.invalid` installs a fresh closed gate as soon as a file changes.\n workerGate = createGate();\n workerGate.open({ error: `The server worker exited with code ${code}. See the terminal for the error it crashed with.` });\n }\n });\n });\n }\n\n serverCompiler.hooks.invalid.tap('rshono/gate', () => {\n workerGate = createGate();\n });\n\n serverCompiler.hooks.done.tapPromise('rshono/worker', async (stats: Stats) => {\n const gate = workerGate;\n restartChain = restartChain.then(async () => {\n if (stats.hasErrors()) {\n console.error(stats.toString({ preset: 'errors-warnings', colors: true }));\n gate.open({ error: stats.toString({ preset: 'errors-only', colors: false }) });\n return;\n }\n try {\n if (currentWorker) {\n const old = currentWorker;\n currentWorker = null;\n await old.terminate();\n }\n const { worker, port: newPort } = await spawnWorker();\n currentWorker = worker;\n workerPort = newPort;\n gate.open({});\n if (serverComponentsChanged) {\n serverComponentsChanged = false;\n broadcast({ type: 'rsc-update' });\n }\n } catch (error) {\n console.error(' ✗ failed to start server worker:', error);\n gate.open({ error: describe(error) });\n }\n });\n // No link in this queue may be left rejected: `.then` on a rejected promise short-circuits, and from there\n // no worker is spawned and no gate is opened again.\n restartChain = restartChain.catch((error) => {\n console.error(' ✗ dev server restart failed:', error);\n gate.open({ error: describe(error) });\n });\n await restartChain;\n });\n\n clientCompiler.hooks.done.tap('rshono/hmr', (stats: Stats) => {\n if (stats.hasErrors()) {\n console.error(stats.toString({ preset: 'errors-warnings', colors: true }));\n return;\n }\n clientHash = stats.hash ?? undefined;\n if (clientHash) broadcast({ type: 'client-built', hash: clientHash });\n });\n\n let firstBuild = true;\n compiler.watch([{}, {}] as never, (err, multiStats) => {\n if (err) {\n console.error(' ✗ build failed:', err);\n return;\n }\n if (multiStats && !multiStats.hasErrors()) {\n const seconds = Math.max(...multiStats.stats.map((s) => (s.endTime ?? 0) - (s.startTime ?? 0))) / 1000;\n console.log(` ${firstBuild ? '✓ built' : '✓ rebuilt'} in ${seconds.toFixed(1)}s`);\n firstBuild = false;\n }\n });\n\n const front = new Hono();\n\n front.route('/_static', createStaticAssetsApp({ root: join(outDir, 'static'), isDev: true }));\n\n front.get('/_rshono/hmr', () => {\n let ctrl: ReadableStreamDefaultController<Uint8Array>;\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n ctrl = controller;\n sseClients.add(controller);\n controller.enqueue(encoder.encode('retry: 500\\n\\n'));\n controller.enqueue(sseChunk({ type: 'hello', hash: clientHash } satisfies DevMessage));\n },\n cancel() {\n sseClients.delete(ctrl);\n },\n });\n return new Response(stream, {\n headers: {\n 'content-type': 'text/event-stream',\n 'cache-control': 'no-cache',\n connection: 'keep-alive',\n },\n });\n });\n\n // An SSE comment, not a message: it keeps an idle connection off a proxy's timeout without the client\n // having to know a frame type that means nothing.\n const ping = encoder.encode(': ping\\n\\n');\n setInterval(() => sendToAll(ping), 15_000).unref();\n\n front.all('*', async (c) => {\n const { error } = await workerGate.promise;\n if (error || workerPort === null) {\n return c.text(`Build failed:\\n\\n${error ?? 'server not running'}`, 500);\n }\n\n const incoming = new URL(c.req.url);\n const target = `http://127.0.0.1:${workerPort}${incoming.pathname}${incoming.search}`;\n\n // Hono's proxy helper rather than a hand-rolled `fetch`: it carries the method, the streamed body (with\n // the `duplex` Node requires) and the client's abort signal, and strips the hop-by-hop headers on the way\n // back. `headers` replaces the set wholesale, so the request's own are spread back in first.\n const response = await proxy(target, {\n raw: c.req.raw,\n // The worker's redirects are the app's answer to this request, to be rewritten below and passed on.\n redirect: 'manual',\n headers: {\n ...c.req.header(),\n // This front-end *is* the proxy the app sits behind, which is why `trustProxy` is forced on in dev:\n // without these the app resolves every URL against the worker's random 127.0.0.1 port.\n 'x-forwarded-host': incoming.host,\n 'x-forwarded-proto': incoming.protocol.replace(':', ''),\n },\n });\n\n // A redirect to the worker's own address has to become a relative one, or the browser leaves the dev\n // server for a random port only this process knows about.\n const location = response.headers.get('location');\n const loc = location ? URL.parse(location, target) : null;\n if (loc && loc.host === `127.0.0.1:${workerPort}`) {\n response.headers.set('location', `${loc.pathname}${loc.search}${loc.hash}`);\n }\n return response;\n });\n\n serve({ fetch: front.fetch, port, hostname: '127.0.0.1' }, (info) => {\n console.log(` ➜ rshono dev server: http://localhost:${info.port}`);\n });\n}\n"]}
package/dist/cli/index.js CHANGED
@@ -3,9 +3,8 @@ import { parseArgs } from 'node:util';
3
3
  import { DEPLOY_TARGETS, resolveDeployPreset } from '../deploy/presets.js';
4
4
  import { loadConfig } from '../server/load-config.js';
5
5
  import { loadEnvFiles } from '../server/load-env.js';
6
- // The commands are imported where they are dispatched, not here: `build` and `dev` pull in Rspack a
7
- // native binding and a large module graph and a static import would load it for `start` too, which
8
- // does nothing but spawn the built server. ~30 MB of RSS and ~70ms of startup on a production host.
6
+ // The commands are imported where they are dispatched: `build` and `dev` pull in Rspack, and a static import
7
+ // would load it for `start` too~30 MB of RSS and ~70ms of startup for a command that only spawns a server.
9
8
  const HELP = `rshono — Hono + Rspack + React Server Components
10
9
 
11
10
  Usage:
@@ -33,7 +32,8 @@ async function main() {
33
32
  });
34
33
  if (values.version) {
35
34
  const require = createRequire(import.meta.url);
36
- console.log(require('@rshono/core/package.json').version);
35
+ const { version } = require('@rshono/core/package.json');
36
+ console.log(version);
37
37
  return;
38
38
  }
39
39
  const command = positionals[0];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,sGAAsG;AACtG,qGAAqG;AACrG,oGAAoG;AAEpG,MAAM,IAAI,GAAG;;;;;;;;;;+CAUkC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC;;;CAGxE,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;QACxC,OAAO,EAAE;YACP,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACpC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACtC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACtC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;YACrC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;SACzC;QACD,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAA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O,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;gBAC/C,OAAO;gBACP,MAAM;gBACN,MAAM,EAAE,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;aAC5G,CAAC,CAAC;QACL,KAAK,OAAO;YACV,OAAO,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E;YACE,OAAO,CAAC,KAAK,CAAC,4BAA4B,OAAO,KAAK,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { parseArgs } from 'node:util';\nimport { DEPLOY_TARGETS, resolveDeployPreset } from '../deploy/presets.js';\nimport { loadConfig } from '../server/load-config.js';\nimport { loadEnvFiles } from '../server/load-env.js';\n\n// The commands are imported where they are dispatched, not here: `build` and `dev` pull in Rspack — a\n// native binding and a large module graph — and a static import would load it for `start` too, which\n// does nothing but spawn the built server. ~30 MB of RSS and ~70ms of startup on a production host.\n\nconst HELP = `rshono — Hono + Rspack + React Server Components\n\nUsage:\n rshono dev [--port 3000] start the dev server\n rshono build build for production (client + server + SSG)\n rshono start [--port 3000] run the production build\n\nOptions:\n -p, --port <n> port to listen on (default: PORT env or 3000)\n -c, --config <path> path to a config file (default: rshono.config.{ts,js,mjs})\n -d, --deploy <name> platform to build for: ${DEPLOY_TARGETS.join(' | ')} (default: node)\n -h, --help show this help\n -v, --version print the version\n`;\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n options: {\n port: { type: 'string', short: 'p' },\n config: { type: 'string', short: 'c' },\n deploy: { type: 'string', short: 'd' },\n help: { type: 'boolean', short: 'h' },\n version: { type: 'boolean', short: 'v' },\n },\n allowPositionals: true,\n });\n\n if (values.version) {\n const require = createRequire(import.meta.url);\n console.log(require('@rshono/core/package.json').version);\n return;\n }\n\n const command = positionals[0];\n if (values.help || !command) {\n console.log(HELP);\n return;\n }\n\n const rootDir = process.cwd();\n loadEnvFiles(rootDir);\n const config = await loadConfig(rootDir, values.config);\n\n const flagPort = values.port ? Number(values.port) : undefined;\n if (values.port && Number.isNaN(flagPort)) {\n console.error(`rshono: invalid --port \"${values.port}\"`);\n process.exit(1);\n }\n // Precedence: --port flag > PORT env > the command's built-in default.\n const envPort = process.env.PORT ? Number(process.env.PORT) : undefined;\n const port = flagPort ?? envPort;\n const host = process.env.HOST;\n\n switch (command) {\n case 'dev':\n return (await import('./dev.js')).devCommand({ rootDir, port, config });\n case 'build':\n return (await import('./build.js')).buildCommand({\n rootDir,\n config,\n preset: resolveDeployPreset({ flag: values.deploy, env: process.env.RSHONO_DEPLOY, config: config.deploy }),\n });\n case 'start':\n return (await import('./start.js')).startCommand({ rootDir, port, host });\n default:\n console.error(`rshono: unknown command \"${command}\"\\n`);\n console.log(HELP);\n process.exit(1);\n }\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CA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QACL,KAAK,OAAO;YACV,OAAO,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E;YACE,OAAO,CAAC,KAAK,CAAC,4BAA4B,OAAO,KAAK,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { parseArgs } from 'node:util';\nimport { DEPLOY_TARGETS, resolveDeployPreset } from '../deploy/presets.js';\nimport { loadConfig } from '../server/load-config.js';\nimport { loadEnvFiles } from '../server/load-env.js';\n\n// The commands are imported where they are dispatched: `build` and `dev` pull in Rspack, and a static import\n// would load it for `start` too ~30 MB of RSS and ~70ms of startup for a command that only spawns a server.\n\nconst HELP = `rshono — Hono + Rspack + React Server Components\n\nUsage:\n rshono dev [--port 3000] start the dev server\n rshono build build for production (client + server + SSG)\n rshono start [--port 3000] run the production build\n\nOptions:\n -p, --port <n> port to listen on (default: PORT env or 3000)\n -c, --config <path> path to a config file (default: rshono.config.{ts,js,mjs})\n -d, --deploy <name> platform to build for: ${DEPLOY_TARGETS.join(' | ')} (default: node)\n -h, --help show this help\n -v, --version print the version\n`;\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n options: {\n port: { type: 'string', short: 'p' },\n config: { type: 'string', short: 'c' },\n deploy: { type: 'string', short: 'd' },\n help: { type: 'boolean', short: 'h' },\n version: { type: 'boolean', short: 'v' },\n },\n allowPositionals: true,\n });\n\n if (values.version) {\n const require = createRequire(import.meta.url);\n const { version } = require('@rshono/core/package.json') as { version: string };\n console.log(version);\n return;\n }\n\n const command = positionals[0];\n if (values.help || !command) {\n console.log(HELP);\n return;\n }\n\n const rootDir = process.cwd();\n loadEnvFiles(rootDir);\n const config = await loadConfig(rootDir, values.config);\n\n const flagPort = values.port ? Number(values.port) : undefined;\n if (values.port && Number.isNaN(flagPort)) {\n console.error(`rshono: invalid --port \"${values.port}\"`);\n process.exit(1);\n }\n // Precedence: --port flag > PORT env > the command's built-in default.\n const envPort = process.env.PORT ? Number(process.env.PORT) : undefined;\n const port = flagPort ?? envPort;\n const host = process.env.HOST;\n\n switch (command) {\n case 'dev':\n return (await import('./dev.js')).devCommand({ rootDir, port, config });\n case 'build':\n return (await import('./build.js')).buildCommand({\n rootDir,\n config,\n preset: resolveDeployPreset({ flag: values.deploy, env: process.env.RSHONO_DEPLOY, config: config.deploy }),\n });\n case 'start':\n return (await import('./start.js')).startCommand({ rootDir, port, host });\n default:\n console.error(`rshono: unknown command \"${command}\"\\n`);\n console.log(HELP);\n process.exit(1);\n }\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCvE"}
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCvE"}
package/dist/cli/start.js CHANGED
@@ -12,9 +12,8 @@ export async function startCommand(options) {
12
12
  console.error('rshono: no production build found — run `rshono build` first.');
13
13
  process.exit(1);
14
14
  }
15
- // A bundle built for a hosting platform has no listener in it its entry hands a `fetch` handler to
16
- // whatever is running it. Starting one here would exit silently the moment the module finished
17
- // evaluating, so say what happened and point at the command that does deploy it.
15
+ // A bundle built for a hosting platform has no listener in it, so starting one here would exit silently the
16
+ // moment the module finished evaluating.
18
17
  const target = readBuildMarker(distDir);
19
18
  if (target !== null && target !== 'node') {
20
19
  const hint = deployHintFor(target);
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqB;IACtD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACrD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;QAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,C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fs';\nimport { join } from 'node:path';\nimport { readBuildMarker } from '../deploy/build-marker.js';\nimport { deployHintFor } from '../deploy/presets.js';\nimport { onShutdown } from '../server/shutdown.js';\n\ninterface StartOptions {\n rootDir: string;\n port?: number;\n host?: string;\n}\n\nexport async function startCommand(options: StartOptions): Promise<void> {\n const { rootDir, port, host } = options;\n const distDir = join(rootDir, 'dist');\n const mainPath = join(distDir, 'server', 'main.mjs');\n if (!existsSync(mainPath)) {\n console.error('rshono: no production build found — run `rshono build` first.');\n process.exit(1);\n }\n\n // A bundle built for a hosting platform has no listener in it its entry hands a `fetch` handler to\n // whatever is running it. Starting one here would exit silently the moment the module finished\n // evaluating, so say what happened and point at the command that does deploy it.\n const target = readBuildMarker(distDir);\n if (target !== null && target !== 'node') {\n const hint = deployHintFor(target);\n console.error(`rshono: this build targets ${target}, which \\`rshono start\\` cannot run${hint ? ` — ${hint}` : '.'}`);\n console.error(' Rebuild for a server with `rshono build --deploy node` to run it here.');\n process.exit(1);\n }\n\n const env = { ...process.env };\n if (port !== undefined) env.PORT = String(port);\n if (host !== undefined) env.HOST = host;\n\n const child = spawn(process.execPath, ['--enable-source-maps', mainPath], {\n stdio: 'inherit',\n env,\n });\n\n onShutdown((signal) => child.kill(signal));\n child.on('exit', (code, signal) => {\n process.exit(signal ? 1 : (code ?? 1));\n });\n}\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,MAAM,CAAC,KAAK,UAAU,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AAC,CAAC;IAEH,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { spawn } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { readBuildMarker } from '../deploy/build-marker.js';\nimport { deployHintFor } from '../deploy/presets.js';\nimport { onShutdown } from '../server/shutdown.js';\n\ninterface StartOptions {\n rootDir: string;\n port?: number;\n host?: string;\n}\n\nexport async function startCommand(options: StartOptions): Promise<void> {\n const { rootDir, port, host } = options;\n const distDir = join(rootDir, 'dist');\n const mainPath = join(distDir, 'server', 'main.mjs');\n if (!existsSync(mainPath)) {\n console.error('rshono: no production build found — run `rshono build` first.');\n process.exit(1);\n }\n\n // A bundle built for a hosting platform has no listener in it, so starting one here would exit silently the\n // moment the module finished evaluating.\n const target = readBuildMarker(distDir);\n if (target !== null && target !== 'node') {\n const hint = deployHintFor(target);\n console.error(`rshono: this build targets ${target}, which \\`rshono start\\` cannot run${hint ? ` — ${hint}` : '.'}`);\n console.error(' Rebuild for a server with `rshono build --deploy node` to run it here.');\n process.exit(1);\n }\n\n const env = { ...process.env };\n if (port !== undefined) env.PORT = String(port);\n if (host !== undefined) env.HOST = host;\n\n const child = spawn(process.execPath, ['--enable-source-maps', mainPath], {\n stdio: 'inherit',\n env,\n });\n\n onShutdown((signal) => child.kill(signal));\n child.on('exit', (code, signal) => {\n process.exit(signal ? 1 : (code ?? 1));\n });\n}\n"]}
package/dist/config.d.ts CHANGED
@@ -8,12 +8,11 @@ export interface RspackHookContext {
8
8
  isDev: boolean;
9
9
  }
10
10
  /**
11
- * Project configuration for rshono, default-exported from `rshono.config.ts` at the project root
12
- * (`.js` / `.mjs` also work). Every field is optional; omit the file entirely to accept all defaults.
11
+ * Project configuration, default-exported from `rshono.config.ts` at the project root (`.js` / `.mjs`
12
+ * also work). Every field is optional; omit the file entirely to accept all defaults.
13
13
  *
14
- * Deliberately small: it holds what only the *build* can decide. Everything that is a per-request
15
- * concern — CSRF, CSP, the body cap — is Hono middleware in `src/server.ts` instead, because Hono
16
- * already ships all of it and a config field would only be a worse way to spell the same call.
14
+ * It holds only what the *build* decides. Per-request concerns CSRF, CSP, the body cap — are Hono
15
+ * middleware in `src/server.ts`, which is where Hono already ships all of them.
17
16
  *
18
17
  * @example
19
18
  * ```ts
@@ -29,45 +28,43 @@ export interface RspackHookContext {
29
28
  */
30
29
  export interface RshonoConfig {
31
30
  /**
32
- * The hosting platform `rshono build` targets. Default `'node'` — a long-lived server process, for
33
- * a VPS, a container or anywhere else you run `rshono start`.
31
+ * The hosting platform `rshono build` targets. Default `'node'` — a long-lived server process run
32
+ * with `rshono start`.
34
33
  *
35
- * Overridden by the `--deploy` flag or the `RSHONO_DEPLOY` env var, so one config can still be
36
- * built for more than one place. `rshono dev` ignores it entirely and always runs the Node dev
37
- * server.
34
+ * Overridden by the `--deploy` flag or the `RSHONO_DEPLOY` env var, so one config can build for more
35
+ * than one place. `rshono dev` ignores it and always runs the Node dev server.
38
36
  *
39
37
  * @see {@link https://www.rshono.com/docs/deployment | Docs — deployment}
40
38
  */
41
39
  deploy?: DeployTarget;
42
40
  /**
43
- * The public origin the site is served from, e.g. `'https://example.com'`.
41
+ * The public origin the site is served from, e.g. `'https://example.com'`. Must be a bare origin —
42
+ * a path is rejected rather than silently dropped.
44
43
  *
45
- * Only used when prerendering `render: 'static'` routes: they are rendered once at build time, with
46
- * no request to read a `Host` from, so a page's `url` prop falls back to `http://localhost` without
47
- * this — and that is what its canonical tag, absolute links and `og:url` get baked with. Dynamic
48
- * routes resolve the URL per request and are unaffected.
49
- *
50
- * Must be a bare origin; a path is rejected rather than silently dropped.
44
+ * Only used when prerendering `render: 'static'` routes, which have no request to read a `Host`
45
+ * from: without it their `url` prop falls back to `http://localhost`, and that is what canonical
46
+ * tags, absolute links and `og:url` get baked with.
51
47
  *
52
48
  * @see {@link https://www.rshono.com/docs/configuration#siteurl | Docs — siteUrl}
53
49
  */
54
50
  siteUrl?: string;
55
51
  /**
56
- * Honour `X-Forwarded-Host` / `X-Forwarded-Proto` when resolving the browser-facing request
57
- * URL — `getRequestContext().url` and a page's `url` prop.
52
+ * Honour `X-Forwarded-Host` / `X-Forwarded-Proto` when resolving the browser-facing request URL —
53
+ * `getRequestContext().url` and a page's `url` prop. Default `false`; always `true` under
54
+ * `rshono dev`.
55
+ *
56
+ * **Enable it only behind a proxy you control**: any client can send those headers, so with nothing
57
+ * stripping them at the edge one request can point every absolute URL the app builds at an
58
+ * attacker's host. Turn it on when you terminate TLS or rewrite `Host` at a reverse proxy.
58
59
  *
59
- * Middleware in `src/server.ts` is handed Hono's `c` and so reads `c.req.url`, the *internal*
60
- * address, whatever this says. Hono's `csrf()` is the one to watch: behind a proxy that rewrites
61
- * `Host`, give it the public origin explicitly (`csrf({ origin: 'https://example.com' })`) rather
62
- * than leaving it to compare against an address the browser never used.
60
+ * Middleware in `src/server.ts` reads Hono's `c.req.url` the *internal* address — whatever this
61
+ * says, so give `csrf()` the public origin explicitly.
63
62
  *
64
- * **Off by default, and leave it off unless a proxy you control sets those headers**: any client
65
- * can send them, so with nothing stripping them at the edge one request can point every absolute
66
- * URL the app builds at an attacker's host (and poison a shared cache). Turn it on when you
67
- * terminate TLS or rewrite `Host` at a reverse proxy / load balancer. Always `true` under
68
- * `rshono dev`, where the framework's own proxy sets them and binds to localhost. Default `false`.
63
+ * @example
64
+ * ```ts
65
+ * export default defineConfig({ trustProxy: true });
66
+ * ```
69
67
  *
70
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Host | MDN — X-Forwarded-Host}
71
68
  * @see {@link https://www.rshono.com/docs/configuration#proxy-headers | Docs — proxy headers}
72
69
  */
73
70
  trustProxy?: boolean;
@@ -89,8 +86,8 @@ export interface RshonoConfig {
89
86
  rspack?: (config: RspackOptions, ctx: RspackHookContext) => RspackOptions | void;
90
87
  }
91
88
  /**
92
- * Identity helper that types a config object gives editor autocomplete without an explicit
93
- * annotation. Default-export the result from `rshono.config.ts`.
89
+ * Types a config object for editor autocomplete, without an explicit annotation. Default-export the
90
+ * result from `rshono.config.ts`.
94
91
  *
95
92
  * @param config - The project's {@link RshonoConfig}; every field is optional.
96
93
  * @returns The config, unchanged and fully typed.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,kGAAkG;AAClG,MAAM,WAAW,iBAAiB;IAChC,oGAAoG;IACpG,QAAQ,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,iBAAiB,KAAK,aAAa,GAAG,IAAI,CAAC;CAClF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,kGAAkG;AAClG,MAAM,WAAW,iBAAiB;IAChC,oGAAoG;IACpG,QAAQ,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;;OAkBG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,iBAAiB,KAAK,aAAa,GAAG,IAAI,CAAC;CAClF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D"}
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Identity helper that types a config object gives editor autocomplete without an explicit
3
- * annotation. Default-export the result from `rshono.config.ts`.
2
+ * Types a config object for editor autocomplete, without an explicit annotation. Default-export the
3
+ * result from `rshono.config.ts`.
4
4
  *
5
5
  * @param config - The project's {@link RshonoConfig}; every field is optional.
6
6
  * @returns The config, unchanged and fully typed.
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA6FA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { RspackOptions } from '@rspack/core';\nimport type { DeployTarget } from './deploy/contract.js';\n\n/** Which of the two Rspack compilers the {@link RshonoConfig.rspack} hook is being called for. */\nexport interface RspackHookContext {\n /** `true` for the server (`target: node`) bundle, `false` for the client (`target: web`) bundle. */\n isServer: boolean;\n /** `true` under `rshono dev`, `false` under `rshono build`. */\n isDev: boolean;\n}\n\n/**\n * Project configuration for rshono, default-exported from `rshono.config.ts` at the project root\n * (`.js` / `.mjs` also work). Every field is optional; omit the file entirely to accept all defaults.\n *\n * Deliberately small: it holds what only the *build* can decide. Everything that is a per-request\n * concern — CSRF, CSP, the body cap — is Hono middleware in `src/server.ts` instead, because Hono\n * already ships all of it and a config field would only be a worse way to spell the same call.\n *\n * @example\n * ```ts\n * import { defineConfig } from '@rshono/core';\n *\n * export default defineConfig({\n * deploy: 'cloudflare',\n * siteUrl: 'https://example.com',\n * });\n * ```\n *\n * @see {@link https://www.rshono.com/docs/configuration | Docs — configuration}\n */\nexport interface RshonoConfig {\n /**\n * The hosting platform `rshono build` targets. Default `'node'` — a long-lived server process, for\n * a VPS, a container or anywhere else you run `rshono start`.\n *\n * Overridden by the `--deploy` flag or the `RSHONO_DEPLOY` env var, so one config can still be\n * built for more than one place. `rshono dev` ignores it entirely and always runs the Node dev\n * server.\n *\n * @see {@link https://www.rshono.com/docs/deployment | Docs — deployment}\n */\n deploy?: DeployTarget;\n /**\n * The public origin the site is served from, e.g. `'https://example.com'`.\n *\n * Only used when prerendering `render: 'static'` routes: they are rendered once at build time, with\n * no request to read a `Host` from, so a page's `url` prop falls back to `http://localhost` without\n * this — and that is what its canonical tag, absolute links and `og:url` get baked with. Dynamic\n * routes resolve the URL per request and are unaffected.\n *\n * Must be a bare origin; a path is rejected rather than silently dropped.\n *\n * @see {@link https://www.rshono.com/docs/configuration#siteurl | Docs — siteUrl}\n */\n siteUrl?: string;\n /**\n * Honour `X-Forwarded-Host` / `X-Forwarded-Proto` when resolving the browser-facing request\n * URL — `getRequestContext().url` and a page's `url` prop.\n *\n * Middleware in `src/server.ts` is handed Hono's `c` and so reads `c.req.url`, the *internal*\n * address, whatever this says. Hono's `csrf()` is the one to watch: behind a proxy that rewrites\n * `Host`, give it the public origin explicitly (`csrf({ origin: 'https://example.com' })`) rather\n * than leaving it to compare against an address the browser never used.\n *\n * **Off by default, and leave it off unless a proxy you control sets those headers**: any client\n * can send them, so with nothing stripping them at the edge one request can point every absolute\n * URL the app builds at an attacker's host (and poison a shared cache). Turn it on when you\n * terminate TLS or rewrite `Host` at a reverse proxy / load balancer. Always `true` under\n * `rshono dev`, where the framework's own proxy sets them and binds to localhost. Default `false`.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Host | MDN X-Forwarded-Host}\n * @see {@link https://www.rshono.com/docs/configuration#proxy-headers | Docs — proxy headers}\n */\n trustProxy?: boolean;\n /**\n * Escape hatch: mutate the generated Rspack config just before it's compiled. Called once per\n * compiler — inspect {@link RspackHookContext.isServer} to tell them apart. Mutate `config` in\n * place and return nothing, or return a replacement.\n *\n * @example\n * ```ts\n * rspack(config, { isServer }) {\n * config.module?.rules?.push({ test: /\\.svg$/, type: 'asset/source' });\n * }\n * ```\n *\n * @see {@link https://rspack.rs/config/ | Rspack — configuration reference}\n * @see {@link https://www.rshono.com/docs/configuration#the-rspack-hook | Docs — the rspack hook}\n */\n rspack?: (config: RspackOptions, ctx: RspackHookContext) => RspackOptions | void;\n}\n\n/**\n * Identity helper that types a config object gives editor autocomplete without an explicit\n * annotation. Default-export the result from `rshono.config.ts`.\n *\n * @param config - The project's {@link RshonoConfig}; every field is optional.\n * @returns The config, unchanged and fully typed.\n *\n * @example\n * ```ts\n * // rshono.config.ts\n * import { defineConfig } from '@rshono/core';\n *\n * export default defineConfig({ deploy: 'cloudflare', siteUrl: 'https://example.com' });\n * ```\n *\n * @see {@link https://www.rshono.com/docs/configuration | Docs — configuration}\n */\nexport function defineConfig(config: RshonoConfig): RshonoConfig {\n return config;\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA0FA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { RspackOptions } from '@rspack/core';\nimport type { DeployTarget } from './deploy/contract.js';\n\n/** Which of the two Rspack compilers the {@link RshonoConfig.rspack} hook is being called for. */\nexport interface RspackHookContext {\n /** `true` for the server (`target: node`) bundle, `false` for the client (`target: web`) bundle. */\n isServer: boolean;\n /** `true` under `rshono dev`, `false` under `rshono build`. */\n isDev: boolean;\n}\n\n/**\n * Project configuration, default-exported from `rshono.config.ts` at the project root (`.js` / `.mjs`\n * also work). Every field is optional; omit the file entirely to accept all defaults.\n *\n * It holds only what the *build* decides. Per-request concerns — CSRF, CSP, the body cap — are Hono\n * middleware in `src/server.ts`, which is where Hono already ships all of them.\n *\n * @example\n * ```ts\n * import { defineConfig } from '@rshono/core';\n *\n * export default defineConfig({\n * deploy: 'cloudflare',\n * siteUrl: 'https://example.com',\n * });\n * ```\n *\n * @see {@link https://www.rshono.com/docs/configuration | Docs — configuration}\n */\nexport interface RshonoConfig {\n /**\n * The hosting platform `rshono build` targets. Default `'node'` — a long-lived server process run\n * with `rshono start`.\n *\n * Overridden by the `--deploy` flag or the `RSHONO_DEPLOY` env var, so one config can build for more\n * than one place. `rshono dev` ignores it and always runs the Node dev server.\n *\n * @see {@link https://www.rshono.com/docs/deployment | Docs — deployment}\n */\n deploy?: DeployTarget;\n /**\n * The public origin the site is served from, e.g. `'https://example.com'`. Must be a bare origin —\n * a path is rejected rather than silently dropped.\n *\n * Only used when prerendering `render: 'static'` routes, which have no request to read a `Host`\n * from: without it their `url` prop falls back to `http://localhost`, and that is what canonical\n * tags, absolute links and `og:url` get baked with.\n *\n * @see {@link https://www.rshono.com/docs/configuration#siteurl | Docs — siteUrl}\n */\n siteUrl?: string;\n /**\n * Honour `X-Forwarded-Host` / `X-Forwarded-Proto` when resolving the browser-facing request URL —\n * `getRequestContext().url` and a page's `url` prop. Default `false`; always `true` under\n * `rshono dev`.\n *\n * **Enable it only behind a proxy you control**: any client can send those headers, so with nothing\n * stripping them at the edge one request can point every absolute URL the app builds at an\n * attacker's host. Turn it on when you terminate TLS or rewrite `Host` at a reverse proxy.\n *\n * Middleware in `src/server.ts` reads Hono's `c.req.url` the *internal* address whatever this\n * says, so give `csrf()` the public origin explicitly.\n *\n * @example\n * ```ts\n * export default defineConfig({ trustProxy: true });\n * ```\n *\n * @see {@link https://www.rshono.com/docs/configuration#proxy-headers | Docs — proxy headers}\n */\n trustProxy?: boolean;\n /**\n * Escape hatch: mutate the generated Rspack config just before it's compiled. Called once per\n * compiler — inspect {@link RspackHookContext.isServer} to tell them apart. Mutate `config` in\n * place and return nothing, or return a replacement.\n *\n * @example\n * ```ts\n * rspack(config, { isServer }) {\n * config.module?.rules?.push({ test: /\\.svg$/, type: 'asset/source' });\n * }\n * ```\n *\n * @see {@link https://rspack.rs/config/ | Rspack — configuration reference}\n * @see {@link https://www.rshono.com/docs/configuration#the-rspack-hook | Docs — the rspack hook}\n */\n rspack?: (config: RspackOptions, ctx: RspackHookContext) => RspackOptions | void;\n}\n\n/**\n * Types a config object for editor autocomplete, without an explicit annotation. Default-export the\n * result from `rshono.config.ts`.\n *\n * @param config - The project's {@link RshonoConfig}; every field is optional.\n * @returns The config, unchanged and fully typed.\n *\n * @example\n * ```ts\n * // rshono.config.ts\n * import { defineConfig } from '@rshono/core';\n *\n * export default defineConfig({ deploy: 'cloudflare', siteUrl: 'https://example.com' });\n * ```\n *\n * @see {@link https://www.rshono.com/docs/configuration | Docs — configuration}\n */\nexport function defineConfig(config: RshonoConfig): RshonoConfig {\n return config;\n}\n"]}
@@ -2,13 +2,11 @@ import type { DeployRuntime } from '../contract.js';
2
2
  /**
3
3
  * AWS Lambda behind a Function URL, in streaming mode.
4
4
  *
5
- * `streamHandle` wraps the app with `awslambda.streamifyResponse`, which is the only way a Lambda can
6
- * write a response progressively — and progressive is the whole point of a streamed SSR shell. It
7
- * requires the Function URL's invoke mode to be `RESPONSE_STREAM`; the buffered `handle` would work
8
- * anywhere but would hold every page until the last byte rendered.
5
+ * `streamHandle` wraps the app with `awslambda.streamifyResponse`, the only way a Lambda writes a response
6
+ * progressively — which is the whole point of a streamed SSR shell. It requires the Function URL's invoke mode
7
+ * to be `RESPONSE_STREAM`; the buffered `handle` would work anywhere but hold every page until its last byte.
9
8
  *
10
- * The filesystem capabilities are Node's: a Lambda unpacks the deployment package onto a read-only
11
- * disk, so `dist/static`, `dist/public` and `dist/ssg` are read exactly as they are on a server.
9
+ * The filesystem capabilities are Node's: a Lambda unpacks the deployment package onto a read-only disk.
12
10
  */
13
11
  export declare const runtime: DeployRuntime;
14
12
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/deploy/aws-lambda/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,EAAE,aASrB,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/deploy/aws-lambda/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,aAQrB,CAAC"}
@@ -3,19 +3,16 @@ import { fileSystemRuntime } from '../filesystem.js';
3
3
  /**
4
4
  * AWS Lambda behind a Function URL, in streaming mode.
5
5
  *
6
- * `streamHandle` wraps the app with `awslambda.streamifyResponse`, which is the only way a Lambda can
7
- * write a response progressively — and progressive is the whole point of a streamed SSR shell. It
8
- * requires the Function URL's invoke mode to be `RESPONSE_STREAM`; the buffered `handle` would work
9
- * anywhere but would hold every page until the last byte rendered.
6
+ * `streamHandle` wraps the app with `awslambda.streamifyResponse`, the only way a Lambda writes a response
7
+ * progressively — which is the whole point of a streamed SSR shell. It requires the Function URL's invoke mode
8
+ * to be `RESPONSE_STREAM`; the buffered `handle` would work anywhere but hold every page until its last byte.
10
9
  *
11
- * The filesystem capabilities are Node's: a Lambda unpacks the deployment package onto a read-only
12
- * disk, so `dist/static`, `dist/public` and `dist/ssg` are read exactly as they are on a server.
10
+ * The filesystem capabilities are Node's: a Lambda unpacks the deployment package onto a read-only disk.
13
11
  */
14
12
  export const runtime = {
15
13
  ...fileSystemRuntime,
16
14
  serveApp(app) {
17
- // `awslambda` is a global the Lambda runtime injects, so it is absent when the build imports this
18
- // bundle to prerender. Returning nothing then keeps that pass working; a real invocation has it.
15
+ // A global the Lambda runtime injects, so it is absent when the build imports this bundle to prerender.
19
16
  if (typeof globalThis.awslambda === 'undefined')
20
17
  return undefined;
21
18
  return streamHandle(app);
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/deploy/aws-lambda/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,GAAG,iBAAiB;IAEpB,QAAQ,CAAC,GAAS;QAChB,kGAAkG;QAClG,iGAAiG;QACjG,IAAI,OAAQ,UAAsC,CAAC,SAAS,KAAK,WAAW;YAAE,OAAO,SAAS,CAAC;QAC/F,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF,CAAC","sourcesContent":["import type { Hono } from 'hono';\nimport { streamHandle } from 'hono/aws-lambda';\nimport type { DeployRuntime } from '../contract.js';\nimport { fileSystemRuntime } from '../filesystem.js';\n\n/**\n * AWS Lambda behind a Function URL, in streaming mode.\n *\n * `streamHandle` wraps the app with `awslambda.streamifyResponse`, which is the only way a Lambda can\n * write a response progressively — and progressive is the whole point of a streamed SSR shell. It\n * requires the Function URL's invoke mode to be `RESPONSE_STREAM`; the buffered `handle` would work\n * anywhere but would hold every page until the last byte rendered.\n *\n * The filesystem capabilities are Node's: a Lambda unpacks the deployment package onto a read-only\n * disk, so `dist/static`, `dist/public` and `dist/ssg` are read exactly as they are on a server.\n */\nexport const runtime: DeployRuntime = {\n ...fileSystemRuntime,\n\n serveApp(app: Hono): unknown {\n // `awslambda` is a global the Lambda runtime injects, so it is absent when the build imports this\n // bundle to prerender. Returning nothing then keeps that pass working; a real invocation has it.\n if (typeof (globalThis as { awslambda?: unknown }).awslambda === 'undefined') return undefined;\n return streamHandle(app);\n },\n};\n"]}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/deploy/aws-lambda/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,GAAG,iBAAiB;IAEpB,QAAQ,CAAC,GAAS;QAChB,wGAAwG;QACxG,IAAI,OAAQ,UAAsC,CAAC,SAAS,KAAK,WAAW;YAAE,OAAO,SAAS,CAAC;QAC/F,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF,CAAC","sourcesContent":["import type { Hono } from 'hono';\nimport { streamHandle } from 'hono/aws-lambda';\nimport type { DeployRuntime } from '../contract.js';\nimport { fileSystemRuntime } from '../filesystem.js';\n\n/**\n * AWS Lambda behind a Function URL, in streaming mode.\n *\n * `streamHandle` wraps the app with `awslambda.streamifyResponse`, the only way a Lambda writes a response\n * progressively — which is the whole point of a streamed SSR shell. It requires the Function URL's invoke mode\n * to be `RESPONSE_STREAM`; the buffered `handle` would work anywhere but hold every page until its last byte.\n *\n * The filesystem capabilities are Node's: a Lambda unpacks the deployment package onto a read-only disk.\n */\nexport const runtime: DeployRuntime = {\n ...fileSystemRuntime,\n\n serveApp(app: Hono): unknown {\n // A global the Lambda runtime injects, so it is absent when the build imports this bundle to prerender.\n if (typeof (globalThis as { awslambda?: unknown }).awslambda === 'undefined') return undefined;\n return streamHandle(app);\n },\n};\n"]}
@@ -5,11 +5,9 @@ export interface BuildMarker {
5
5
  }
6
6
  export declare function writeBuildMarker(distDir: string, deploy: DeployTarget): void;
7
7
  /**
8
- * The target the build in `distDir` was produced for, or `null` when there is nothing to go on.
9
- *
10
- * A missing or unreadable marker is deliberately not an error: a build from an older rshono has none,
11
- * and refusing to start one that would have worked is worse than the confusing failure this guards
12
- * against.
8
+ * The target the build in `distDir` was produced for, or `null` when there is nothing to go on — a missing
9
+ * marker is not an error, since a build from an older rshono has none and refusing to start one that would
10
+ * have worked is worse than the failure this guards against.
13
11
  */
14
12
  export declare function readBuildMarker(distDir: string): DeployTarget | null;
15
13
  //# sourceMappingURL=build-marker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-marker.d.ts","sourceRoot":"","sources":["../../src/deploy/build-marker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,CAAC;CACtB;AAID,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CASpE"}
1
+ {"version":3,"file":"build-marker.d.ts","sourceRoot":"","sources":["../../src/deploy/build-marker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,CAAC;CACtB;AAID,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CASpE"}