@rshono/core 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +273 -0
- package/bin/rshono.mjs +15 -0
- package/dist/builder/env-shadow-loader.cjs +26 -0
- package/dist/builder/page-entry-loader.cjs +7 -0
- package/dist/builder/page-files.d.ts +2 -0
- package/dist/builder/page-files.d.ts.map +1 -0
- package/dist/builder/page-files.js +45 -0
- package/dist/builder/page-files.js.map +1 -0
- package/dist/builder/public-env.d.ts +2 -0
- package/dist/builder/public-env.d.ts.map +1 -0
- package/dist/builder/public-env.js +5 -0
- package/dist/builder/public-env.js.map +1 -0
- package/dist/builder/rspack-config.d.ts +14 -0
- package/dist/builder/rspack-config.d.ts.map +1 -0
- package/dist/builder/rspack-config.js +235 -0
- package/dist/builder/rspack-config.js.map +1 -0
- package/dist/cli/build.d.ts +11 -0
- package/dist/cli/build.d.ts.map +1 -0
- package/dist/cli/build.js +64 -0
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/dev.d.ts +9 -0
- package/dist/cli/dev.d.ts.map +1 -0
- package/dist/cli/dev.js +210 -0
- package/dist/cli/dev.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +77 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/start.d.ts +8 -0
- package/dist/cli/start.d.ts.map +1 -0
- package/dist/cli/start.js +39 -0
- package/dist/cli/start.js.map +1 -0
- package/dist/config.d.ts +121 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -0
- package/dist/deploy/aws-lambda/runtime.d.ts +14 -0
- package/dist/deploy/aws-lambda/runtime.d.ts.map +1 -0
- package/dist/deploy/aws-lambda/runtime.js +24 -0
- package/dist/deploy/aws-lambda/runtime.js.map +1 -0
- package/dist/deploy/build-marker.d.ts +15 -0
- package/dist/deploy/build-marker.d.ts.map +1 -0
- package/dist/deploy/build-marker.js +26 -0
- package/dist/deploy/build-marker.js.map +1 -0
- package/dist/deploy/bun/runtime.d.ts +11 -0
- package/dist/deploy/bun/runtime.d.ts.map +1 -0
- package/dist/deploy/bun/runtime.js +22 -0
- package/dist/deploy/bun/runtime.js.map +1 -0
- package/dist/deploy/cloudflare/build.d.ts +7 -0
- package/dist/deploy/cloudflare/build.d.ts.map +1 -0
- package/dist/deploy/cloudflare/build.js +74 -0
- package/dist/deploy/cloudflare/build.js.map +1 -0
- package/dist/deploy/cloudflare/runtime.d.ts +10 -0
- package/dist/deploy/cloudflare/runtime.d.ts.map +1 -0
- package/dist/deploy/cloudflare/runtime.js +129 -0
- package/dist/deploy/cloudflare/runtime.js.map +1 -0
- package/dist/deploy/contract.d.ts +65 -0
- package/dist/deploy/contract.d.ts.map +1 -0
- package/dist/deploy/contract.js +2 -0
- package/dist/deploy/contract.js.map +1 -0
- package/dist/deploy/deno/runtime.d.ts +11 -0
- package/dist/deploy/deno/runtime.d.ts.map +1 -0
- package/dist/deploy/deno/runtime.js +16 -0
- package/dist/deploy/deno/runtime.js.map +1 -0
- package/dist/deploy/filesystem.d.ts +10 -0
- package/dist/deploy/filesystem.d.ts.map +1 -0
- package/dist/deploy/filesystem.js +47 -0
- package/dist/deploy/filesystem.js.map +1 -0
- package/dist/deploy/listen.d.ts +20 -0
- package/dist/deploy/listen.d.ts.map +1 -0
- package/dist/deploy/listen.js +24 -0
- package/dist/deploy/listen.js.map +1 -0
- package/dist/deploy/netlify/build.d.ts +8 -0
- package/dist/deploy/netlify/build.d.ts.map +1 -0
- package/dist/deploy/netlify/build.js +52 -0
- package/dist/deploy/netlify/build.js.map +1 -0
- package/dist/deploy/netlify/runtime.d.ts +13 -0
- package/dist/deploy/netlify/runtime.d.ts.map +1 -0
- package/dist/deploy/netlify/runtime.js +24 -0
- package/dist/deploy/netlify/runtime.js.map +1 -0
- package/dist/deploy/node/runtime.d.ts +7 -0
- package/dist/deploy/node/runtime.d.ts.map +1 -0
- package/dist/deploy/node/runtime.js +36 -0
- package/dist/deploy/node/runtime.js.map +1 -0
- package/dist/deploy/presets.d.ts +88 -0
- package/dist/deploy/presets.d.ts.map +1 -0
- package/dist/deploy/presets.js +110 -0
- package/dist/deploy/presets.js.map +1 -0
- package/dist/deploy/vercel/build.d.ts +3 -0
- package/dist/deploy/vercel/build.d.ts.map +1 -0
- package/dist/deploy/vercel/build.js +56 -0
- package/dist/deploy/vercel/build.js.map +1 -0
- package/dist/deploy/vercel/runtime.d.ts +14 -0
- package/dist/deploy/vercel/runtime.d.ts.map +1 -0
- package/dist/deploy/vercel/runtime.js +26 -0
- package/dist/deploy/vercel/runtime.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/router.d.ts +337 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +18 -0
- package/dist/router.js.map +1 -0
- package/dist/runtime/boundaries.d.ts +102 -0
- package/dist/runtime/boundaries.d.ts.map +1 -0
- package/dist/runtime/boundaries.js +101 -0
- package/dist/runtime/boundaries.js.map +1 -0
- package/dist/runtime/client.d.ts +16 -0
- package/dist/runtime/client.d.ts.map +1 -0
- package/dist/runtime/client.js +16 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/context.d.ts +271 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +360 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/control.d.ts +18 -0
- package/dist/runtime/control.d.ts.map +1 -0
- package/dist/runtime/control.js +39 -0
- package/dist/runtime/control.js.map +1 -0
- package/dist/runtime/dev-protocol.d.ts +22 -0
- package/dist/runtime/dev-protocol.d.ts.map +1 -0
- package/dist/runtime/dev-protocol.js +2 -0
- package/dist/runtime/dev-protocol.js.map +1 -0
- package/dist/runtime/empty-server-app.d.ts +3 -0
- package/dist/runtime/empty-server-app.d.ts.map +1 -0
- package/dist/runtime/empty-server-app.js +2 -0
- package/dist/runtime/empty-server-app.js.map +1 -0
- package/dist/runtime/entry.client.d.ts +2 -0
- package/dist/runtime/entry.client.d.ts.map +1 -0
- package/dist/runtime/entry.client.js +453 -0
- package/dist/runtime/entry.client.js.map +1 -0
- package/dist/runtime/entry.rsc.d.ts +32 -0
- package/dist/runtime/entry.rsc.d.ts.map +1 -0
- package/dist/runtime/entry.rsc.js +466 -0
- package/dist/runtime/entry.rsc.js.map +1 -0
- package/dist/runtime/entry.ssr.d.ts +25 -0
- package/dist/runtime/entry.ssr.d.ts.map +1 -0
- package/dist/runtime/entry.ssr.js +86 -0
- package/dist/runtime/entry.ssr.js.map +1 -0
- package/dist/runtime/navigation.d.ts +114 -0
- package/dist/runtime/navigation.d.ts.map +1 -0
- package/dist/runtime/navigation.js +112 -0
- package/dist/runtime/navigation.js.map +1 -0
- package/dist/runtime/request.d.ts +35 -0
- package/dist/runtime/request.d.ts.map +1 -0
- package/dist/runtime/request.js +39 -0
- package/dist/runtime/request.js.map +1 -0
- package/dist/runtime/server.d.ts +24 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +24 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/server/compress.d.ts +15 -0
- package/dist/server/compress.d.ts.map +1 -0
- package/dist/server/compress.js +76 -0
- package/dist/server/compress.js.map +1 -0
- package/dist/server/headers.d.ts +24 -0
- package/dist/server/headers.d.ts.map +1 -0
- package/dist/server/headers.js +44 -0
- package/dist/server/headers.js.map +1 -0
- package/dist/server/load-config.d.ts +7 -0
- package/dist/server/load-config.d.ts.map +1 -0
- package/dist/server/load-config.js +41 -0
- package/dist/server/load-config.js.map +1 -0
- package/dist/server/load-env.d.ts +2 -0
- package/dist/server/load-env.d.ts.map +1 -0
- package/dist/server/load-env.js +10 -0
- package/dist/server/load-env.js.map +1 -0
- package/dist/server/prerendered.d.ts +67 -0
- package/dist/server/prerendered.d.ts.map +1 -0
- package/dist/server/prerendered.js +39 -0
- package/dist/server/prerendered.js.map +1 -0
- package/dist/server/server-config.d.ts +72 -0
- package/dist/server/server-config.d.ts.map +1 -0
- package/dist/server/server-config.js +94 -0
- package/dist/server/server-config.js.map +1 -0
- package/dist/server/shutdown.d.ts +7 -0
- package/dist/server/shutdown.d.ts.map +1 -0
- package/dist/server/shutdown.js +11 -0
- package/dist/server/shutdown.js.map +1 -0
- package/dist/server/ssg.d.ts +25 -0
- package/dist/server/ssg.d.ts.map +1 -0
- package/dist/server/ssg.js +160 -0
- package/dist/server/ssg.js.map +1 -0
- package/dist/server/static.d.ts +14 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +30 -0
- package/dist/server/static.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { RspackOptions } from '@rspack/core';
|
|
2
|
+
import type { DeployTarget } from './contract.js';
|
|
3
|
+
/** What a preset's {@link DeployPreset.finalize} is told about the build it is arranging. */
|
|
4
|
+
export interface DeployBuildContext {
|
|
5
|
+
/** The project root — where `rshono build` ran, and what a platform config file is written next to. */
|
|
6
|
+
rootDir: string;
|
|
7
|
+
/** `<root>/dist`. */
|
|
8
|
+
distDir: string;
|
|
9
|
+
/** The hashed client bundle, `<root>/dist/static` — served at `/_static`. */
|
|
10
|
+
staticDir: string;
|
|
11
|
+
/** The copy of the app's `public/`, or `null` when it has none. Served at the web root. */
|
|
12
|
+
publicDir: string | null;
|
|
13
|
+
/** Prerendered pages, `<root>/dist/ssg` — empty when the app has no `render: 'static'` routes. */
|
|
14
|
+
ssgDir: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The build-time half of a deploy target: which runtime module the bundle gets, how the server
|
|
18
|
+
* compiler has to change to produce something the platform can run, and how the output is arranged
|
|
19
|
+
* once it exists.
|
|
20
|
+
*
|
|
21
|
+
* The runtime half is {@link DeployRuntime}, in its own file because it is compiled *into* the app
|
|
22
|
+
* bundle — this side only ever runs in the CLI.
|
|
23
|
+
*/
|
|
24
|
+
export interface DeployPreset {
|
|
25
|
+
readonly name: DeployTarget;
|
|
26
|
+
/**
|
|
27
|
+
* The module `@rshono/deploy` resolves to, as a path relative to the framework's own `dist/`.
|
|
28
|
+
* Slash-separated and split on use, so it stays a valid path on Windows too.
|
|
29
|
+
*/
|
|
30
|
+
readonly runtimeModule: string;
|
|
31
|
+
/** How to run what was just built, completing the "build complete —" line. */
|
|
32
|
+
readonly deployHint: string;
|
|
33
|
+
/**
|
|
34
|
+
* Extra resolve conditions for the server bundle, most specific first.
|
|
35
|
+
*
|
|
36
|
+
* This is what picks the right build of React and the RSC runtime: both ship one per runtime behind
|
|
37
|
+
* `workerd` / `deno` / `edge-light` / `node` conditions. Omit it to accept whatever the Rspack
|
|
38
|
+
* target implies, which is correct for Node.
|
|
39
|
+
*/
|
|
40
|
+
readonly resolveConditions?: readonly string[];
|
|
41
|
+
/** browserslist-style targets for the server bundle's swc pass. Defaults to Node. */
|
|
42
|
+
readonly syntaxTargets?: readonly string[];
|
|
43
|
+
/**
|
|
44
|
+
* Adjusts the generated server Rspack config for this platform — target, externals policy, output
|
|
45
|
+
* shape. Mutates in place, and runs *before* the user's `rspack` hook so that hook keeps the last
|
|
46
|
+
* word.
|
|
47
|
+
*/
|
|
48
|
+
configureServer?(config: RspackOptions): void;
|
|
49
|
+
/**
|
|
50
|
+
* Arranges the finished build for the platform: assembles whatever directory layout it expects,
|
|
51
|
+
* emits its config file, and prints how to deploy.
|
|
52
|
+
*
|
|
53
|
+
* Runs last — after both bundles, the `public/` copy and the prerender pass — so everything it
|
|
54
|
+
* needs to move is already on disk.
|
|
55
|
+
*/
|
|
56
|
+
finalize?(ctx: DeployBuildContext): Promise<void> | void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Node: a long-lived server process. The generated config is already this shape, so the preset has
|
|
60
|
+
* nothing to contribute — the platform-specific settings still living in `builder/rspack-config.ts`
|
|
61
|
+
* (`target: 'node'`, the externals policy, ESM chunk output) are the Node ones by default.
|
|
62
|
+
*/
|
|
63
|
+
export declare const NODE_PRESET: DeployPreset;
|
|
64
|
+
/** Every target `deploy` accepts, for error messages and docs. */
|
|
65
|
+
export declare const DEPLOY_TARGETS: DeployTarget[];
|
|
66
|
+
/**
|
|
67
|
+
* How to deploy what a given target built, or `null` for a name this rshono does not know — which a
|
|
68
|
+
* `dist/` produced by a newer version can legitimately carry.
|
|
69
|
+
*/
|
|
70
|
+
export declare function deployHintFor(target: string): string | null;
|
|
71
|
+
/** Where a deploy target can be named, in precedence order. */
|
|
72
|
+
export interface DeploySources {
|
|
73
|
+
/** The `--deploy` flag. */
|
|
74
|
+
flag?: string;
|
|
75
|
+
/** The `RSHONO_DEPLOY` env var — for a CI job that deploys the same app to more than one place. */
|
|
76
|
+
env?: string;
|
|
77
|
+
/** {@link RSHonoConfig.deploy} from `rshono.config.ts`. */
|
|
78
|
+
config?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolves the preset to build with: the flag wins over the environment, which wins over the config
|
|
82
|
+
* file, which wins over the `node` default.
|
|
83
|
+
*
|
|
84
|
+
* Blank values are ignored at every level, so an unset-but-present `RSHONO_DEPLOY=` in a CI
|
|
85
|
+
* environment falls through to the config file instead of failing the build.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveDeployPreset(sources?: DeploySources): DeployPreset;
|
|
88
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +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;AAIlD,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,uGAAuG;IACvG,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,6EA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
import { finalizeCloudflareBuild } from './cloudflare/build.js';
|
|
2
|
+
import { finalizeNetlifyBuild } from './netlify/build.js';
|
|
3
|
+
import { finalizeVercelBuild } from './vercel/build.js';
|
|
4
|
+
/**
|
|
5
|
+
* Node: a long-lived server process. The generated config is already this shape, so the preset has
|
|
6
|
+
* nothing to contribute — the platform-specific settings still living in `builder/rspack-config.ts`
|
|
7
|
+
* (`target: 'node'`, the externals policy, ESM chunk output) are the Node ones by default.
|
|
8
|
+
*/
|
|
9
|
+
export const NODE_PRESET = {
|
|
10
|
+
name: 'node',
|
|
11
|
+
runtimeModule: 'deploy/node/runtime.js',
|
|
12
|
+
deployHint: 'run `rshono start`',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Cloudflare Workers: the host owns the process, the CDN owns the assets, and there is no filesystem.
|
|
16
|
+
*
|
|
17
|
+
* Every compiler setting here follows from `workerd` not being Node. Dependencies are bundled because
|
|
18
|
+
* nothing resolves `node_modules` at runtime; `node:` and `cloudflare:` imports stay external because
|
|
19
|
+
* the runtime provides them (`nodejs_compat`, which the scaffolded config enables for
|
|
20
|
+
* `AsyncLocalStorage`); and async chunks are inlined because Wrangler's bundler cannot follow the
|
|
21
|
+
* computed specifier Rspack's ESM chunk loader emits — a split bundle would deploy and then fail on
|
|
22
|
+
* the first page render.
|
|
23
|
+
*/
|
|
24
|
+
const CLOUDFLARE_PRESET = {
|
|
25
|
+
name: 'cloudflare',
|
|
26
|
+
runtimeModule: 'deploy/cloudflare/runtime.js',
|
|
27
|
+
deployHint: 'deploy with `wrangler deploy`',
|
|
28
|
+
resolveConditions: ['workerd'],
|
|
29
|
+
syntaxTargets: ['chrome 120'],
|
|
30
|
+
configureServer(config) {
|
|
31
|
+
config.target = 'webworker';
|
|
32
|
+
config.externalsType = 'module-import';
|
|
33
|
+
config.externals = [/^(?:node|cloudflare):/];
|
|
34
|
+
config.output = { ...config.output, asyncChunks: false };
|
|
35
|
+
},
|
|
36
|
+
finalize: finalizeCloudflareBuild,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Bun and Deno: like Node, but the runtime opens the socket from the module's default export. Their
|
|
40
|
+
* `node:` compatibility covers everything `server/` uses, so the bundle is Node's — only the handoff
|
|
41
|
+
* differs, which is precisely the thing an app cannot do for itself.
|
|
42
|
+
*/
|
|
43
|
+
const BUN_PRESET = {
|
|
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.
|
|
56
|
+
*/
|
|
57
|
+
const VERCEL_PRESET = {
|
|
58
|
+
name: 'vercel',
|
|
59
|
+
runtimeModule: 'deploy/vercel/runtime.js',
|
|
60
|
+
deployHint: 'deploy with `vercel deploy --prebuilt`',
|
|
61
|
+
finalize: finalizeVercelBuild,
|
|
62
|
+
};
|
|
63
|
+
const NETLIFY_PRESET = {
|
|
64
|
+
name: 'netlify',
|
|
65
|
+
runtimeModule: 'deploy/netlify/runtime.js',
|
|
66
|
+
deployHint: 'deploy with `netlify deploy --build=false --dir=.netlify/publish`',
|
|
67
|
+
finalize: finalizeNetlifyBuild,
|
|
68
|
+
};
|
|
69
|
+
/** AWS Lambda behind a Function URL in `RESPONSE_STREAM` mode — the AWS shape that keeps streaming. */
|
|
70
|
+
const AWS_LAMBDA_PRESET = {
|
|
71
|
+
name: 'aws-lambda',
|
|
72
|
+
runtimeModule: 'deploy/aws-lambda/runtime.js',
|
|
73
|
+
deployHint: 'zip dist/ with the handler at dist/server/main.mjs',
|
|
74
|
+
};
|
|
75
|
+
const PRESETS = {
|
|
76
|
+
node: NODE_PRESET,
|
|
77
|
+
cloudflare: CLOUDFLARE_PRESET,
|
|
78
|
+
bun: BUN_PRESET,
|
|
79
|
+
deno: DENO_PRESET,
|
|
80
|
+
vercel: VERCEL_PRESET,
|
|
81
|
+
netlify: NETLIFY_PRESET,
|
|
82
|
+
'aws-lambda': AWS_LAMBDA_PRESET,
|
|
83
|
+
};
|
|
84
|
+
/** Every target `deploy` accepts, for error messages and docs. */
|
|
85
|
+
export const DEPLOY_TARGETS = Object.keys(PRESETS);
|
|
86
|
+
/**
|
|
87
|
+
* How to deploy what a given target built, or `null` for a name this rshono does not know — which a
|
|
88
|
+
* `dist/` produced by a newer version can legitimately carry.
|
|
89
|
+
*/
|
|
90
|
+
export function deployHintFor(target) {
|
|
91
|
+
return PRESETS[target]?.deployHint ?? null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the preset to build with: the flag wins over the environment, which wins over the config
|
|
95
|
+
* file, which wins over the `node` default.
|
|
96
|
+
*
|
|
97
|
+
* Blank values are ignored at every level, so an unset-but-present `RSHONO_DEPLOY=` in a CI
|
|
98
|
+
* environment falls through to the config file instead of failing the build.
|
|
99
|
+
*/
|
|
100
|
+
export function resolveDeployPreset(sources = {}) {
|
|
101
|
+
const target = sources.flag?.trim() || sources.env?.trim() || sources.config?.trim();
|
|
102
|
+
if (!target)
|
|
103
|
+
return NODE_PRESET;
|
|
104
|
+
const preset = PRESETS[target];
|
|
105
|
+
if (!preset) {
|
|
106
|
+
throw new Error(`[rshono] unknown deploy target ${JSON.stringify(target)} — expected one of: ${DEPLOY_TARGETS.join(', ')}.`);
|
|
107
|
+
}
|
|
108
|
+
return preset;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/deploy/presets.ts"],"names":[],"mappings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AM,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/deploy/vercel/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA6BxD,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqChF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { rm } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
/**
|
|
5
|
+
* The Build Output API v3 layout, which is what `vercel deploy --prebuilt` uploads verbatim. Producing
|
|
6
|
+
* it directly means Vercel runs no build of its own — everything it needs already exists.
|
|
7
|
+
*/
|
|
8
|
+
const OUTPUT_DIR = join('.vercel', 'output');
|
|
9
|
+
const FUNCTION_DIR = join('functions', 'index.func');
|
|
10
|
+
/**
|
|
11
|
+
* The function's own view of the build.
|
|
12
|
+
*
|
|
13
|
+
* `dist/server/main.mjs` is kept at that exact path inside the function because the runtime derives the
|
|
14
|
+
* project root from where the bundle sits (see `deploy/filesystem.ts`) — so `dist/ssg` and `dist/public`
|
|
15
|
+
* land where it already looks for them, and no runtime code needs to know it is on Vercel.
|
|
16
|
+
*/
|
|
17
|
+
const HANDLER = 'dist/server/main.mjs';
|
|
18
|
+
/**
|
|
19
|
+
* Routes, in the order Vercel evaluates them: hashed assets get the immutable header the CDN cannot
|
|
20
|
+
* infer, then anything present in the static output is served from it, and whatever is left is the
|
|
21
|
+
* app's to render.
|
|
22
|
+
*/
|
|
23
|
+
const ROUTES = [
|
|
24
|
+
{ src: '^/_static/(.*)$', headers: { 'cache-control': 'public, max-age=31536000, immutable' }, continue: true },
|
|
25
|
+
{ handle: 'filesystem' },
|
|
26
|
+
{ src: '/(.*)', dest: '/index' },
|
|
27
|
+
];
|
|
28
|
+
export async function finalizeVercelBuild(ctx) {
|
|
29
|
+
const outputDir = join(ctx.rootDir, OUTPUT_DIR);
|
|
30
|
+
const staticOut = join(outputDir, 'static');
|
|
31
|
+
const functionDir = join(outputDir, FUNCTION_DIR);
|
|
32
|
+
// Rebuilt from scratch, so a deleted page or asset cannot survive in the uploaded output.
|
|
33
|
+
await rm(outputDir, { recursive: true, force: true });
|
|
34
|
+
mkdirSync(staticOut, { recursive: true });
|
|
35
|
+
mkdirSync(functionDir, { recursive: true });
|
|
36
|
+
// Served by the CDN: the hashed bundle under its public path, and `public/` at the web root.
|
|
37
|
+
cpSync(ctx.staticDir, join(staticOut, '_static'), { recursive: true });
|
|
38
|
+
if (ctx.publicDir)
|
|
39
|
+
cpSync(ctx.publicDir, staticOut, { recursive: true });
|
|
40
|
+
// Shipped inside the function: the bundle, plus the two things it reads from disk at request time.
|
|
41
|
+
cpSync(join(ctx.distDir, 'server'), join(functionDir, 'dist', 'server'), { recursive: true });
|
|
42
|
+
if (existsSync(ctx.ssgDir))
|
|
43
|
+
cpSync(ctx.ssgDir, join(functionDir, 'dist', 'ssg'), { recursive: true });
|
|
44
|
+
if (ctx.publicDir)
|
|
45
|
+
cpSync(ctx.publicDir, join(functionDir, 'dist', 'public'), { recursive: true });
|
|
46
|
+
writeFileSync(join(functionDir, '.vc-config.json'), `${JSON.stringify({
|
|
47
|
+
runtime: 'nodejs22.x',
|
|
48
|
+
handler: HANDLER,
|
|
49
|
+
launcherType: 'Nodejs',
|
|
50
|
+
// Without this the platform buffers the whole response, which would undo streamed SSR.
|
|
51
|
+
supportsResponseStreaming: true,
|
|
52
|
+
}, null, 2)}\n`);
|
|
53
|
+
writeFileSync(join(outputDir, 'config.json'), `${JSON.stringify({ version: 3, routes: ROUTES }, null, 2)}\n`);
|
|
54
|
+
console.log(` • assembled ${OUTPUT_DIR} (Build Output API v3)`);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/deploy/vercel/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;GAGG;AACH,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,GAAG;IACb,EAAE,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,qCAAqC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC/G,EAAE,MAAM,EAAE,YAAY,EAAE;IACxB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;CACjC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAuB;IAC/D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,Q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AAI,CAAC,SAAS,CACf;QACE,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,OAAO;QAChB,YAAY,EAAE,QAAQ;QACtB,uFAAuF;QACvF,yBAAyB,EAAE,IAAI;KAChC,EACD,IAAI,EACJ,CAAC,CACF,IAAI,CACN,CAAC;IAEF,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAE9G,OAAO,CAAC,GAAG,CAAC,iBAAiB,UAAU,wBAAwB,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { cpSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { DeployBuildContext } from '../presets.js';\n\n/**\n * The Build Output API v3 layout, which is what `vercel deploy --prebuilt` uploads verbatim. Producing\n * it directly means Vercel runs no build of its own — everything it needs already exists.\n */\nconst OUTPUT_DIR = join('.vercel', 'output');\nconst FUNCTION_DIR = join('functions', 'index.func');\n\n/**\n * The function's own view of the build.\n *\n * `dist/server/main.mjs` is kept at that exact path inside the function because the runtime derives the\n * project root from where the bundle sits (see `deploy/filesystem.ts`) — so `dist/ssg` and `dist/public`\n * land where it already looks for them, and no runtime code needs to know it is on Vercel.\n */\nconst HANDLER = 'dist/server/main.mjs';\n\n/**\n * Routes, in the order Vercel evaluates them: hashed assets get the immutable header the CDN cannot\n * infer, then anything present in the static output is served from it, and whatever is left is the\n * app's to render.\n */\nconst ROUTES = [\n { src: '^/_static/(.*)$', headers: { 'cache-control': 'public, max-age=31536000, immutable' }, continue: true },\n { handle: 'filesystem' },\n { src: '/(.*)', dest: '/index' },\n];\n\nexport async function finalizeVercelBuild(ctx: DeployBuildContext): Promise<void> {\n const outputDir = join(ctx.rootDir, OUTPUT_DIR);\n const staticOut = join(outputDir, 'static');\n const functionDir = join(outputDir, FUNCTION_DIR);\n\n // Rebuilt from scratch, so a deleted page or asset cannot survive in the uploaded output.\n await rm(outputDir, { recursive: true, force: true });\n mkdirSync(staticOut, { recursive: true });\n mkdirSync(functionDir, { recursive: true });\n\n // Served by the CDN: the hashed bundle under its public path, and `public/` at the web root.\n cpSync(ctx.staticDir, join(staticOut, '_static'), { recursive: true });\n if (ctx.publicDir) cpSync(ctx.publicDir, staticOut, { recursive: true });\n\n // Shipped inside the function: the bundle, plus the two things it reads from disk at request time.\n cpSync(join(ctx.distDir, 'server'), join(functionDir, 'dist', 'server'), { recursive: true });\n if (existsSync(ctx.ssgDir)) cpSync(ctx.ssgDir, join(functionDir, 'dist', 'ssg'), { recursive: true });\n if (ctx.publicDir) cpSync(ctx.publicDir, join(functionDir, 'dist', 'public'), { recursive: true });\n\n writeFileSync(\n join(functionDir, '.vc-config.json'),\n `${JSON.stringify(\n {\n runtime: 'nodejs22.x',\n handler: HANDLER,\n launcherType: 'Nodejs',\n // Without this the platform buffers the whole response, which would undo streamed SSR.\n supportsResponseStreaming: true,\n },\n null,\n 2,\n )}\\n`,\n );\n\n writeFileSync(join(outputDir, 'config.json'), `${JSON.stringify({ version: 3, routes: ROUTES }, null, 2)}\\n`);\n\n console.log(` • assembled ${OUTPUT_DIR} (Build Output API v3)`);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DeployRuntime } from '../contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Vercel, as a single Node function fed by the platform's own router.
|
|
4
|
+
*
|
|
5
|
+
* `/_static` and `public/` are in the static output, and `config.json` puts the filesystem handler
|
|
6
|
+
* ahead of the function — so the CDN answers them and the function is never invoked for an asset,
|
|
7
|
+
* which is why mounting them here would only be dead weight.
|
|
8
|
+
*
|
|
9
|
+
* Prerendered pages are *not* static output: one URL answers with a document or a flight payload
|
|
10
|
+
* depending on `Accept`, and a path-keyed CDN cannot choose. They ship inside the function instead and
|
|
11
|
+
* are read from its read-only disk, exactly as on a server.
|
|
12
|
+
*/
|
|
13
|
+
export declare const runtime: DeployRuntime;
|
|
14
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +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,aAcrB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handle } from 'hono/vercel';
|
|
2
|
+
import { fileSystemRuntime } from '../filesystem.js';
|
|
3
|
+
/**
|
|
4
|
+
* Vercel, as a single Node function fed by the platform's own router.
|
|
5
|
+
*
|
|
6
|
+
* `/_static` and `public/` are in the static output, and `config.json` puts the filesystem handler
|
|
7
|
+
* ahead of the function — so the CDN answers them and the function is never invoked for an asset,
|
|
8
|
+
* which is why mounting them here would only be dead weight.
|
|
9
|
+
*
|
|
10
|
+
* Prerendered pages are *not* static output: one URL answers with a document or a flight payload
|
|
11
|
+
* depending on `Accept`, and a path-keyed CDN cannot choose. They ship inside the function instead and
|
|
12
|
+
* are read from its read-only disk, exactly as on a server.
|
|
13
|
+
*/
|
|
14
|
+
export const runtime = {
|
|
15
|
+
...fileSystemRuntime,
|
|
16
|
+
mountStaticAssets() {
|
|
17
|
+
// Served from `.vercel/output/static` before the function runs.
|
|
18
|
+
},
|
|
19
|
+
serveApp(app) {
|
|
20
|
+
return handle(app);
|
|
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
|
+
};
|
|
26
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +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;IAED,iGAAiG;IACjG,wDAAwD;IACxD,QAAQ,EAAE,IAAI;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 // Vercel compresses at the edge. Its Node runtime does support streaming, so the framework's own\n // streamed SSR still reaches the browser progressively.\n compress: null,\n};\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@rshono/core` — the build-time surface: route and config declaration plus the types
|
|
3
|
+
* your pages and endpoints are written against. Everything here is safe to
|
|
4
|
+
* import from server code; none of it pulls in runtime machinery.
|
|
5
|
+
*
|
|
6
|
+
* The two companion entry points are runtime-only:
|
|
7
|
+
* - `@rshono/core/server` — {@link https://hono.dev | Hono} request context inside
|
|
8
|
+
* server components and actions (`getContext`, `redirect`, `notFound`), plus
|
|
9
|
+
* `onServerError` for reporting the errors the framework catches.
|
|
10
|
+
* - `@rshono/core/client` — hooks and components for `'use client'` modules
|
|
11
|
+
* (`useNavigation`, `Boundary`, `ErrorBoundary`, `NavigationProgress`).
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export { defineRoutes, isPageRoute, type EndpointRoute, type EndpointServerModule, type ErrorInfo, type ErrorPageProps, type FallbackPage, type HTTPMethod, type PageComponent, type PageProps, type PageRoute, type PathParams, type Route, type RouteConfig, } from './router.js';
|
|
16
|
+
export { defineConfig, type RSHonoConfig, type RspackHookContext } from './config.js';
|
|
17
|
+
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
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,YAAY,EACZ,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,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;AAEzD;;;GAGG;AACH,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@rshono/core` — the build-time surface: route and config declaration plus the types
|
|
3
|
+
* your pages and endpoints are written against. Everything here is safe to
|
|
4
|
+
* import from server code; none of it pulls in runtime machinery.
|
|
5
|
+
*
|
|
6
|
+
* The two companion entry points are runtime-only:
|
|
7
|
+
* - `@rshono/core/server` — {@link https://hono.dev | Hono} request context inside
|
|
8
|
+
* server components and actions (`getContext`, `redirect`, `notFound`), plus
|
|
9
|
+
* `onServerError` for reporting the errors the framework catches.
|
|
10
|
+
* - `@rshono/core/client` — hooks and components for `'use client'` modules
|
|
11
|
+
* (`useNavigation`, `Boundary`, `ErrorBoundary`, `NavigationProgress`).
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export { defineRoutes, isPageRoute, } from './router.js';
|
|
16
|
+
export { defineConfig } from './config.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,YAAY,EACZ,WAAW,GAaZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAA6C,MAAM,aAAa,CAAC","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 (`getContext`, `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`, `Boundary`, `ErrorBoundary`, `NavigationProgress`).\n *\n * @packageDocumentation\n */\n\nexport {\n defineRoutes,\n isPageRoute,\n type EndpointRoute,\n type EndpointServerModule,\n type ErrorInfo,\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/**\n * Re-exported from Hono for convenience, so an endpoint module can type its\n * `handler` without depending on `hono` directly.\n */\nexport type { Context, Handler } from 'hono';\n"]}
|