create-nifra 2.1.0 → 2.3.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 +4 -4
- package/dist/agent-files.d.ts +14 -14
- package/dist/agent-files.js +29 -29
- package/dist/agents.d.ts +4 -4
- package/dist/agents.js +63 -63
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +8 -8
- package/dist/cli.d.ts +6 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -35
- package/dist/cli.js.map +1 -1
- package/dist/db.d.ts +6 -6
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +138 -41
- package/dist/db.js.map +1 -1
- package/dist/scaffold/features.d.ts +41 -0
- package/dist/scaffold/features.d.ts.map +1 -0
- package/dist/scaffold/features.js +48 -0
- package/dist/scaffold/features.js.map +1 -0
- package/dist/scaffold/frameworks.d.ts +73 -0
- package/dist/scaffold/frameworks.d.ts.map +1 -0
- package/dist/scaffold/frameworks.js +100 -0
- package/dist/scaffold/frameworks.js.map +1 -0
- package/dist/scaffold/site-build.d.ts +60 -0
- package/dist/scaffold/site-build.d.ts.map +1 -0
- package/dist/scaffold/site-build.js +198 -0
- package/dist/scaffold/site-build.js.map +1 -0
- package/dist/scaffold/site-files.d.ts +16 -0
- package/dist/scaffold/site-files.d.ts.map +1 -0
- package/dist/scaffold/site-files.js +112 -0
- package/dist/scaffold/site-files.js.map +1 -0
- package/dist/scaffold/site.d.ts +33 -0
- package/dist/scaffold/site.d.ts.map +1 -0
- package/dist/scaffold/site.js +99 -0
- package/dist/scaffold/site.js.map +1 -0
- package/package.json +3 -2
- package/src/agent-files.ts +149 -0
- package/template/README.md +3 -3
- package/template/nifra.assurance.ts +80 -0
- package/template/package.json +5 -3
- package/template/src/app.ts +10 -11
- package/template/src/routes.ts +13 -0
- package/template-isr/README.md +1 -1
- package/template-isr/backend.ts +11 -15
- package/template-isr/nifra.assurance.ts +81 -0
- package/template-isr/package.json +8 -7
- package/template-isr/page.ts +12 -0
- package/template-isr/routes/_404.tsx +1 -1
- package/template-isr/routes/_layout.tsx +1 -1
- package/template-isr/routes/index.tsx +2 -2
- package/template-isr/server.ts +1 -1
- package/template-isr/worker.ts +2 -2
- package/template-isr/wrangler.toml +2 -2
- package/template-site/Dockerfile +1 -1
- package/template-site/README.md +6 -6
- package/template-site/backend.ts +11 -13
- package/template-site/counter.ts +16 -0
- package/template-site/nifra.assurance.ts +83 -0
- package/template-site/nifra.config.ts +1 -1
- package/template-site/routes/index.tsx +1 -1
- package/template-site/server-node.ts +1 -1
- package/template-site/server-vercel.ts +1 -1
- package/template-site-preact/README.md +7 -7
- package/template-site-preact/nifra.config.ts +1 -1
- package/template-site-preact/routes/index.tsx +1 -1
- package/template-site-solid/README.md +7 -7
- package/template-site-solid/nifra.config.ts +2 -2
- package/template-site-solid/routes/index.tsx +1 -1
- package/template-site-svelte/README.md +7 -7
- package/template-site-svelte/nifra.config.ts +2 -2
- package/template-site-svelte/routes/_layout.svelte +1 -1
- package/template-site-svelte/routes/index.svelte +1 -1
- package/template-site-vue/README.md +7 -7
- package/template-site-vue/nifra.config.ts +2 -2
- package/template-site-vue/routes/_layout.vue +2 -2
- package/template-site-vue/routes/index.vue +3 -3
- package/template-site/build-bun.ts +0 -27
- package/template-site/build-deno.ts +0 -25
- package/template-site/build-node.ts +0 -26
- package/template-site/build-vercel.ts +0 -45
- package/template-site/build.ts +0 -29
- package/template-site/framework.ts +0 -6
- package/template-site/package.json +0 -38
- package/template-site/tsconfig.json +0 -37
- package/template-site-preact/.dockerignore +0 -14
- package/template-site-preact/Dockerfile +0 -20
- package/template-site-preact/_worker.ts +0 -17
- package/template-site-preact/backend.ts +0 -15
- package/template-site-preact/build-bun.ts +0 -27
- package/template-site-preact/build-deno.ts +0 -25
- package/template-site-preact/build-node.ts +0 -26
- package/template-site-preact/build-vercel.ts +0 -45
- package/template-site-preact/build.ts +0 -29
- package/template-site-preact/deno.json +0 -7
- package/template-site-preact/framework.ts +0 -6
- package/template-site-preact/gitignore +0 -16
- package/template-site-preact/package.json +0 -35
- package/template-site-preact/server-bun.ts +0 -35
- package/template-site-preact/server-deno.ts +0 -38
- package/template-site-preact/server-node.ts +0 -40
- package/template-site-preact/server-vercel.ts +0 -17
- package/template-site-preact/tsconfig.json +0 -38
- package/template-site-preact/wrangler.toml +0 -4
- package/template-site-solid/.dockerignore +0 -14
- package/template-site-solid/Dockerfile +0 -20
- package/template-site-solid/_worker.ts +0 -17
- package/template-site-solid/backend.ts +0 -15
- package/template-site-solid/build-bun.ts +0 -33
- package/template-site-solid/build-deno.ts +0 -32
- package/template-site-solid/build-node.ts +0 -33
- package/template-site-solid/build-vercel.ts +0 -47
- package/template-site-solid/build.ts +0 -36
- package/template-site-solid/deno.json +0 -7
- package/template-site-solid/framework.ts +0 -6
- package/template-site-solid/gitignore +0 -16
- package/template-site-solid/package.json +0 -35
- package/template-site-solid/server-bun.ts +0 -35
- package/template-site-solid/server-deno.ts +0 -38
- package/template-site-solid/server-node.ts +0 -40
- package/template-site-solid/server-vercel.ts +0 -17
- package/template-site-solid/tsconfig.json +0 -38
- package/template-site-solid/wrangler.toml +0 -4
- package/template-site-svelte/.dockerignore +0 -14
- package/template-site-svelte/Dockerfile +0 -20
- package/template-site-svelte/_worker.ts +0 -17
- package/template-site-svelte/backend.ts +0 -15
- package/template-site-svelte/build-bun.ts +0 -32
- package/template-site-svelte/build-deno.ts +0 -31
- package/template-site-svelte/build-node.ts +0 -32
- package/template-site-svelte/build-vercel.ts +0 -46
- package/template-site-svelte/build.ts +0 -35
- package/template-site-svelte/deno.json +0 -7
- package/template-site-svelte/framework.ts +0 -6
- package/template-site-svelte/gitignore +0 -16
- package/template-site-svelte/package.json +0 -35
- package/template-site-svelte/server-bun.ts +0 -35
- package/template-site-svelte/server-deno.ts +0 -38
- package/template-site-svelte/server-node.ts +0 -40
- package/template-site-svelte/server-vercel.ts +0 -17
- package/template-site-svelte/tsconfig.json +0 -37
- package/template-site-svelte/wrangler.toml +0 -4
- package/template-site-vue/.dockerignore +0 -14
- package/template-site-vue/Dockerfile +0 -20
- package/template-site-vue/_worker.ts +0 -17
- package/template-site-vue/backend.ts +0 -15
- package/template-site-vue/build-bun.ts +0 -37
- package/template-site-vue/build-deno.ts +0 -36
- package/template-site-vue/build-node.ts +0 -37
- package/template-site-vue/build-vercel.ts +0 -54
- package/template-site-vue/build.ts +0 -40
- package/template-site-vue/deno.json +0 -7
- package/template-site-vue/framework.ts +0 -6
- package/template-site-vue/gitignore +0 -16
- package/template-site-vue/package.json +0 -36
- package/template-site-vue/server-bun.ts +0 -35
- package/template-site-vue/server-deno.ts +0 -38
- package/template-site-vue/server-node.ts +0 -40
- package/template-site-vue/server-vercel.ts +0 -17
- package/template-site-vue/tsconfig.json +0 -37
- package/template-site-vue/wrangler.toml +0 -4
package/template-isr/server.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Local Bun dev server (no wrangler)
|
|
2
|
+
* Local Bun dev server (no wrangler) - the same app with an in-memory ISR store. `bun run dev:bun`
|
|
3
3
|
* after `bun run build`. Production uses Workers KV (worker.ts); the only line that changes is the
|
|
4
4
|
* store. Watch the `x-nifra-isr` response header: miss → hit → stale.
|
|
5
5
|
*/
|
package/template-isr/worker.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cloudflare Workers entry
|
|
2
|
+
* Cloudflare Workers entry - the app, cached in Workers KV so cached pages and on-demand purges hold
|
|
3
3
|
* ACROSS instances. `ctx.waitUntil` keeps the worker alive while a stale page regenerates behind the
|
|
4
4
|
* response. `bun run build` then `bunx wrangler dev` (a local KV is provided automatically).
|
|
5
5
|
*/
|
|
@@ -30,7 +30,7 @@ interface Env {
|
|
|
30
30
|
readonly REVALIDATE_SECRET?: string
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** Minimal shape of the Workers execution context
|
|
33
|
+
/** Minimal shape of the Workers execution context - just `waitUntil`. */
|
|
34
34
|
interface ExecutionContext {
|
|
35
35
|
waitUntil(promise: Promise<unknown>): void
|
|
36
36
|
}
|
|
@@ -7,14 +7,14 @@ compatibility_flags = ["nodejs_compat"]
|
|
|
7
7
|
# /assets/*. Non-asset paths fall through to the worker (SSR + ISR).
|
|
8
8
|
assets = { directory = "./public" }
|
|
9
9
|
|
|
10
|
-
# The ISR page cache. `wrangler dev` provides a LOCAL (miniflare) KV automatically
|
|
10
|
+
# The ISR page cache. `wrangler dev` provides a LOCAL (miniflare) KV automatically - no Cloudflare
|
|
11
11
|
# account needed. For `wrangler deploy`, create a namespace and paste its id:
|
|
12
12
|
# bunx wrangler kv namespace create ISR_CACHE
|
|
13
13
|
[[kv_namespaces]]
|
|
14
14
|
binding = "ISR_CACHE"
|
|
15
15
|
id = "REPLACE_WITH_YOUR_KV_NAMESPACE_ID"
|
|
16
16
|
|
|
17
|
-
# On-demand revalidation secret. DEV placeholder
|
|
17
|
+
# On-demand revalidation secret. DEV placeholder - set a real one for production with
|
|
18
18
|
# `bunx wrangler secret put REVALIDATE_SECRET`.
|
|
19
19
|
[vars]
|
|
20
20
|
REVALIDATE_SECRET = "dev-secret"
|
package/template-site/Dockerfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# nifra on Node, containerized. Build with Bun (nifra's build toolchain), then run the self-contained
|
|
2
|
-
# bundle on a slim Node image
|
|
2
|
+
# bundle on a slim Node image - the final image carries no build tools or node_modules.
|
|
3
3
|
# docker build -t my-nifra-app .
|
|
4
4
|
# docker run -p 3000:3000 my-nifra-app
|
|
5
5
|
FROM oven/bun:1 AS build
|
package/template-site/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nifra site
|
|
2
2
|
|
|
3
|
-
A nifra + React SSR site
|
|
3
|
+
A nifra + React SSR site - file-based routes, typed loaders/actions, hydration - that deploys to
|
|
4
4
|
**Bun, Node (Docker), Deno Deploy, Cloudflare Pages, and Vercel Edge from one source**. `app.fetch`
|
|
5
5
|
is Web-standard, so only the server entry + build target differ per platform.
|
|
6
6
|
|
|
@@ -14,18 +14,18 @@ Edit `routes/index.tsx` (the landing + a live loader/action counter), add files
|
|
|
14
14
|
(`about.tsx` → `/about`, `[id].tsx` → `:id`, nested `_layout.tsx` for sections), and put your data
|
|
15
15
|
behind `backend.ts`.
|
|
16
16
|
|
|
17
|
-
## Deploy
|
|
17
|
+
## Deploy - pick a target
|
|
18
18
|
|
|
19
19
|
| target | build | deploy |
|
|
20
20
|
| --- | --- | --- |
|
|
21
|
-
| **Bun** (flagship) | `bun run build:bun` | `bun run start` (`bun dist-bun/server-bun.js`)
|
|
21
|
+
| **Bun** (flagship) | `bun run build:bun` | `bun run start` (`bun dist-bun/server-bun.js`) - any host |
|
|
22
22
|
| **Node** | `bun run build:node` | `docker build -t app . && docker run -p 3000:3000 app` (or `bun run start:node`) |
|
|
23
23
|
| **Deno Deploy** | `bun run build:deno` | `deployctl deploy --prod --entrypoint=dist-deno/server-deno.js` (or `deno task start`) |
|
|
24
24
|
| **Cloudflare Pages** | `bun run build` | `bun run deploy:cf` (`wrangler pages deploy dist`) |
|
|
25
25
|
| **Vercel Edge** | `bun run build:vercel` | `bun run deploy:vercel` (`vercel deploy --prebuilt`) |
|
|
26
26
|
|
|
27
27
|
The routes, `backend.ts`, and the client bundle are shared; each `build*` script swaps
|
|
28
|
-
`buildServer`'s target/conditions and the server entry. nifra never enters your cloud credentials
|
|
28
|
+
`buildServer`'s target/conditions and the server entry. nifra never enters your cloud credentials - the
|
|
29
29
|
configs (`Dockerfile`, `deno.json`, `wrangler.toml`, Vercel Build Output API) are scaffolded; you run
|
|
30
30
|
the vendor CLI.
|
|
31
31
|
|
|
@@ -33,8 +33,8 @@ the vendor CLI.
|
|
|
33
33
|
|
|
34
34
|
```
|
|
35
35
|
routes/ index.tsx (landing), _layout.tsx (chrome), _404.tsx
|
|
36
|
-
framework.ts the render adapter (imported by the server entries
|
|
37
|
-
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Vite plugin)
|
|
36
|
+
framework.ts the render adapter (imported by the server entries - kept edge-bundlable)
|
|
37
|
+
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Vite plugin) - read by `nifra dev`
|
|
38
38
|
backend.ts your contract (loaders/actions call it in-process)
|
|
39
39
|
server-bun.ts Bun entry (Bun.serve) build-bun.ts → dist-bun/
|
|
40
40
|
_worker.ts Cloudflare Pages entry build.ts → dist/
|
package/template-site/backend.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { server } from "@nifrajs/core/server"
|
|
2
|
-
import {
|
|
2
|
+
import { counter } from "./counter"
|
|
3
3
|
|
|
4
|
-
// Your backend contract
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return { count }
|
|
15
|
-
})
|
|
4
|
+
// Your backend contract - page loaders/actions call it in-process during SSR (no network).
|
|
5
|
+
// Composition only: this module merges route modules and registers none of its own.
|
|
6
|
+
//
|
|
7
|
+
// That is not a style preference. `nifra check` works out what a route can reach from the module that
|
|
8
|
+
// REGISTERS it, following that module's imports - so a file that registers routes AND imports a
|
|
9
|
+
// database gives every route in it database reach, and a GET route may not declare a domain write at
|
|
10
|
+
// all. Keeping this file pure means each route's reach is its own module's, which is what lets the
|
|
11
|
+
// capability declarations in `nifra.assurance.ts` stay true as the app grows. Add a feature as a
|
|
12
|
+
// module, merge it here.
|
|
13
|
+
export const backend = server().merge(counter)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { server } from "@nifrajs/core/server"
|
|
2
|
+
import { t } from "@nifrajs/schema"
|
|
3
|
+
|
|
4
|
+
// Replace the demo counter with real data (KV/D1/Postgres/…); on the edge, reach bindings via `c.env`.
|
|
5
|
+
// Anything this module can reach becomes reach for the routes below it, so give a feature that touches
|
|
6
|
+
// a database its own module rather than adding it here.
|
|
7
|
+
let count = 0
|
|
8
|
+
|
|
9
|
+
const Counter = t.object({ count: t.number() })
|
|
10
|
+
|
|
11
|
+
export const counter = server()
|
|
12
|
+
.get("/count", { response: Counter }, () => ({ count }))
|
|
13
|
+
.post("/count", { response: Counter }, () => {
|
|
14
|
+
count += 1
|
|
15
|
+
return { count }
|
|
16
|
+
})
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this app's routes are required to PROVE, checked by `nifra assure` (and level L1 of
|
|
3
|
+
* `nifra levels`). Evidence is collected from the routes themselves - a `body` schema records
|
|
4
|
+
* `body-bounded`, an auth middleware records `authenticated` - so this file states the requirement
|
|
5
|
+
* and the framework reports whether the route actually carries it.
|
|
6
|
+
*
|
|
7
|
+
* Page routes under `routes/` are not classified here; this is the backend contract those pages call.
|
|
8
|
+
*
|
|
9
|
+
* Rules are first-match-wins, so order matters: narrow exemptions go above the general rule, and each
|
|
10
|
+
* one is named and justified. An exemption you have to write down is one a reviewer can argue with;
|
|
11
|
+
* an exemption you get by leaving the rule off is one nobody ever sees.
|
|
12
|
+
*/
|
|
13
|
+
import { defineAssuranceConfig, NIFRA_ASSURANCE } from "@nifrajs/core/assurance"
|
|
14
|
+
import { backend } from "./backend"
|
|
15
|
+
|
|
16
|
+
export default defineAssuranceConfig({
|
|
17
|
+
source: backend,
|
|
18
|
+
// What each effect IS, so the policy below can be written about a CLASS of effect rather than a list
|
|
19
|
+
// of token names: `{ access: "write", zone: "domain" }` covers `payments.charge` the day someone adds
|
|
20
|
+
// it, where a rule naming `db.write` would not.
|
|
21
|
+
capabilities: {
|
|
22
|
+
definitions: [
|
|
23
|
+
{ id: "db.read", zone: "domain", access: "read" },
|
|
24
|
+
{ id: "db.write", zone: "domain", access: "write" },
|
|
25
|
+
],
|
|
26
|
+
provenance: {
|
|
27
|
+
// Reaching one of these modules means holding the capabilities beside it, and `nifra check` fails
|
|
28
|
+
// any route that can reach further than it declared - so wiring a database into a handler and
|
|
29
|
+
// forgetting to say so is a failing check rather than something review has to catch.
|
|
30
|
+
//
|
|
31
|
+
// The first two are the seam `--db` scaffolds, split by access on purpose: reach is computed per
|
|
32
|
+
// MODULE, and a GET route may not declare a domain write, so a module that can reach both has GET
|
|
33
|
+
// routes with no legal declaration. Keeping reads and writes import-disjoint - at the seam and at
|
|
34
|
+
// the route modules - is what keeps every route's declaration equal to its reach. The drivers
|
|
35
|
+
// below are the backstop for code that goes around the seam; they grant both, because an import
|
|
36
|
+
// cannot tell a read from a write.
|
|
37
|
+
imports: [
|
|
38
|
+
{ specifier: "./read.ts", capabilities: ["db.read"] },
|
|
39
|
+
{ specifier: "./write.ts", capabilities: ["db.write"] },
|
|
40
|
+
{ specifier: "bun:sqlite", capabilities: ["db.read", "db.write"] },
|
|
41
|
+
{ specifier: "node:sqlite", capabilities: ["db.read", "db.write"] },
|
|
42
|
+
{ specifier: "pg", capabilities: ["db.read", "db.write"] },
|
|
43
|
+
{ specifier: "postgres", capabilities: ["db.read", "db.write"] },
|
|
44
|
+
{ specifier: "mysql2", capabilities: ["db.read", "db.write"] },
|
|
45
|
+
{ specifier: "kysely", capabilities: ["db.read", "db.write"] },
|
|
46
|
+
{ specifier: "drizzle-orm", capabilities: ["db.read", "db.write"] },
|
|
47
|
+
{ specifier: "drizzle-orm/*", capabilities: ["db.read", "db.write"] },
|
|
48
|
+
{ specifier: "@libsql/*", capabilities: ["db.read", "db.write"] },
|
|
49
|
+
{ specifier: "@prisma/client", capabilities: ["db.read", "db.write"] },
|
|
50
|
+
],
|
|
51
|
+
// Add a driver here to force every query through the seam, and the check will name any route that
|
|
52
|
+
// reaches around it: `{ specifier: "pg", reason: "query through db/read.ts or db/write.ts" }`.
|
|
53
|
+
forbiddenImports: [],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
policy: {
|
|
57
|
+
rules: [
|
|
58
|
+
// The counter increments; it accepts no input at all, so there is no body to bound. Exempted by
|
|
59
|
+
// name so the general rule below stays strict for every mutation that DOES take input.
|
|
60
|
+
{ name: "bodyless-mutation", match: { methods: ["POST"], paths: ["/count"] }, require: [] },
|
|
61
|
+
// Anything that writes business state must prove who asked. Matched on what the capability IS
|
|
62
|
+
// rather than on its name or its path, so a token introduced later - `payments.charge`,
|
|
63
|
+
// `orders.write` - is covered the day it is declared instead of the day someone remembers to
|
|
64
|
+
// widen this rule. A server function is a public POST endpoint like any other, so this is what
|
|
65
|
+
// stops one shipping unauthenticated.
|
|
66
|
+
{
|
|
67
|
+
name: "authenticated-write",
|
|
68
|
+
match: { access: "write", zone: "domain" },
|
|
69
|
+
require: [NIFRA_ASSURANCE.AUTHENTICATED],
|
|
70
|
+
},
|
|
71
|
+
// Anything else that changes state must validate its input at the boundary. Adding a POST
|
|
72
|
+
// without a `body` schema fails this - which is the point: the check notices, not review.
|
|
73
|
+
{
|
|
74
|
+
name: "mutation",
|
|
75
|
+
match: { methods: ["POST", "PUT", "PATCH", "DELETE"] },
|
|
76
|
+
require: [NIFRA_ASSURANCE.BODY_BOUNDED],
|
|
77
|
+
},
|
|
78
|
+
// Reads carry no requirement yet. When some become private, split this into a public rule and
|
|
79
|
+
// an authenticated one rather than weakening the whole class.
|
|
80
|
+
{ name: "read", match: { methods: ["GET"] }, require: [] },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The nifra CLI's config
|
|
1
|
+
// The nifra CLI's config - read by `nifra dev|build|start`. Separate from `framework.ts` (which the
|
|
2
2
|
// edge/server entries import, so it must stay edge-bundlable): THIS file is imported only by the CLI
|
|
3
3
|
// (which runs on Bun), so it's the place for dev/build tooling like the Vite plugin. React JSX is
|
|
4
4
|
// Bun-native, so the only extra is the Vite plugin for dev HMR (Fast Refresh).
|
|
@@ -28,7 +28,7 @@ export default function Home(props: { data: LoaderData<typeof loader> }) {
|
|
|
28
28
|
<span className="grad">everywhere.</span>
|
|
29
29
|
</h1>
|
|
30
30
|
<p>
|
|
31
|
-
SSR + hydration, end-to-end types, React. One source
|
|
31
|
+
SSR + hydration, end-to-end types, React. One source - deploy to Cloudflare Pages, Node,
|
|
32
32
|
Deno, or Vercel Edge. Edit <code>routes/index.tsx</code> to begin.
|
|
33
33
|
</p>
|
|
34
34
|
</section>
|
|
@@ -14,7 +14,7 @@ const app = createWebApp({
|
|
|
14
14
|
title: "nifra site",
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
// @nifrajs/node serves app.fetch only
|
|
17
|
+
// @nifrajs/node serves app.fetch only - so serve /assets/* (the client bundle) from disk here.
|
|
18
18
|
const ASSETS = new URL("./assets/", import.meta.url)
|
|
19
19
|
const TYPES: Readonly<Record<string, string>> = { js: "text/javascript", css: "text/css" }
|
|
20
20
|
|
|
@@ -12,6 +12,6 @@ const app = createWebApp({
|
|
|
12
12
|
title: "nifra site",
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
// Vercel Edge Function
|
|
15
|
+
// Vercel Edge Function - Vercel serves /assets/* from its CDN, so this only SSRs page routes.
|
|
16
16
|
export const config = { runtime: "edge" }
|
|
17
17
|
export default (req: Request): Response | Promise<Response> => app.fetch(req)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nifra site (Preact)
|
|
2
2
|
|
|
3
|
-
A nifra + **Preact** SSR site
|
|
3
|
+
A nifra + **Preact** SSR site - file-based routes, typed loaders/actions, hydration - that deploys to
|
|
4
4
|
**Bun, Node (Docker), Deno Deploy, Cloudflare Pages, and Vercel Edge from one source**. `app.fetch`
|
|
5
5
|
is Web-standard, so only the server entry + build target differ per platform.
|
|
6
6
|
|
|
@@ -10,30 +10,30 @@ bun run dev # nifra dev → true-HMR dev server (Vite + nifra SSR) at htt
|
|
|
10
10
|
bun run preview # wrangler pages dev dist → preview the built Cloudflare bundle (run `bun run build` first)
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Routes are Preact function components (JSX, via `jsxImportSource: "preact"`) under `routes/`
|
|
13
|
+
Routes are Preact function components (JSX, via `jsxImportSource: "preact"`) under `routes/` -
|
|
14
14
|
`index.tsx` (landing + a live loader/action counter), `_layout.tsx` (chrome), `_404.tsx`. The
|
|
15
15
|
frontend adapter is one line in `framework.ts`; data lives behind `backend.ts`.
|
|
16
16
|
|
|
17
|
-
## Deploy
|
|
17
|
+
## Deploy - pick a target
|
|
18
18
|
|
|
19
19
|
| target | build | deploy |
|
|
20
20
|
| --- | --- | --- |
|
|
21
|
-
| **Bun** (flagship) | `bun run build:bun` | `bun run start`
|
|
21
|
+
| **Bun** (flagship) | `bun run build:bun` | `bun run start` - any host |
|
|
22
22
|
| **Node** | `bun run build:node` | `docker build -t app . && docker run -p 3000:3000 app` (or `bun run start:node`) |
|
|
23
23
|
| **Deno Deploy** | `bun run build:deno` | `deployctl deploy --prod --entrypoint=dist-deno/server-deno.js` |
|
|
24
24
|
| **Cloudflare Pages** | `bun run build` | `bun run deploy:cf` |
|
|
25
25
|
| **Vercel Edge** | `bun run build:vercel` | `bun run deploy:vercel` |
|
|
26
26
|
|
|
27
27
|
The routes, `backend.ts`, and the client bundle are shared; each `build*` script swaps `buildServer`'s
|
|
28
|
-
target/conditions and the server entry. nifra never enters your cloud credentials
|
|
28
|
+
target/conditions and the server entry. nifra never enters your cloud credentials - it scaffolds the
|
|
29
29
|
configs (`Dockerfile`, `deno.json`, `wrangler.toml`, Vercel Build Output API); you run the vendor CLI.
|
|
30
30
|
|
|
31
31
|
## Structure
|
|
32
32
|
|
|
33
33
|
```
|
|
34
34
|
routes/ index.tsx (landing), _layout.tsx (chrome), _404.tsx
|
|
35
|
-
framework.ts the adapter (preactAdapter)
|
|
36
|
-
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Vite plugin)
|
|
35
|
+
framework.ts the adapter (preactAdapter) - imported by the server entries (edge-bundlable)
|
|
36
|
+
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Vite plugin) - read by `nifra dev`
|
|
37
37
|
backend.ts your contract (loaders/actions call it in-process)
|
|
38
38
|
server-bun.ts Bun entry (Bun.serve) build-bun.ts → dist-bun/
|
|
39
39
|
_worker.ts Cloudflare Pages entry build.ts → dist/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The nifra CLI's config
|
|
1
|
+
// The nifra CLI's config - read by `nifra dev|build|start`. Separate from `framework.ts` (which the
|
|
2
2
|
// edge/server entries import, so it must stay edge-bundlable): THIS file is imported only by the CLI
|
|
3
3
|
// (which runs on Bun), so it's the place for dev/build tooling like the Vite plugin. Preact JSX is
|
|
4
4
|
// Bun-native, so the only extra is the Vite plugin for dev HMR (`@preact/preset-vite` = prefresh).
|
|
@@ -28,7 +28,7 @@ export default function Home(props: { data: LoaderData<typeof loader> }) {
|
|
|
28
28
|
<span className="grad">everywhere.</span>
|
|
29
29
|
</h1>
|
|
30
30
|
<p>
|
|
31
|
-
SSR + hydration, end-to-end types, Preact. One source
|
|
31
|
+
SSR + hydration, end-to-end types, Preact. One source - deploy to Cloudflare Pages, Node,
|
|
32
32
|
Deno, or Vercel Edge. Edit <code>routes/index.tsx</code> to begin.
|
|
33
33
|
</p>
|
|
34
34
|
</section>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nifra site (Solid)
|
|
2
2
|
|
|
3
|
-
A nifra + **Solid** SSR site
|
|
3
|
+
A nifra + **Solid** SSR site - file-based routes, typed loaders/actions, hydration - that deploys to
|
|
4
4
|
**Bun, Node (Docker), Deno Deploy, Cloudflare Pages, and Vercel Edge from one source**. `app.fetch`
|
|
5
5
|
is Web-standard, so only the server entry + build target differ per platform.
|
|
6
6
|
|
|
@@ -10,30 +10,30 @@ bun run dev # nifra dev → true-HMR dev server (Vite + nifra SSR) at htt
|
|
|
10
10
|
bun run preview # wrangler pages dev dist → preview the built Cloudflare bundle (run `bun run build` first)
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Routes are Solid function components (JSX, compiled by `solidBunPlugin`) under `routes/`
|
|
13
|
+
Routes are Solid function components (JSX, compiled by `solidBunPlugin`) under `routes/` - `index.tsx`
|
|
14
14
|
(landing + a live loader/action counter), `_layout.tsx` (chrome), `_404.tsx`. The frontend adapter is
|
|
15
15
|
one line in `framework.ts`; data lives behind `backend.ts`. Each `build*` script wires
|
|
16
16
|
`solidBunPlugin("dom")` for the client and `("ssr")` + the `solid` export condition for the server.
|
|
17
17
|
|
|
18
|
-
## Deploy
|
|
18
|
+
## Deploy - pick a target
|
|
19
19
|
|
|
20
20
|
| target | build | deploy |
|
|
21
21
|
| --- | --- | --- |
|
|
22
|
-
| **Bun** (flagship) | `bun run build:bun` | `bun run start`
|
|
22
|
+
| **Bun** (flagship) | `bun run build:bun` | `bun run start` - any host |
|
|
23
23
|
| **Node** | `bun run build:node` | `docker build -t app . && docker run -p 3000:3000 app` (or `bun run start:node`) |
|
|
24
24
|
| **Deno Deploy** | `bun run build:deno` | `deployctl deploy --prod --entrypoint=dist-deno/server-deno.js` |
|
|
25
25
|
| **Cloudflare Pages** | `bun run build` | `bun run deploy:cf` |
|
|
26
26
|
| **Vercel Edge** | `bun run build:vercel` | `bun run deploy:vercel` |
|
|
27
27
|
|
|
28
|
-
nifra never enters your cloud credentials
|
|
28
|
+
nifra never enters your cloud credentials - it scaffolds the configs (`Dockerfile`, `deno.json`,
|
|
29
29
|
`wrangler.toml`, Vercel Build Output API); you run the vendor CLI.
|
|
30
30
|
|
|
31
31
|
## Structure
|
|
32
32
|
|
|
33
33
|
```
|
|
34
34
|
routes/ index.tsx (landing), _layout.tsx (chrome), _404.tsx
|
|
35
|
-
framework.ts the adapter (solidAdapter)
|
|
36
|
-
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Solid plugins)
|
|
35
|
+
framework.ts the adapter (solidAdapter) - imported by the server entries (edge-bundlable)
|
|
36
|
+
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Solid plugins) - read by `nifra dev`
|
|
37
37
|
backend.ts your contract (loaders/actions call it in-process)
|
|
38
38
|
server-bun.ts Bun entry (Bun.serve) build-bun.ts → dist-bun/
|
|
39
39
|
_worker.ts Cloudflare Pages entry build.ts → dist/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The nifra CLI's config
|
|
2
|
-
// Bun), so it can eagerly import the Vite plugin + the Solid compile plugin
|
|
1
|
+
// The nifra CLI's config - read by `nifra dev|build|start`. It's imported ONLY by the CLI (which runs on
|
|
2
|
+
// Bun), so it can eagerly import the Vite plugin + the Solid compile plugin - keeping them OUT of the
|
|
3
3
|
// edge worker bundle that `framework.ts` (the render-adapter source the entries import) must stay free
|
|
4
4
|
// of. Solid needs the `"solid"` resolve condition (routes solid-js to its source / JSX-dev build).
|
|
5
5
|
import { solidBunPlugin } from "@nifrajs/web-solid"
|
|
@@ -28,7 +28,7 @@ export default function Home(props: { data: LoaderData<typeof loader> }) {
|
|
|
28
28
|
<span class="grad">everywhere.</span>
|
|
29
29
|
</h1>
|
|
30
30
|
<p>
|
|
31
|
-
SSR + hydration, end-to-end types, Solid. One source
|
|
31
|
+
SSR + hydration, end-to-end types, Solid. One source - deploy to Cloudflare Pages, Node,
|
|
32
32
|
Deno, or Vercel Edge. Edit <code>routes/index.tsx</code> to begin.
|
|
33
33
|
</p>
|
|
34
34
|
</section>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nifra site (Svelte)
|
|
2
2
|
|
|
3
|
-
A nifra + **Svelte 5** SSR site
|
|
3
|
+
A nifra + **Svelte 5** SSR site - file-based routes, typed loaders/actions, hydration - that deploys to
|
|
4
4
|
**Bun, Node (Docker), Deno Deploy, Cloudflare Pages, and Vercel Edge from one source**. `app.fetch`
|
|
5
5
|
is Web-standard, so only the server entry + build target differ per platform.
|
|
6
6
|
|
|
@@ -10,32 +10,32 @@ bun run dev # nifra dev → true-HMR dev server (Vite + nifra SSR) at htt
|
|
|
10
10
|
bun run preview # wrangler pages dev dist → preview the built Cloudflare bundle (run `bun run build` first)
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Routes are `.svelte` components under `routes/`
|
|
13
|
+
Routes are `.svelte` components under `routes/` - `index.svelte` (landing + a live loader/action
|
|
14
14
|
counter), `_layout.svelte` (chrome via the `children` snippet), `_404.svelte`. A route's
|
|
15
15
|
`loader`/`action`/`meta` are named exports from its `<script module>` block; the page receives the
|
|
16
16
|
loader output as the `data` prop (`let { data } = $props()`). The frontend adapter is one line in
|
|
17
17
|
`framework.ts`; data lives behind `backend.ts`. Each `build*` script wires `svelteBunPlugin("dom")` for
|
|
18
18
|
the client and `("ssr")` for the server.
|
|
19
19
|
|
|
20
|
-
## Deploy
|
|
20
|
+
## Deploy - pick a target
|
|
21
21
|
|
|
22
22
|
| target | build | deploy |
|
|
23
23
|
| --- | --- | --- |
|
|
24
|
-
| **Bun** (flagship) | `bun run build:bun` | `bun run start`
|
|
24
|
+
| **Bun** (flagship) | `bun run build:bun` | `bun run start` - any host |
|
|
25
25
|
| **Node** | `bun run build:node` | `docker build -t app . && docker run -p 3000:3000 app` (or `bun run start:node`) |
|
|
26
26
|
| **Deno Deploy** | `bun run build:deno` | `deployctl deploy --prod --entrypoint=dist-deno/server-deno.js` |
|
|
27
27
|
| **Cloudflare Pages** | `bun run build` | `bun run deploy:cf` |
|
|
28
28
|
| **Vercel Edge** | `bun run build:vercel` | `bun run deploy:vercel` |
|
|
29
29
|
|
|
30
|
-
nifra never enters your cloud credentials
|
|
30
|
+
nifra never enters your cloud credentials - it scaffolds the configs (`Dockerfile`, `deno.json`,
|
|
31
31
|
`wrangler.toml`, Vercel Build Output API); you run the vendor CLI.
|
|
32
32
|
|
|
33
33
|
## Structure
|
|
34
34
|
|
|
35
35
|
```
|
|
36
36
|
routes/ index.svelte (landing), _layout.svelte (chrome), _404.svelte
|
|
37
|
-
framework.ts the adapter (svelteAdapter)
|
|
38
|
-
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Svelte plugins)
|
|
37
|
+
framework.ts the adapter (svelteAdapter) - imported by the server entries (edge-bundlable)
|
|
38
|
+
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Svelte plugins) - read by `nifra dev`
|
|
39
39
|
backend.ts your contract (loaders/actions call it in-process)
|
|
40
40
|
server-bun.ts Bun entry (Bun.serve) build-bun.ts → dist-bun/
|
|
41
41
|
_worker.ts Cloudflare Pages entry build.ts → dist/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The nifra CLI's config
|
|
2
|
-
// Bun), so it can eagerly import the Vite plugin + the Svelte compiler
|
|
1
|
+
// The nifra CLI's config - read by `nifra dev|build|start`. It's imported ONLY by the CLI (which runs on
|
|
2
|
+
// Bun), so it can eagerly import the Vite plugin + the Svelte compiler - keeping them OUT of the edge
|
|
3
3
|
// worker bundle that `framework.ts` (the render-adapter source the entries import) must stay free of.
|
|
4
4
|
import { svelte } from "@sveltejs/vite-plugin-svelte"
|
|
5
5
|
import { svelteBunPlugin } from "@nifrajs/web-svelte/plugin"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- Root layout
|
|
1
|
+
<!-- Root layout - wraps every page via the `children` snippet (the Chain fold passes the page there). -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
let { children } = $props()
|
|
4
4
|
const css = `
|
|
@@ -27,7 +27,7 @@ export async function action({ api }: ActionArgs<typeof backend>) {
|
|
|
27
27
|
<section class="hero">
|
|
28
28
|
<h1>Your nifra app,<br /><span class="grad">everywhere.</span></h1>
|
|
29
29
|
<p>
|
|
30
|
-
SSR + hydration, end-to-end types, Svelte. One source
|
|
30
|
+
SSR + hydration, end-to-end types, Svelte. One source - deploy to Cloudflare Pages, Node, Deno,
|
|
31
31
|
or Vercel Edge. Edit <code>routes/index.svelte</code> to begin.
|
|
32
32
|
</p>
|
|
33
33
|
</section>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nifra site (Vue)
|
|
2
2
|
|
|
3
|
-
A nifra + **Vue** SSR site
|
|
3
|
+
A nifra + **Vue** SSR site - file-based routes, typed loaders/actions, hydration - that deploys to
|
|
4
4
|
**Bun, Node (Docker), Deno Deploy, Cloudflare Pages, and Vercel Edge from one source**. `app.fetch`
|
|
5
5
|
is Web-standard, so only the server entry + build target differ per platform.
|
|
6
6
|
|
|
@@ -10,32 +10,32 @@ bun run dev # nifra dev → true-HMR dev server (Vite + nifra SSR) at htt
|
|
|
10
10
|
bun run preview # wrangler pages dev dist → preview the built Cloudflare bundle (run `bun run build` first)
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Routes are **Vue SFCs** (`.vue`) under `routes/`
|
|
13
|
+
Routes are **Vue SFCs** (`.vue`) under `routes/` - `index.vue` (landing + a live loader/action
|
|
14
14
|
counter), `_layout.vue` (chrome via the default slot), `_404.vue`. A route SFC's plain `<script>`
|
|
15
15
|
carries nifra's `loader`/`action`/`meta`; `<script setup>` + `<template>` are the component. The
|
|
16
16
|
build compiles them with `vueBunPlugin` (`@nifrajs/web-vue/plugin`). The frontend adapter is one line in
|
|
17
17
|
`framework.ts`; data lives behind `backend.ts`.
|
|
18
18
|
|
|
19
|
-
## Deploy
|
|
19
|
+
## Deploy - pick a target
|
|
20
20
|
|
|
21
21
|
| target | build | deploy |
|
|
22
22
|
| --- | --- | --- |
|
|
23
|
-
| **Bun** (flagship) | `bun run build:bun` | `bun run start`
|
|
23
|
+
| **Bun** (flagship) | `bun run build:bun` | `bun run start` - any host |
|
|
24
24
|
| **Node** | `bun run build:node` | `docker build -t app . && docker run -p 3000:3000 app` (or `bun run start:node`) |
|
|
25
25
|
| **Deno Deploy** | `bun run build:deno` | `deployctl deploy --prod --entrypoint=dist-deno/server-deno.js` |
|
|
26
26
|
| **Cloudflare Pages** | `bun run build` | `bun run deploy:cf` |
|
|
27
27
|
| **Vercel Edge** | `bun run build:vercel` | `bun run deploy:vercel` |
|
|
28
28
|
|
|
29
29
|
The routes, `backend.ts`, and the client bundle are shared; each `build*` script swaps `buildServer`'s
|
|
30
|
-
target/conditions and the server entry. nifra never enters your cloud credentials
|
|
30
|
+
target/conditions and the server entry. nifra never enters your cloud credentials - it scaffolds the
|
|
31
31
|
configs (`Dockerfile`, `deno.json`, `wrangler.toml`, Vercel Build Output API); you run the vendor CLI.
|
|
32
32
|
|
|
33
33
|
## Structure
|
|
34
34
|
|
|
35
35
|
```
|
|
36
36
|
routes/ index.vue (landing), _layout.vue (chrome), _404.vue (Vue SFCs)
|
|
37
|
-
framework.ts the adapter (vueAdapter)
|
|
38
|
-
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Vue plugins)
|
|
37
|
+
framework.ts the adapter (vueAdapter) - imported by the server entries (edge-bundlable)
|
|
38
|
+
nifra.config.ts the nifra CLI's dev/build config (adapter + clientModule + Vue plugins) - read by `nifra dev`
|
|
39
39
|
backend.ts your contract (loaders/actions call it in-process)
|
|
40
40
|
server-bun.ts Bun entry (Bun.serve) build-bun.ts → dist-bun/
|
|
41
41
|
_worker.ts Cloudflare Pages entry build.ts → dist/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The nifra CLI's config
|
|
2
|
-
// Bun), so it can eagerly import the Vite plugin + the SFC compiler
|
|
1
|
+
// The nifra CLI's config - read by `nifra dev|build|start`. It's imported ONLY by the CLI (which runs on
|
|
2
|
+
// Bun), so it can eagerly import the Vite plugin + the SFC compiler - keeping them OUT of the edge
|
|
3
3
|
// worker bundle that `framework.ts` (the render-adapter source the entries import) must stay free of.
|
|
4
4
|
import { vueBunPlugin } from "@nifrajs/web-vue/plugin"
|
|
5
5
|
import vue from "@vitejs/plugin-vue"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Root layout (Vue SFC)
|
|
3
|
-
The global stylesheet is rendered as a <style> element via <component :is="'style'">
|
|
2
|
+
Root layout (Vue SFC) - wraps every page; the compose fold passes the page through the default slot.
|
|
3
|
+
The global stylesheet is rendered as a <style> element via <component :is="'style'"> - SFC <style>
|
|
4
4
|
blocks are dropped (nifra has no CSS pipeline), and a dynamic component sidesteps the template
|
|
5
5
|
compiler's special-casing of a literal <style> tag. Keeps the whole template single-file.
|
|
6
6
|
-->
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Home route (Vue SFC). The plain <script> carries nifra's route convention
|
|
2
|
+
Home route (Vue SFC). The plain <script> carries nifra's route convention - loader/action/meta are
|
|
3
3
|
server-only named exports the client codegen tree-shakes out. <script setup> + <template> are the
|
|
4
4
|
component. The form POST is the SSR action path; after a client submit the loader revalidates with
|
|
5
5
|
no full reload (progressive enhancement). Compiled by @nifrajs/web-vue/plugin.
|
|
@@ -26,7 +26,7 @@ export async function action({ api }: ActionArgs<typeof backend>) {
|
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
28
|
<script setup lang="ts">
|
|
29
|
-
// compose() spreads data/actionData/pending/submission as props
|
|
29
|
+
// compose() spreads data/actionData/pending/submission as props - declare them so they aren't attrs.
|
|
30
30
|
defineProps(["data", "actionData", "pending", "submission"])
|
|
31
31
|
</script>
|
|
32
32
|
|
|
@@ -35,7 +35,7 @@ defineProps(["data", "actionData", "pending", "submission"])
|
|
|
35
35
|
<section class="hero">
|
|
36
36
|
<h1>Your nifra app,<br /><span class="grad">everywhere.</span></h1>
|
|
37
37
|
<p>
|
|
38
|
-
SSR + hydration, end-to-end types, Vue. One source
|
|
38
|
+
SSR + hydration, end-to-end types, Vue. One source - deploy to Cloudflare Pages, Node, Deno,
|
|
39
39
|
or Vercel Edge. Edit <code>routes/index.vue</code> to begin.
|
|
40
40
|
</p>
|
|
41
41
|
</section>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Build for Bun (nifra's flagship runtime) → dist-bun/ (server-bun.js + client assets).
|
|
2
|
-
// `bun run build:bun`. Run: `bun dist-bun/server-bun.js`.
|
|
3
|
-
import { cpSync, mkdirSync, rmSync } from "node:fs"
|
|
4
|
-
import { buildClient, buildServer } from "@nifrajs/web/build"
|
|
5
|
-
|
|
6
|
-
const dir = import.meta.dir
|
|
7
|
-
const dist = `${dir}/dist-bun`
|
|
8
|
-
rmSync(dist, { recursive: true, force: true })
|
|
9
|
-
mkdirSync(`${dist}/assets`, { recursive: true })
|
|
10
|
-
|
|
11
|
-
const client = await buildClient({
|
|
12
|
-
routesDir: `${dir}/routes`,
|
|
13
|
-
outDir: `${dist}/assets`,
|
|
14
|
-
clientModule: "@nifrajs/web-react/client",
|
|
15
|
-
conditions: ["bun", "browser"],
|
|
16
|
-
define: { "process.env.NODE_ENV": '"production"' },
|
|
17
|
-
})
|
|
18
|
-
const { worker } = await buildServer({
|
|
19
|
-
routesDir: `${dir}/routes`,
|
|
20
|
-
serverEntry: `${dir}/server-bun.ts`,
|
|
21
|
-
outDir: `${dir}/.build-bun`,
|
|
22
|
-
target: "bun",
|
|
23
|
-
clientEntry: client.entry,
|
|
24
|
-
})
|
|
25
|
-
cpSync(worker, `${dist}/server-bun.js`)
|
|
26
|
-
rmSync(`${dir}/.build-bun`, { recursive: true, force: true })
|
|
27
|
-
console.log("Bun output → dist-bun (run: bun dist-bun/server-bun.js)")
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Build for Deno → dist-deno/ (server-deno.js + client assets). `bun run build:deno`.
|
|
2
|
-
import { cpSync, mkdirSync, rmSync } from "node:fs"
|
|
3
|
-
import { buildClient, buildServer } from "@nifrajs/web/build"
|
|
4
|
-
|
|
5
|
-
const dir = import.meta.dir
|
|
6
|
-
const dist = `${dir}/dist-deno`
|
|
7
|
-
rmSync(dist, { recursive: true, force: true })
|
|
8
|
-
mkdirSync(`${dist}/assets`, { recursive: true })
|
|
9
|
-
|
|
10
|
-
const client = await buildClient({
|
|
11
|
-
routesDir: `${dir}/routes`,
|
|
12
|
-
outDir: `${dist}/assets`,
|
|
13
|
-
clientModule: "@nifrajs/web-react/client",
|
|
14
|
-
conditions: ["bun", "browser"],
|
|
15
|
-
define: { "process.env.NODE_ENV": '"production"' },
|
|
16
|
-
})
|
|
17
|
-
const { worker } = await buildServer({
|
|
18
|
-
routesDir: `${dir}/routes`,
|
|
19
|
-
serverEntry: `${dir}/server-deno.ts`,
|
|
20
|
-
outDir: `${dir}/.build-deno`,
|
|
21
|
-
clientEntry: client.entry,
|
|
22
|
-
})
|
|
23
|
-
cpSync(worker, `${dist}/server-deno.js`)
|
|
24
|
-
rmSync(`${dir}/.build-deno`, { recursive: true, force: true })
|
|
25
|
-
console.log("Deno output → dist-deno (run: deno run -A dist-deno/server-deno.js)")
|