fondu 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -30
- package/dist/vite/index.js +31 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -6,13 +6,20 @@ runs on **Node, Bun and Cloudflare Workers**.
|
|
|
6
6
|
|
|
7
7
|
Fondu is glue, not a new framework: it joins Hono, Inertia and Vite, and writes as little of its own as it can.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun create fondu my-app # or: npm create fondu@latest my-app · pnpm create fondu my-app
|
|
13
|
+
cd my-app
|
|
14
|
+
bun dev
|
|
14
15
|
```
|
|
15
16
|
|
|
17
|
+
It asks where the app runs (Node, Bun or Cloudflare Workers; or `--target node|bun|cloudflare`) and writes a small
|
|
18
|
+
app: a route, its page, the error page, Tailwind CSS, editor snippets and an `AGENTS.md` for coding agents.
|
|
19
|
+
|
|
20
|
+
Two examples in this repository show more: [apps/node](apps/node) (Node and Bun) and [apps/cloudflare](apps/cloudflare)
|
|
21
|
+
(every Inertia v3 feature, one page each, with D1 and Better Auth).
|
|
22
|
+
|
|
16
23
|
## Who does what
|
|
17
24
|
|
|
18
25
|
| Part | Done by |
|
|
@@ -23,29 +30,8 @@ apps/cloudflare every Inertia v3 feature, one page each — Workers, D1, Bett
|
|
|
23
30
|
| Page resolution, the server render's entry | `@inertiajs/vite` (rendered in the same process) |
|
|
24
31
|
| The Inertia v3 server protocol, `routes/`, generated types, the document, error pages, server-only guard | Fondu |
|
|
25
32
|
|
|
26
|
-
## This repository
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
bun install # also builds packages/fondu (the examples use the built package, like a real app)
|
|
30
|
-
bun run test # the protocol, on a small app with app.request()
|
|
31
|
-
bun run typecheck # the package and both examples (with apps/cloudflare/e2e/types.ts)
|
|
32
|
-
bun run check # format (oxfmt), lint (oxlint), typecheck
|
|
33
|
-
bun run dev # rebuild packages/fondu on change
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Commits follow [Conventional Commits](https://www.conventionalcommits.org) (lefthook runs commitlint, and formats and
|
|
37
|
-
lints what is staged). A release: `bun run release` picks the version, tags it and pushes; CI publishes the tag to npm
|
|
38
|
-
(trusted publishing, with provenance) and writes the GitHub Release from the commits.
|
|
39
|
-
|
|
40
|
-
`apps/node`: `bun run dev`; `bun run build && bun run start` (Node); `bun run build:bun && bun run start:bun` (Bun).
|
|
41
|
-
`apps/cloudflare`: `cp .dev.vars.example .dev.vars`, then `bun run dev` (in workerd), `bun run preview`, `bun run deploy`.
|
|
42
|
-
|
|
43
33
|
## An app
|
|
44
34
|
|
|
45
|
-
```bash
|
|
46
|
-
bun create fondu my-app # or: npm create fondu@latest my-app — asks for the target, then installs
|
|
47
|
-
```
|
|
48
|
-
|
|
49
35
|
```
|
|
50
36
|
package.json fondu hono @inertiajs/react react react-dom (Node: also @hono/node-server)
|
|
51
37
|
"imports": { "#/*": "./app/*" }: import '#/lib/db.server.ts' from anywhere in app/
|
|
@@ -165,10 +151,40 @@ during a visit). `render()` of a page that doesn't exist says which file to crea
|
|
|
165
151
|
### Editor snippets
|
|
166
152
|
|
|
167
153
|
`.vscode/fondu.code-snippets`: `/route`, `/api`, `/loader`, `/action`, `/actions`, `/validated`, `/get` … `/delete`,
|
|
168
|
-
`/middleware` in routes; `/page`, `/layout`, `/form` in pages.
|
|
154
|
+
`/middleware` in routes; `/page`, `/layout`, `/form` in pages. A new app has it; edit it freely.
|
|
169
155
|
|
|
170
156
|
## Deploying
|
|
171
157
|
|
|
172
|
-
- **Node**: `vite build --mode client && vite build`, then `node dist/index.js` (dependencies stay in `node_modules`). `PORT` sets the port; SIGTERM / SIGINT wait for running requests (10 s).
|
|
173
|
-
- **Bun**: `fondu({ target: 'bun' })`, `bun dist/index.js`.
|
|
174
|
-
- **Cloudflare Workers**: `wrangler.jsonc` `main` is `./app/server.ts`; one `vite build
|
|
158
|
+
- **Node**: `vite build --mode client && vite build`, then `NODE_ENV=production node dist/index.js` (dependencies stay in `node_modules`; `NODE_ENV` makes React use its production build). `PORT` sets the port (default 3000); SIGTERM / SIGINT wait for running requests (10 s).
|
|
159
|
+
- **Bun**: `fondu({ target: 'bun' })`, `NODE_ENV=production bun dist/index.js`.
|
|
160
|
+
- **Cloudflare Workers**: `wrangler.jsonc` `main` is `./app/server.ts`; one `vite build` (the Worker minified: it starts faster; `build.minify: false` in its Vite environment keeps it readable); `wrangler deploy`. `/assets/*` get long-lived caching from a generated `_headers` (unless `public/_headers` exists).
|
|
161
|
+
|
|
162
|
+
## Contributing
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
packages/fondu the package (≈1,100 lines)
|
|
166
|
+
packages/create-fondu `bun create fondu`
|
|
167
|
+
apps/node a small example: Link, loader, action, HTTP routes — Node and Bun
|
|
168
|
+
apps/cloudflare every Inertia v3 feature, one page each — Workers, D1, Better Auth, Base UI
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
bun install # also builds packages/fondu (the examples use the built package, like a real app)
|
|
173
|
+
bun run test # the protocol, on a small app with app.request()
|
|
174
|
+
bun run typecheck # the package and both examples (with apps/cloudflare/e2e/types.ts)
|
|
175
|
+
bun run check # format (oxfmt), lint (oxlint), typecheck
|
|
176
|
+
bun run dev # rebuild packages/fondu on change
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org) (lefthook runs commitlint, and formats and
|
|
180
|
+
lints what is staged). A release: `bun run release` picks the version, tags it and pushes; CI publishes the tag to npm
|
|
181
|
+
(trusted publishing, with provenance) and writes the GitHub Release from the commits.
|
|
182
|
+
|
|
183
|
+
`apps/node`: `bun run dev`; `bun run build && bun run start` (Node); `bun run build:bun && bun run start:bun` (Bun).
|
|
184
|
+
`apps/cloudflare`: `cp .dev.vars.example .dev.vars`, then `bun run dev` (in workerd), `bun run preview`, `bun run deploy`.
|
|
185
|
+
|
|
186
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the details, and [SECURITY.md](SECURITY.md) to report a vulnerability.
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
|
package/dist/vite/index.js
CHANGED
|
@@ -49,11 +49,18 @@ async function buildPlugin(options) {
|
|
|
49
49
|
entry: SERVER,
|
|
50
50
|
external,
|
|
51
51
|
outputDir: './dist',
|
|
52
|
-
// Node:
|
|
53
|
-
//
|
|
52
|
+
// Node: @hono/node-server's serve() on `PORT` (else the option), saying where it listens, with a graceful
|
|
53
|
+
// shutdown on SIGTERM / SIGINT (10 s). Bun serves the default export itself and reads `PORT`.
|
|
54
54
|
...(options.target === 'node' && {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
entryContentAfterHooks: [
|
|
56
|
+
(app) => [
|
|
57
|
+
`import { serve } from '@hono/node-server'`,
|
|
58
|
+
`const server = serve({ fetch: ${app}.fetch, port: Number(process.env.PORT) || ${options.port ?? 3000} }, (info) => console.log(\`Listening on http://localhost:\${info.port}\`))`,
|
|
59
|
+
`const shutdown = () => { server.close(() => process.exit(0)); setTimeout(() => process.exit(1), 10_000).unref() }`,
|
|
60
|
+
`process.on('SIGINT', shutdown)`,
|
|
61
|
+
`process.on('SIGTERM', shutdown)`,
|
|
62
|
+
].join('\n'),
|
|
63
|
+
],
|
|
57
64
|
}),
|
|
58
65
|
// the client build's files (dist/client), found next to the server bundle wherever it runs from; hashed files
|
|
59
66
|
// never change
|
|
@@ -136,6 +143,26 @@ function core(options) {
|
|
|
136
143
|
build: { copyPublicDir: false, rollupOptions: { output: { chunkFileNames: 'server/[name]-[hash].js' } } },
|
|
137
144
|
};
|
|
138
145
|
},
|
|
146
|
+
// dev: the dependencies are found before the first request (Vite scans index.html by default; an app has none),
|
|
147
|
+
// so the first page is not reloaded once they are optimized
|
|
148
|
+
configEnvironment(name, env) {
|
|
149
|
+
const pages = ['app/pages/**/*.tsx', 'app/pages/**/*.jsx'];
|
|
150
|
+
if (name === 'client')
|
|
151
|
+
return { optimizeDeps: { entries: [ENTRY, ...pages] } };
|
|
152
|
+
if (options.target !== 'cloudflare')
|
|
153
|
+
return;
|
|
154
|
+
// the Worker: fondu is not pre-bundled (its routes import it back: a bundle would hand them a half-loaded
|
|
155
|
+
// module); react-dom/server is imported by @inertiajs/vite's generated render, which the scan does not see.
|
|
156
|
+
// The build is minified, as Workers start faster with less code to parse
|
|
157
|
+
return {
|
|
158
|
+
optimizeDeps: {
|
|
159
|
+
exclude: ['fondu'],
|
|
160
|
+
include: options.ssr === false ? [] : ['react-dom/server'],
|
|
161
|
+
entries: [SERVER.slice(2), 'app/routes/**/*.ts', ENTRY, ...pages],
|
|
162
|
+
},
|
|
163
|
+
...(env.build?.minify === undefined && { build: { minify: true } }),
|
|
164
|
+
};
|
|
165
|
+
},
|
|
139
166
|
configResolved(c) {
|
|
140
167
|
config = c;
|
|
141
168
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fondu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Inertia v3 on Hono, with file routes (loader, action, actions) and pages. Node, Bun and Cloudflare Workers.",
|
|
5
5
|
"homepage": "https://github.com/fondujs/fondu#readme",
|
|
6
6
|
"bugs": "https://github.com/fondujs/fondu/issues",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"typecheck": "tsc -p tsconfig.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@hono/vite-build": "1.11.1",
|
|
40
|
-
"@hono/vite-dev-server": "0.26.1",
|
|
41
|
-
"@inertiajs/vite": "3.9.1",
|
|
42
|
-
"@vitejs/plugin-react": "6.1.2"
|
|
39
|
+
"@hono/vite-build": "^1.11.1",
|
|
40
|
+
"@hono/vite-dev-server": "^0.26.1",
|
|
41
|
+
"@inertiajs/vite": "^3.9.1",
|
|
42
|
+
"@vitejs/plugin-react": "^6.1.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@inertiajs/core": "3.9.1",
|