@rshono/core 1.0.0-rc.0 → 1.0.0-rc.10
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 +202 -159
- package/dist/builder/page-files.d.ts.map +1 -1
- package/dist/builder/page-files.js +7 -3
- package/dist/builder/page-files.js.map +1 -1
- package/dist/builder/public-env.d.ts +6 -0
- package/dist/builder/public-env.d.ts.map +1 -1
- package/dist/builder/public-env.js +6 -0
- package/dist/builder/public-env.js.map +1 -1
- package/dist/builder/rspack-config.d.ts +3 -3
- package/dist/builder/rspack-config.d.ts.map +1 -1
- package/dist/builder/rspack-config.js +62 -16
- package/dist/builder/rspack-config.js.map +1 -1
- package/dist/cli/build.d.ts +2 -2
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/dev.d.ts +2 -2
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +63 -35
- package/dist/cli/dev.js.map +1 -1
- package/dist/cli/index.js +10 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/config.d.ts +58 -70
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -1
- package/dist/config.js.map +1 -1
- package/dist/deploy/cloudflare/build.js +1 -1
- package/dist/deploy/cloudflare/build.js.map +1 -1
- package/dist/deploy/cloudflare/runtime.d.ts.map +1 -1
- package/dist/deploy/cloudflare/runtime.js +7 -37
- package/dist/deploy/cloudflare/runtime.js.map +1 -1
- package/dist/deploy/contract.d.ts +22 -16
- package/dist/deploy/contract.d.ts.map +1 -1
- package/dist/deploy/contract.js.map +1 -1
- package/dist/deploy/filesystem.d.ts +1 -1
- package/dist/deploy/filesystem.d.ts.map +1 -1
- package/dist/deploy/filesystem.js +7 -10
- package/dist/deploy/filesystem.js.map +1 -1
- package/dist/deploy/node/runtime.d.ts +4 -0
- package/dist/deploy/node/runtime.d.ts.map +1 -1
- package/dist/deploy/node/runtime.js +24 -3
- package/dist/deploy/node/runtime.js.map +1 -1
- package/dist/deploy/presets.d.ts +3 -3
- package/dist/deploy/presets.d.ts.map +1 -1
- package/dist/deploy/presets.js +13 -30
- package/dist/deploy/presets.js.map +1 -1
- package/dist/deploy/vercel/runtime.d.ts.map +1 -1
- package/dist/deploy/vercel/runtime.js +0 -3
- package/dist/deploy/vercel/runtime.js.map +1 -1
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/router.d.ts +85 -48
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +4 -6
- package/dist/router.js.map +1 -1
- package/dist/runtime/boundaries.d.ts +39 -25
- package/dist/runtime/boundaries.d.ts.map +1 -1
- package/dist/runtime/boundaries.js +22 -17
- package/dist/runtime/boundaries.js.map +1 -1
- package/dist/runtime/client.d.ts +9 -8
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +9 -8
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/context.d.ts +216 -70
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js +299 -93
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/control.d.ts.map +1 -1
- package/dist/runtime/control.js +7 -0
- package/dist/runtime/control.js.map +1 -1
- package/dist/runtime/dev-protocol.d.ts.map +1 -1
- package/dist/runtime/dev-protocol.js.map +1 -1
- package/dist/runtime/entry.client.d.ts +4 -0
- package/dist/runtime/entry.client.d.ts.map +1 -1
- package/dist/runtime/entry.client.js +190 -154
- package/dist/runtime/entry.client.js.map +1 -1
- package/dist/runtime/entry.rsc.d.ts.map +1 -1
- package/dist/runtime/entry.rsc.js +145 -159
- package/dist/runtime/entry.rsc.js.map +1 -1
- package/dist/runtime/entry.ssr.d.ts +9 -1
- package/dist/runtime/entry.ssr.d.ts.map +1 -1
- package/dist/runtime/entry.ssr.js +36 -18
- package/dist/runtime/entry.ssr.js.map +1 -1
- package/dist/runtime/flight-inject.d.ts +31 -0
- package/dist/runtime/flight-inject.d.ts.map +1 -0
- package/dist/runtime/flight-inject.js +221 -0
- package/dist/runtime/flight-inject.js.map +1 -0
- package/dist/runtime/navigation.d.ts +20 -38
- package/dist/runtime/navigation.d.ts.map +1 -1
- package/dist/runtime/navigation.js +10 -53
- package/dist/runtime/navigation.js.map +1 -1
- package/dist/runtime/request.d.ts +6 -0
- package/dist/runtime/request.d.ts.map +1 -1
- package/dist/runtime/request.js +8 -0
- package/dist/runtime/request.js.map +1 -1
- package/dist/runtime/server.d.ts +7 -12
- package/dist/runtime/server.d.ts.map +1 -1
- package/dist/runtime/server.js +15 -12
- package/dist/runtime/server.js.map +1 -1
- package/dist/server/headers.d.ts +9 -9
- package/dist/server/headers.js +9 -9
- package/dist/server/headers.js.map +1 -1
- package/dist/server/load-config.d.ts +2 -2
- package/dist/server/load-config.d.ts.map +1 -1
- package/dist/server/load-config.js +22 -11
- package/dist/server/load-config.js.map +1 -1
- package/dist/server/prerendered.d.ts +43 -15
- package/dist/server/prerendered.d.ts.map +1 -1
- package/dist/server/prerendered.js +47 -0
- package/dist/server/prerendered.js.map +1 -1
- package/dist/server/server-config.d.ts +13 -39
- package/dist/server/server-config.d.ts.map +1 -1
- package/dist/server/server-config.js +5 -74
- package/dist/server/server-config.js.map +1 -1
- package/dist/server/ssg.d.ts +2 -2
- package/dist/server/ssg.d.ts.map +1 -1
- package/dist/server/ssg.js +21 -34
- package/dist/server/ssg.js.map +1 -1
- package/package.json +13 -16
- package/dist/deploy/bun/runtime.d.ts +0 -11
- package/dist/deploy/bun/runtime.d.ts.map +0 -1
- package/dist/deploy/bun/runtime.js +0 -22
- package/dist/deploy/bun/runtime.js.map +0 -1
- package/dist/deploy/deno/runtime.d.ts +0 -11
- package/dist/deploy/deno/runtime.d.ts.map +0 -1
- package/dist/deploy/deno/runtime.js +0 -16
- package/dist/deploy/deno/runtime.js.map +0 -1
- package/dist/deploy/listen.d.ts +0 -20
- package/dist/deploy/listen.d.ts.map +0 -1
- package/dist/deploy/listen.js +0 -24
- package/dist/deploy/listen.js.map +0 -1
- package/dist/deploy/netlify/build.d.ts +0 -8
- package/dist/deploy/netlify/build.d.ts.map +0 -1
- package/dist/deploy/netlify/build.js +0 -52
- package/dist/deploy/netlify/build.js.map +0 -1
- package/dist/deploy/netlify/runtime.d.ts +0 -13
- package/dist/deploy/netlify/runtime.d.ts.map +0 -1
- package/dist/deploy/netlify/runtime.js +0 -24
- package/dist/deploy/netlify/runtime.js.map +0 -1
- package/dist/server/compress.d.ts +0 -15
- package/dist/server/compress.d.ts.map +0 -1
- package/dist/server/compress.js +0 -76
- package/dist/server/compress.js.map +0 -1
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { compress } from '../server/compress.js';
|
|
4
3
|
import { loadEnvFiles } from '../server/load-env.js';
|
|
5
4
|
import { readPrerendered } from '../server/ssg.js';
|
|
6
5
|
import { createPublicFallback, createStaticAssetsApp } from '../server/static.js';
|
|
7
6
|
const isDev = __RSHONO_CONFIG__.isDev;
|
|
8
7
|
/**
|
|
9
|
-
* The project root, derived from where the bundle
|
|
10
|
-
*
|
|
11
|
-
* `import.meta.dirname` `<root>/dist/server` at runtime.
|
|
8
|
+
* The project root, derived from where the bundle ended up: this module is compiled into
|
|
9
|
+
* `<root>/dist/server/main.mjs`, so `import.meta.dirname` is `<root>/dist/server` at runtime.
|
|
12
10
|
*
|
|
13
|
-
* Derived rather than baked in at build time
|
|
14
|
-
* output to the machine that produced it
|
|
15
|
-
* A preset that relocates the bundle keeps `dist/server/main.mjs` intact inside its own layout
|
|
16
|
-
* exactly this reason.
|
|
11
|
+
* Derived rather than baked in at build time, because an absolute build-time path would tie the
|
|
12
|
+
* output to the machine that produced it — and building in CI to run somewhere else is the normal
|
|
13
|
+
* case. A preset that relocates the bundle keeps `dist/server/main.mjs` intact inside its own layout
|
|
14
|
+
* for exactly this reason.
|
|
17
15
|
*/
|
|
18
16
|
const rootDir = join(import.meta.dirname, '..', '..');
|
|
19
17
|
const staticDir = join(rootDir, 'dist', 'static');
|
|
@@ -23,7 +21,7 @@ const publicDir = isDev ? join(rootDir, 'public') : join(rootDir, 'dist', 'publi
|
|
|
23
21
|
/**
|
|
24
22
|
* Everything a deploy target with a real filesystem does the same way.
|
|
25
23
|
*
|
|
26
|
-
* Node
|
|
24
|
+
* Node and the serverless runtimes that unpack a bundle onto a read-only disk (Vercel, AWS Lambda)
|
|
27
25
|
* differ only in how the finished app is handed over — so each of those presets is this object plus
|
|
28
26
|
* its own {@link DeployRuntime.serveApp}, and the implementations live once, in `server/`.
|
|
29
27
|
*/
|
|
@@ -39,7 +37,6 @@ export const fileSystemRuntime = {
|
|
|
39
37
|
readPrerendered(c, variant) {
|
|
40
38
|
return readPrerendered(ssgDir, c.req.path, variant);
|
|
41
39
|
},
|
|
42
|
-
compress: compress(),
|
|
43
40
|
loadEnv() {
|
|
44
41
|
loadEnvFiles(rootDir);
|
|
45
42
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../src/deploy/filesystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../src/deploy/filesystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGlF,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEtD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAClD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAC5C,kHAAkH;AAClH,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEpF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,iBAAiB,CAAC,GAAS;QACzB,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,mBAAmB,CAAC,GAAS;QAC3B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO;QACnC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,oBAAoB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,eAAe,CAAC,CAAC,EAAE,OAAO;QACxB,OAAO,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,OAAO;QACL,YAAY,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;CACF,CAAC","sourcesContent":["import type { Hono } from 'hono';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { loadEnvFiles } from '../server/load-env.js';\nimport { readPrerendered } from '../server/ssg.js';\nimport { createPublicFallback, createStaticAssetsApp } from '../server/static.js';\nimport type { DeployRuntime } from './contract.js';\n\nconst isDev = __RSHONO_CONFIG__.isDev;\n\n/**\n * The project root, derived from where the bundle ended up: this module is compiled into\n * `<root>/dist/server/main.mjs`, so `import.meta.dirname` is `<root>/dist/server` at runtime.\n *\n * Derived rather than baked in at build time, because an absolute build-time path would tie the\n * output to the machine that produced it — and building in CI to run somewhere else is the normal\n * case. A preset that relocates the bundle keeps `dist/server/main.mjs` intact inside its own layout\n * for exactly this reason.\n */\nconst rootDir = join(import.meta.dirname, '..', '..');\n\nconst staticDir = join(rootDir, 'dist', 'static');\nconst ssgDir = join(rootDir, 'dist', 'ssg');\n/** `public/` is copied into `dist/` by the build, so a deployed build is self-contained; dev reads the source. */\nconst publicDir = isDev ? join(rootDir, 'public') : join(rootDir, 'dist', 'public');\n\n/**\n * Everything a deploy target with a real filesystem does the same way.\n *\n * Node and the serverless runtimes that unpack a bundle onto a read-only disk (Vercel, AWS Lambda)\n * differ only in how the finished app is handed over — so each of those presets is this object plus\n * its own {@link DeployRuntime.serveApp}, and the implementations live once, in `server/`.\n */\nexport const fileSystemRuntime: Omit<DeployRuntime, 'serveApp'> = {\n mountStaticAssets(app: Hono): void {\n app.route('/_static', createStaticAssetsApp({ root: staticDir, isDev }));\n },\n\n mountPublicFallback(app: Hono): void {\n if (!existsSync(publicDir)) return;\n app.on(['GET', 'HEAD'], '/*', createPublicFallback({ root: publicDir, isDev }));\n },\n\n readPrerendered(c, variant) {\n return readPrerendered(ssgDir, c.req.path, variant);\n },\n\n loadEnv(): void {\n loadEnvFiles(rootDir);\n },\n};\n"]}
|
|
@@ -2,6 +2,10 @@ import type { DeployRuntime } from '../contract.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Node: a long-lived process that owns its own port, with a filesystem behind every asset. The shape
|
|
4
4
|
* the framework was built against, and the only target `rshono dev` ever produces.
|
|
5
|
+
*
|
|
6
|
+
* Anything that runs a Node process runs this build — a VPS, a container, a PaaS — and Bun and Deno
|
|
7
|
+
* are expected to as well, since the listener below is `@hono/node-server` and both implement the
|
|
8
|
+
* `node:` APIs it needs.
|
|
5
9
|
*/
|
|
6
10
|
export declare const runtime: DeployRuntime;
|
|
7
11
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/deploy/node/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/deploy/node/runtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAqBpD;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,aA4BrB,CAAC"}
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { serve } from '@hono/node-server';
|
|
2
2
|
import { parentPort, workerData } from 'node:worker_threads';
|
|
3
|
+
import { SERVER_DEFAULTS } from '../../server/server-config.js';
|
|
3
4
|
import { onShutdown } from '../../server/shutdown.js';
|
|
4
5
|
import { fileSystemRuntime } from '../filesystem.js';
|
|
5
|
-
|
|
6
|
+
/** Bound to every interface — so the address printed on start is `localhost`, not this. */
|
|
7
|
+
const WILDCARD_HOST = '0.0.0.0';
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the address to listen on: an explicit override (the dev server, which picks the port for its
|
|
10
|
+
* worker) beats the environment, which beats the built-in default.
|
|
11
|
+
*
|
|
12
|
+
* `PORT` and `HOST` are the whole interface, because that is the deployment convention everywhere
|
|
13
|
+
* this runs. `??` rather than `||` so an explicit `PORT=0`, meaning "any free port", is honoured.
|
|
14
|
+
*/
|
|
15
|
+
function listenAddress(overrides) {
|
|
16
|
+
const envPort = process.env.PORT !== undefined ? Number(process.env.PORT) : undefined;
|
|
17
|
+
return {
|
|
18
|
+
port: overrides?.port ?? envPort ?? SERVER_DEFAULTS.port,
|
|
19
|
+
hostname: overrides?.hostname ?? process.env.HOST ?? SERVER_DEFAULTS.host,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
6
22
|
/**
|
|
7
23
|
* Node: a long-lived process that owns its own port, with a filesystem behind every asset. The shape
|
|
8
24
|
* the framework was built against, and the only target `rshono dev` ever produces.
|
|
25
|
+
*
|
|
26
|
+
* Anything that runs a Node process runs this build — a VPS, a container, a PaaS — and Bun and Deno
|
|
27
|
+
* are expected to as well, since the listener below is `@hono/node-server` and both implement the
|
|
28
|
+
* `node:` APIs it needs.
|
|
9
29
|
*/
|
|
10
30
|
export const runtime = {
|
|
11
31
|
...fileSystemRuntime,
|
|
@@ -16,7 +36,7 @@ export const runtime = {
|
|
|
16
36
|
if (process.env.RSHONO_PRERENDER)
|
|
17
37
|
return;
|
|
18
38
|
// The dev server runs this bundle in a worker thread and picks the port itself, so its choice wins
|
|
19
|
-
// over
|
|
39
|
+
// over the environment.
|
|
20
40
|
const devWorker = workerData;
|
|
21
41
|
const address = listenAddress(devWorker ?? undefined);
|
|
22
42
|
const server = serve({ fetch: app.fetch, ...address }, (info) => {
|
|
@@ -24,7 +44,8 @@ export const runtime = {
|
|
|
24
44
|
parentPort.postMessage({ type: 'ready', port: info.port });
|
|
25
45
|
}
|
|
26
46
|
else {
|
|
27
|
-
|
|
47
|
+
const host = address.hostname === WILDCARD_HOST ? 'localhost' : address.hostname;
|
|
48
|
+
console.log(` ➜ rshono serving on http://${host}:${info.port}`);
|
|
28
49
|
}
|
|
29
50
|
});
|
|
30
51
|
onShutdown(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/deploy/node/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,iBA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,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;YAC9D,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7D,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACjF,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import { serve } from '@hono/node-server';\nimport type { Hono } from 'hono';\nimport { parentPort, workerData } from 'node:worker_threads';\nimport { SERVER_DEFAULTS } from '../../server/server-config.js';\nimport { onShutdown } from '../../server/shutdown.js';\nimport type { DeployRuntime } from '../contract.js';\nimport { fileSystemRuntime } from '../filesystem.js';\n\n/** Bound to every interface — so the address printed on start is `localhost`, not this. */\nconst WILDCARD_HOST = '0.0.0.0';\n\n/**\n * Resolves the address to listen on: an explicit override (the dev server, which picks the port for its\n * worker) beats the environment, which beats the built-in default.\n *\n * `PORT` and `HOST` are the whole interface, because that is the deployment convention everywhere\n * this runs. `??` rather than `||` so an explicit `PORT=0`, meaning \"any free port\", is honoured.\n */\nfunction listenAddress(overrides?: { port?: number; hostname?: string }): { port: number; hostname: string } {\n const envPort = process.env.PORT !== undefined ? Number(process.env.PORT) : undefined;\n return {\n port: overrides?.port ?? envPort ?? SERVER_DEFAULTS.port,\n hostname: overrides?.hostname ?? process.env.HOST ?? SERVER_DEFAULTS.host,\n };\n}\n\n/**\n * Node: a long-lived process that owns its own port, with a filesystem behind every asset. The shape\n * the framework was built against, and the only target `rshono dev` ever produces.\n *\n * Anything that runs a Node process runs this build — a VPS, a container, a PaaS — and Bun and Deno\n * are expected to as well, since the listener below is `@hono/node-server` and both implement the\n * `node:` APIs it needs.\n */\nexport const runtime: DeployRuntime = {\n ...fileSystemRuntime,\n\n serveApp(app: Hono): undefined {\n // `rshono build` imports this bundle to prerender `render: 'static'` routes. That pass renders\n // through `app.fetch` directly and must not bind a port — nothing is listening for it, and the\n // build would never exit.\n if (process.env.RSHONO_PRERENDER) return;\n\n // The dev server runs this bundle in a worker thread and picks the port itself, so its choice wins\n // over the environment.\n const devWorker = workerData as { port?: number; hostname?: string } | null;\n const address = listenAddress(devWorker ?? undefined);\n\n const server = serve({ fetch: app.fetch, ...address }, (info) => {\n if (parentPort) {\n parentPort.postMessage({ type: 'ready', port: info.port });\n } else {\n const host = address.hostname === WILDCARD_HOST ? 'localhost' : address.hostname;\n console.log(` ➜ rshono serving on http://${host}:${info.port}`);\n }\n });\n\n onShutdown(() => {\n server.close(() => process.exit(0));\n setTimeout(() => process.exit(0), 3000).unref();\n });\n },\n};\n"]}
|
package/dist/deploy/presets.d.ts
CHANGED
|
@@ -57,8 +57,8 @@ export interface DeployPreset {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Node: a long-lived server process. The generated config is already this shape, so the preset has
|
|
60
|
-
* nothing to contribute — the
|
|
61
|
-
*
|
|
60
|
+
* nothing to contribute — the settings in `builder/rspack-config.ts` (`target: 'node'`, the externals
|
|
61
|
+
* policy, ESM chunk output) are the Node ones by default.
|
|
62
62
|
*/
|
|
63
63
|
export declare const NODE_PRESET: DeployPreset;
|
|
64
64
|
/** Every target `deploy` accepts, for error messages and docs. */
|
|
@@ -74,7 +74,7 @@ export interface DeploySources {
|
|
|
74
74
|
flag?: string;
|
|
75
75
|
/** The `RSHONO_DEPLOY` env var — for a CI job that deploys the same app to more than one place. */
|
|
76
76
|
env?: string;
|
|
77
|
-
/** {@link
|
|
77
|
+
/** {@link RshonoConfig.deploy} from `rshono.config.ts`. */
|
|
78
78
|
config?: string;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/deploy/presets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/deploy/presets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,uGAAuG;IACvG,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kGAAkG;IAClG,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,qFAAqF;IACrF,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;;OAIG;IACH,eAAe,CAAC,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC9C;;;;;;OAMG;IACH,QAAQ,CAAC,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1D;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,YAIzB,CAAC;AA4DF,kEAAkE;AAClE,eAAO,MAAM,cAAc,EAA2B,YAAY,EAAE,CAAC;AAErE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3D;AAED,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mGAAmG;IACnG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,aAAkB,GAAG,YAAY,CAS7E"}
|
package/dist/deploy/presets.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { finalizeCloudflareBuild } from './cloudflare/build.js';
|
|
2
|
-
import { finalizeNetlifyBuild } from './netlify/build.js';
|
|
3
2
|
import { finalizeVercelBuild } from './vercel/build.js';
|
|
4
3
|
/**
|
|
5
4
|
* Node: a long-lived server process. The generated config is already this shape, so the preset has
|
|
6
|
-
* nothing to contribute — the
|
|
7
|
-
*
|
|
5
|
+
* nothing to contribute — the settings in `builder/rspack-config.ts` (`target: 'node'`, the externals
|
|
6
|
+
* policy, ESM chunk output) are the Node ones by default.
|
|
8
7
|
*/
|
|
9
8
|
export const NODE_PRESET = {
|
|
10
9
|
name: 'node',
|
|
@@ -36,23 +35,11 @@ const CLOUDFLARE_PRESET = {
|
|
|
36
35
|
finalize: finalizeCloudflareBuild,
|
|
37
36
|
};
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: 'bun',
|
|
45
|
-
runtimeModule: 'deploy/bun/runtime.js',
|
|
46
|
-
deployHint: 'run `bun dist/server/main.mjs`',
|
|
47
|
-
};
|
|
48
|
-
const DENO_PRESET = {
|
|
49
|
-
name: 'deno',
|
|
50
|
-
runtimeModule: 'deploy/deno/runtime.js',
|
|
51
|
-
deployHint: 'run `deno serve -A dist/server/main.mjs`',
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Vercel and Netlify: one Node function behind the platform's CDN, which serves the assets and reaches
|
|
55
|
-
* the function only for a page. Both `finalize` hooks assemble the layout the platform uploads.
|
|
38
|
+
* Vercel: one Node function behind the platform's CDN, which serves the assets and reaches the function
|
|
39
|
+
* only for a page. `finalize` assembles the Build Output API layout the platform uploads — including the
|
|
40
|
+
* `supportsResponseStreaming` flag, without which Vercel buffers the whole response and streamed SSR is
|
|
41
|
+
* silently undone. That flag, and the exact path the bundle has to keep, are the reason this is a preset
|
|
42
|
+
* rather than a snippet in the docs.
|
|
56
43
|
*/
|
|
57
44
|
const VERCEL_PRESET = {
|
|
58
45
|
name: 'vercel',
|
|
@@ -60,13 +47,12 @@ const VERCEL_PRESET = {
|
|
|
60
47
|
deployHint: 'deploy with `vercel deploy --prebuilt`',
|
|
61
48
|
finalize: finalizeVercelBuild,
|
|
62
49
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** AWS Lambda behind a Function URL in `RESPONSE_STREAM` mode — the AWS shape that keeps streaming. */
|
|
50
|
+
/**
|
|
51
|
+
* AWS Lambda behind a Function URL in `RESPONSE_STREAM` mode — the AWS shape that keeps streaming.
|
|
52
|
+
*
|
|
53
|
+
* Same reasoning as Vercel: the runtime wraps the app in `awslambda.streamifyResponse`, and the buffered
|
|
54
|
+
* alternative would deploy fine and then hold every page until its last byte rendered.
|
|
55
|
+
*/
|
|
70
56
|
const AWS_LAMBDA_PRESET = {
|
|
71
57
|
name: 'aws-lambda',
|
|
72
58
|
runtimeModule: 'deploy/aws-lambda/runtime.js',
|
|
@@ -75,10 +61,7 @@ const AWS_LAMBDA_PRESET = {
|
|
|
75
61
|
const PRESETS = {
|
|
76
62
|
node: NODE_PRESET,
|
|
77
63
|
cloudflare: CLOUDFLARE_PRESET,
|
|
78
|
-
bun: BUN_PRESET,
|
|
79
|
-
deno: DENO_PRESET,
|
|
80
64
|
vercel: VERCEL_PRESET,
|
|
81
|
-
netlify: NETLIFY_PRESET,
|
|
82
65
|
'aws-lambda': AWS_LAMBDA_PRESET,
|
|
83
66
|
};
|
|
84
67
|
/** Every target `deploy` accepts, for error messages and docs. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/deploy/presets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA2DxD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,wBAAwB;IACvC,UAAU,EAAE,oBAAoB;CACjC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAiB;IACtC,IAAI,EAAE,YAAY;IAClB,aAAa,EAAE,8BAA8B;IAC7C,UAAU,EAAE,+BAA+B;IAC3C,iBAAiB,EAAE,CAAC,SAAS,CAAC;IAC9B,aAAa,EAAE,C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kE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAmB,CAAC;AAErE;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAQ,OAAoD,CAAC,MAAM,CAAC,EAAE,UAAU,IAAI,IAAI,CAAC;AAC3F,CAAC;AAYD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAkB,EAAE;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IACrF,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAC;IAEhC,MAAM,MAAM,GAAI,OAAoD,CAAC,MAAM,CAAC,CAAC;IAC7E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,uBAAuB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/H,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { RspackOptions } from '@rspack/core';\nimport { finalizeCloudflareBuild } from './cloudflare/build.js';\nimport type { DeployTarget } from './contract.js';\nimport { finalizeNetlifyBuild } from './netlify/build.js';\nimport { finalizeVercelBuild } from './vercel/build.js';\n\n/** What a preset's {@link DeployPreset.finalize} is told about the build it is arranging. */\nexport interface DeployBuildContext {\n /** The project root — where `rshono build` ran, and what a platform config file is written next to. */\n rootDir: string;\n /** `<root>/dist`. */\n distDir: string;\n /** The hashed client bundle, `<root>/dist/static` — served at `/_static`. */\n staticDir: string;\n /** The copy of the app's `public/`, or `null` when it has none. Served at the web root. */\n publicDir: string | null;\n /** Prerendered pages, `<root>/dist/ssg` — empty when the app has no `render: 'static'` routes. */\n ssgDir: string;\n}\n\n/**\n * The build-time half of a deploy target: which runtime module the bundle gets, how the server\n * compiler has to change to produce something the platform can run, and how the output is arranged\n * once it exists.\n *\n * The runtime half is {@link DeployRuntime}, in its own file because it is compiled *into* the app\n * bundle — this side only ever runs in the CLI.\n */\nexport interface DeployPreset {\n readonly name: DeployTarget;\n /**\n * The module `@rshono/deploy` resolves to, as a path relative to the framework's own `dist/`.\n * Slash-separated and split on use, so it stays a valid path on Windows too.\n */\n readonly runtimeModule: string;\n /** How to run what was just built, completing the \"build complete —\" line. */\n readonly deployHint: string;\n /**\n * Extra resolve conditions for the server bundle, most specific first.\n *\n * This is what picks the right build of React and the RSC runtime: both ship one per runtime behind\n * `workerd` / `deno` / `edge-light` / `node` conditions. Omit it to accept whatever the Rspack\n * target implies, which is correct for Node.\n */\n readonly resolveConditions?: readonly string[];\n /** browserslist-style targets for the server bundle's swc pass. Defaults to Node. */\n readonly syntaxTargets?: readonly string[];\n /**\n * Adjusts the generated server Rspack config for this platform — target, externals policy, output\n * shape. Mutates in place, and runs *before* the user's `rspack` hook so that hook keeps the last\n * word.\n */\n configureServer?(config: RspackOptions): void;\n /**\n * Arranges the finished build for the platform: assembles whatever directory layout it expects,\n * emits its config file, and prints how to deploy.\n *\n * Runs last — after both bundles, the `public/` copy and the prerender pass — so everything it\n * needs to move is already on disk.\n */\n finalize?(ctx: DeployBuildContext): Promise<void> | void;\n}\n\n/**\n * Node: a long-lived server process. The generated config is already this shape, so the preset has\n * nothing to contribute — the platform-specific settings still living in `builder/rspack-config.ts`\n * (`target: 'node'`, the externals policy, ESM chunk output) are the Node ones by default.\n */\nexport const NODE_PRESET: DeployPreset = {\n name: 'node',\n runtimeModule: 'deploy/node/runtime.js',\n deployHint: 'run `rshono start`',\n};\n\n/**\n * Cloudflare Workers: the host owns the process, the CDN owns the assets, and there is no filesystem.\n *\n * Every compiler setting here follows from `workerd` not being Node. Dependencies are bundled because\n * nothing resolves `node_modules` at runtime; `node:` and `cloudflare:` imports stay external because\n * the runtime provides them (`nodejs_compat`, which the scaffolded config enables for\n * `AsyncLocalStorage`); and async chunks are inlined because Wrangler's bundler cannot follow the\n * computed specifier Rspack's ESM chunk loader emits — a split bundle would deploy and then fail on\n * the first page render.\n */\nconst CLOUDFLARE_PRESET: DeployPreset = {\n name: 'cloudflare',\n runtimeModule: 'deploy/cloudflare/runtime.js',\n deployHint: 'deploy with `wrangler deploy`',\n resolveConditions: ['workerd'],\n syntaxTargets: ['chrome 120'],\n configureServer(config) {\n config.target = 'webworker';\n config.externalsType = 'module-import';\n config.externals = [/^(?:node|cloudflare):/];\n config.output = { ...config.output, asyncChunks: false };\n },\n finalize: finalizeCloudflareBuild,\n};\n\n/**\n * Bun and Deno: like Node, but the runtime opens the socket from the module's default export. Their\n * `node:` compatibility covers everything `server/` uses, so the bundle is Node's — only the handoff\n * differs, which is precisely the thing an app cannot do for itself.\n */\nconst BUN_PRESET: DeployPreset = {\n name: 'bun',\n runtimeModule: 'deploy/bun/runtime.js',\n deployHint: 'run `bun dist/server/main.mjs`',\n};\n\nconst DENO_PRESET: DeployPreset = {\n name: 'deno',\n runtimeModule: 'deploy/deno/runtime.js',\n deployHint: 'run `deno serve -A dist/server/main.mjs`',\n};\n\n/**\n * Vercel and Netlify: one Node function behind the platform's CDN, which serves the assets and reaches\n * the function only for a page. Both `finalize` hooks assemble the layout the platform uploads.\n */\nconst VERCEL_PRESET: DeployPreset = {\n name: 'vercel',\n runtimeModule: 'deploy/vercel/runtime.js',\n deployHint: 'deploy with `vercel deploy --prebuilt`',\n finalize: finalizeVercelBuild,\n};\n\nconst NETLIFY_PRESET: DeployPreset = {\n name: 'netlify',\n runtimeModule: 'deploy/netlify/runtime.js',\n deployHint: 'deploy with `netlify deploy --build=false --dir=.netlify/publish`',\n finalize: finalizeNetlifyBuild,\n};\n\n/** AWS Lambda behind a Function URL in `RESPONSE_STREAM` mode — the AWS shape that keeps streaming. */\nconst AWS_LAMBDA_PRESET: DeployPreset = {\n name: 'aws-lambda',\n runtimeModule: 'deploy/aws-lambda/runtime.js',\n deployHint: 'zip dist/ with the handler at dist/server/main.mjs',\n};\n\nconst PRESETS: Record<DeployTarget, DeployPreset> = {\n node: NODE_PRESET,\n cloudflare: CLOUDFLARE_PRESET,\n bun: BUN_PRESET,\n deno: DENO_PRESET,\n vercel: VERCEL_PRESET,\n netlify: NETLIFY_PRESET,\n 'aws-lambda': AWS_LAMBDA_PRESET,\n};\n\n/** Every target `deploy` accepts, for error messages and docs. */\nexport const DEPLOY_TARGETS = Object.keys(PRESETS) as DeployTarget[];\n\n/**\n * How to deploy what a given target built, or `null` for a name this rshono does not know — which a\n * `dist/` produced by a newer version can legitimately carry.\n */\nexport function deployHintFor(target: string): string | null {\n return (PRESETS as Record<string, DeployPreset | undefined>)[target]?.deployHint ?? null;\n}\n\n/** Where a deploy target can be named, in precedence order. */\nexport interface DeploySources {\n /** The `--deploy` flag. */\n flag?: string;\n /** The `RSHONO_DEPLOY` env var — for a CI job that deploys the same app to more than one place. */\n env?: string;\n /** {@link RSHonoConfig.deploy} from `rshono.config.ts`. */\n config?: string;\n}\n\n/**\n * Resolves the preset to build with: the flag wins over the environment, which wins over the config\n * file, which wins over the `node` default.\n *\n * Blank values are ignored at every level, so an unset-but-present `RSHONO_DEPLOY=` in a CI\n * environment falls through to the config file instead of failing the build.\n */\nexport function resolveDeployPreset(sources: DeploySources = {}): DeployPreset {\n const target = sources.flag?.trim() || sources.env?.trim() || sources.config?.trim();\n if (!target) return NODE_PRESET;\n\n const preset = (PRESETS as Record<string, DeployPreset | undefined>)[target];\n if (!preset) {\n throw new Error(`[rshono] unknown deploy target ${JSON.stringify(target)} — expected one of: ${DEPLOY_TARGETS.join(', ')}.`);\n }\n return preset;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/deploy/presets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,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M,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAQ,OAAoD,CAAC,MAAM,CAAC,EAAE,UAAU,IAAI,IAAI,CAAC;AAC3F,CAAC;AAYD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAkB,EAAE;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IACrF,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAC;IAEhC,MAAM,MAAM,GAAI,OAAoD,CAAC,MAAM,CAAC,CAAC;IAC7E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,uBAAuB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/H,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { RspackOptions } from '@rspack/core';\nimport { finalizeCloudflareBuild } from './cloudflare/build.js';\nimport type { DeployTarget } from './contract.js';\nimport { finalizeVercelBuild } from './vercel/build.js';\n\n/** What a preset's {@link DeployPreset.finalize} is told about the build it is arranging. */\nexport interface DeployBuildContext {\n /** The project root — where `rshono build` ran, and what a platform config file is written next to. */\n rootDir: string;\n /** `<root>/dist`. */\n distDir: string;\n /** The hashed client bundle, `<root>/dist/static` — served at `/_static`. */\n staticDir: string;\n /** The copy of the app's `public/`, or `null` when it has none. Served at the web root. */\n publicDir: string | null;\n /** Prerendered pages, `<root>/dist/ssg` — empty when the app has no `render: 'static'` routes. */\n ssgDir: string;\n}\n\n/**\n * The build-time half of a deploy target: which runtime module the bundle gets, how the server\n * compiler has to change to produce something the platform can run, and how the output is arranged\n * once it exists.\n *\n * The runtime half is {@link DeployRuntime}, in its own file because it is compiled *into* the app\n * bundle — this side only ever runs in the CLI.\n */\nexport interface DeployPreset {\n readonly name: DeployTarget;\n /**\n * The module `@rshono/deploy` resolves to, as a path relative to the framework's own `dist/`.\n * Slash-separated and split on use, so it stays a valid path on Windows too.\n */\n readonly runtimeModule: string;\n /** How to run what was just built, completing the \"build complete —\" line. */\n readonly deployHint: string;\n /**\n * Extra resolve conditions for the server bundle, most specific first.\n *\n * This is what picks the right build of React and the RSC runtime: both ship one per runtime behind\n * `workerd` / `deno` / `edge-light` / `node` conditions. Omit it to accept whatever the Rspack\n * target implies, which is correct for Node.\n */\n readonly resolveConditions?: readonly string[];\n /** browserslist-style targets for the server bundle's swc pass. Defaults to Node. */\n readonly syntaxTargets?: readonly string[];\n /**\n * Adjusts the generated server Rspack config for this platform — target, externals policy, output\n * shape. Mutates in place, and runs *before* the user's `rspack` hook so that hook keeps the last\n * word.\n */\n configureServer?(config: RspackOptions): void;\n /**\n * Arranges the finished build for the platform: assembles whatever directory layout it expects,\n * emits its config file, and prints how to deploy.\n *\n * Runs last — after both bundles, the `public/` copy and the prerender pass — so everything it\n * needs to move is already on disk.\n */\n finalize?(ctx: DeployBuildContext): Promise<void> | void;\n}\n\n/**\n * Node: a long-lived server process. The generated config is already this shape, so the preset has\n * nothing to contribute — the settings in `builder/rspack-config.ts` (`target: 'node'`, the externals\n * policy, ESM chunk output) are the Node ones by default.\n */\nexport const NODE_PRESET: DeployPreset = {\n name: 'node',\n runtimeModule: 'deploy/node/runtime.js',\n deployHint: 'run `rshono start`',\n};\n\n/**\n * Cloudflare Workers: the host owns the process, the CDN owns the assets, and there is no filesystem.\n *\n * Every compiler setting here follows from `workerd` not being Node. Dependencies are bundled because\n * nothing resolves `node_modules` at runtime; `node:` and `cloudflare:` imports stay external because\n * the runtime provides them (`nodejs_compat`, which the scaffolded config enables for\n * `AsyncLocalStorage`); and async chunks are inlined because Wrangler's bundler cannot follow the\n * computed specifier Rspack's ESM chunk loader emits — a split bundle would deploy and then fail on\n * the first page render.\n */\nconst CLOUDFLARE_PRESET: DeployPreset = {\n name: 'cloudflare',\n runtimeModule: 'deploy/cloudflare/runtime.js',\n deployHint: 'deploy with `wrangler deploy`',\n resolveConditions: ['workerd'],\n syntaxTargets: ['chrome 120'],\n configureServer(config) {\n config.target = 'webworker';\n config.externalsType = 'module-import';\n config.externals = [/^(?:node|cloudflare):/];\n config.output = { ...config.output, asyncChunks: false };\n },\n finalize: finalizeCloudflareBuild,\n};\n\n/**\n * Vercel: one Node function behind the platform's CDN, which serves the assets and reaches the function\n * only for a page. `finalize` assembles the Build Output API layout the platform uploads — including the\n * `supportsResponseStreaming` flag, without which Vercel buffers the whole response and streamed SSR is\n * silently undone. That flag, and the exact path the bundle has to keep, are the reason this is a preset\n * rather than a snippet in the docs.\n */\nconst VERCEL_PRESET: DeployPreset = {\n name: 'vercel',\n runtimeModule: 'deploy/vercel/runtime.js',\n deployHint: 'deploy with `vercel deploy --prebuilt`',\n finalize: finalizeVercelBuild,\n};\n\n/**\n * AWS Lambda behind a Function URL in `RESPONSE_STREAM` mode — the AWS shape that keeps streaming.\n *\n * Same reasoning as Vercel: the runtime wraps the app in `awslambda.streamifyResponse`, and the buffered\n * alternative would deploy fine and then hold every page until its last byte rendered.\n */\nconst AWS_LAMBDA_PRESET: DeployPreset = {\n name: 'aws-lambda',\n runtimeModule: 'deploy/aws-lambda/runtime.js',\n deployHint: 'zip dist/ with the handler at dist/server/main.mjs',\n};\n\nconst PRESETS: Record<DeployTarget, DeployPreset> = {\n node: NODE_PRESET,\n cloudflare: CLOUDFLARE_PRESET,\n vercel: VERCEL_PRESET,\n 'aws-lambda': AWS_LAMBDA_PRESET,\n};\n\n/** Every target `deploy` accepts, for error messages and docs. */\nexport const DEPLOY_TARGETS = Object.keys(PRESETS) as DeployTarget[];\n\n/**\n * How to deploy what a given target built, or `null` for a name this rshono does not know — which a\n * `dist/` produced by a newer version can legitimately carry.\n */\nexport function deployHintFor(target: string): string | null {\n return (PRESETS as Record<string, DeployPreset | undefined>)[target]?.deployHint ?? null;\n}\n\n/** Where a deploy target can be named, in precedence order. */\nexport interface DeploySources {\n /** The `--deploy` flag. */\n flag?: string;\n /** The `RSHONO_DEPLOY` env var — for a CI job that deploys the same app to more than one place. */\n env?: string;\n /** {@link RshonoConfig.deploy} from `rshono.config.ts`. */\n config?: string;\n}\n\n/**\n * Resolves the preset to build with: the flag wins over the environment, which wins over the config\n * file, which wins over the `node` default.\n *\n * Blank values are ignored at every level, so an unset-but-present `RSHONO_DEPLOY=` in a CI\n * environment falls through to the config file instead of failing the build.\n */\nexport function resolveDeployPreset(sources: DeploySources = {}): DeployPreset {\n const target = sources.flag?.trim() || sources.env?.trim() || sources.config?.trim();\n if (!target) return NODE_PRESET;\n\n const preset = (PRESETS as Record<string, DeployPreset | undefined>)[target];\n if (!preset) {\n throw new Error(`[rshono] unknown deploy target ${JSON.stringify(target)} — expected one of: ${DEPLOY_TARGETS.join(', ')}.`);\n }\n return preset;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/deploy/vercel/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/deploy/vercel/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,EAAE,aAUrB,CAAC"}
|
|
@@ -19,8 +19,5 @@ export const runtime = {
|
|
|
19
19
|
serveApp(app) {
|
|
20
20
|
return handle(app);
|
|
21
21
|
},
|
|
22
|
-
// Vercel compresses at the edge. Its Node runtime does support streaming, so the framework's own
|
|
23
|
-
// streamed SSR still reaches the browser progressively.
|
|
24
|
-
compress: null,
|
|
25
22
|
};
|
|
26
23
|
//# sourceMappingURL=runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/deploy/vercel/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,GAAG,iBAAiB;IAEpB,iBAAiB;QACf,gEAAgE;IAClE,CAAC;IAED,QAAQ,CAAC,GAAS;QAChB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/deploy/vercel/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkB;IACpC,GAAG,iBAAiB;IAEpB,iBAAiB;QACf,gEAAgE;IAClE,CAAC;IAED,QAAQ,CAAC,GAAS;QAChB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;CACF,CAAC","sourcesContent":["import type { Hono } from 'hono';\nimport { handle } from 'hono/vercel';\nimport type { DeployRuntime } from '../contract.js';\nimport { fileSystemRuntime } from '../filesystem.js';\n\n/**\n * Vercel, as a single Node function fed by the platform's own router.\n *\n * `/_static` and `public/` are in the static output, and `config.json` puts the filesystem handler\n * ahead of the function — so the CDN answers them and the function is never invoked for an asset,\n * which is why mounting them here would only be dead weight.\n *\n * Prerendered pages are *not* static output: one URL answers with a document or a flight payload\n * depending on `Accept`, and a path-keyed CDN cannot choose. They ship inside the function instead and\n * are read from its read-only disk, exactly as on a server.\n */\nexport const runtime: DeployRuntime = {\n ...fileSystemRuntime,\n\n mountStaticAssets(): void {\n // Served from `.vercel/output/static` before the function runs.\n },\n\n serveApp(app: Hono): unknown {\n return handle(app);\n },\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,19 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
* The two companion entry points are runtime-only:
|
|
7
7
|
* - `@rshono/core/server` — {@link https://hono.dev | Hono} request context inside
|
|
8
|
-
* server components and actions (`
|
|
8
|
+
* server components and actions (`getRequestContext`, `redirect`, `notFound`), plus
|
|
9
9
|
* `onServerError` for reporting the errors the framework catches.
|
|
10
10
|
* - `@rshono/core/client` — hooks and components for `'use client'` modules
|
|
11
|
-
* (`useNavigation`, `
|
|
11
|
+
* (`useNavigation`, `AsyncBoundary`, `CatchBoundary`).
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://www.rshono.com/docs/api | Docs — API reference}
|
|
12
14
|
*
|
|
13
15
|
* @packageDocumentation
|
|
14
16
|
*/
|
|
15
|
-
export { defineRoutes,
|
|
16
|
-
export { defineConfig, type
|
|
17
|
+
export { defineRoutes, type EndpointRoute, type EndpointServerModule, type ErrorPageInfo, type ErrorPageProps, type FallbackPage, type HTTPMethod, type PageComponent, type PageProps, type PageRoute, type PathParams, type Route, type RouteConfig, } from './router.js';
|
|
18
|
+
export { defineConfig, type RshonoConfig, type RspackHookContext } from './config.js';
|
|
17
19
|
export type { DeployTarget } from './deploy/contract.js';
|
|
18
|
-
/**
|
|
19
|
-
* Re-exported from Hono for convenience, so an endpoint module can type its
|
|
20
|
-
* `handler` without depending on `hono` directly.
|
|
21
|
-
*/
|
|
22
|
-
export type { Context, Handler } from 'hono';
|
|
23
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEtF,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
*
|
|
6
6
|
* The two companion entry points are runtime-only:
|
|
7
7
|
* - `@rshono/core/server` — {@link https://hono.dev | Hono} request context inside
|
|
8
|
-
* server components and actions (`
|
|
8
|
+
* server components and actions (`getRequestContext`, `redirect`, `notFound`), plus
|
|
9
9
|
* `onServerError` for reporting the errors the framework catches.
|
|
10
10
|
* - `@rshono/core/client` — hooks and components for `'use client'` modules
|
|
11
|
-
* (`useNavigation`, `
|
|
11
|
+
* (`useNavigation`, `AsyncBoundary`, `CatchBoundary`).
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://www.rshono.com/docs/api | Docs — API reference}
|
|
12
14
|
*
|
|
13
15
|
* @packageDocumentation
|
|
14
16
|
*/
|
|
15
|
-
export { defineRoutes,
|
|
17
|
+
export { defineRoutes, } from './router.js';
|
|
16
18
|
export { defineConfig } from './config.js';
|
|
19
|
+
// Hono's `Context` and `Handler` are deliberately not re-exported: `hono` is a peer dependency every
|
|
20
|
+
// app already has, so an endpoint module imports them from there rather than choosing between two
|
|
21
|
+
// spellings of the same type.
|
|
17
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,YAAY,GAab,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAA6C,MAAM,aAAa,CAAC;AAItF,qGAAqG;AACrG,kGAAkG;AAClG,8BAA8B","sourcesContent":["/**\n * `@rshono/core` — the build-time surface: route and config declaration plus the types\n * your pages and endpoints are written against. Everything here is safe to\n * import from server code; none of it pulls in runtime machinery.\n *\n * The two companion entry points are runtime-only:\n * - `@rshono/core/server` — {@link https://hono.dev | Hono} request context inside\n * server components and actions (`getRequestContext`, `redirect`, `notFound`), plus\n * `onServerError` for reporting the errors the framework catches.\n * - `@rshono/core/client` — hooks and components for `'use client'` modules\n * (`useNavigation`, `AsyncBoundary`, `CatchBoundary`).\n *\n * @see {@link https://www.rshono.com/docs/api | Docs — API reference}\n *\n * @packageDocumentation\n */\n\nexport {\n defineRoutes,\n type EndpointRoute,\n type EndpointServerModule,\n type ErrorPageInfo,\n type ErrorPageProps,\n type FallbackPage,\n type HTTPMethod,\n type PageComponent,\n type PageProps,\n type PageRoute,\n type PathParams,\n type Route,\n type RouteConfig,\n} from './router.js';\n\nexport { defineConfig, type RshonoConfig, type RspackHookContext } from './config.js';\n\nexport type { DeployTarget } from './deploy/contract.js';\n\n// Hono's `Context` and `Handler` are deliberately not re-exported: `hono` is a peer dependency every\n// app already has, so an endpoint module imports them from there rather than choosing between two\n// spellings of the same type.\n"]}
|