defuss-ssg 0.4.0 → 0.5.2
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 +213 -231
- package/dist/cli.mjs +6 -7
- package/dist/index.cjs +13 -9
- package/dist/index.d.cts +12 -13
- package/dist/index.d.mts +12 -13
- package/dist/index.mjs +5 -6
- package/dist/runtime.cjs +611 -80
- package/dist/runtime.d.cts +17 -3
- package/dist/runtime.d.mts +17 -3
- package/dist/runtime.mjs +609 -78
- package/dist/{serve-CLC1GbGD.mjs → serve-CSH82zKY.mjs} +10 -2
- package/dist/{vite-CPvbAFU5.cjs → vite-CQJBNUfy.cjs} +688 -328
- package/dist/{vite-DyhxNy3G.mjs → vite-DcjFCDSl.mjs} +690 -328
- package/dist/{types-5c6EwOyf.d.cts → vite-DtwFnDf2.d.cts} +10 -10
- package/dist/{types-5c6EwOyf.d.mts → vite-DtwFnDf2.d.mts} +10 -10
- package/dist/vite.cjs +4 -5
- package/dist/vite.d.cts +2 -6
- package/dist/vite.d.mts +2 -6
- package/dist/vite.mjs +4 -5
- package/package.json +8 -27
- package/dist/components/index.cjs +0 -29
- package/dist/components/index.d.cts +0 -11
- package/dist/components/index.d.mts +0 -11
- package/dist/components/index.mjs +0 -27
- package/dist/plugins/index.cjs +0 -8
- package/dist/plugins/index.d.cts +0 -7
- package/dist/plugins/index.d.mts +0 -7
- package/dist/plugins/index.mjs +0 -2
- package/dist/tailwind-C4AuHybm.cjs +0 -14
- package/dist/tailwind-DV23JSh-.mjs +0 -12
package/README.md
CHANGED
|
@@ -1,338 +1,320 @@
|
|
|
1
|
-
|
|
1
|
+
# defuss-ssg
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Static site generation, request-time dev SSR, file-based endpoints, and production serving for defuss.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<code>defuss-ssg</code>
|
|
5
|
+
`defuss-ssg` is both a CLI and a library:
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- `dev` starts a Vite server and renders MD/MDX pages on demand through SSR.
|
|
8
|
+
- `build` renders static HTML, bundles client components, compiles endpoints, and copies assets.
|
|
9
|
+
- `serve` serves built output with `defuss-express`, plus dynamic endpoints and optional RPC.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Use Bun for package management. The published package targets Node `^20.19.0 || >=22.12.0`.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## What It Supports
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
- Markdown and MDX pages from `pages/`
|
|
16
|
+
- YAML or TOML frontmatter exposed as `meta`
|
|
17
|
+
- GitHub Flavored Markdown via `remark-gfm`
|
|
18
|
+
- KaTeX math via `$...$` and `$$...$$`
|
|
19
|
+
- defuss components imported into MDX and HTML-like pages
|
|
20
|
+
- Automatic hydration boundaries for components rendered from `components/`
|
|
21
|
+
- Static assets copied from `assets/`
|
|
22
|
+
- File-based API routes from `pages/**/*.ts` and `pages/**/*.js`
|
|
23
|
+
- Pre-rendered endpoints via `prerender = true` and `getStaticPaths()`
|
|
24
|
+
- RPC auto-discovery from `rpc.ts` or `rpc.js` when `defuss-rpc` is installed
|
|
25
|
+
- Plugin hooks for `pre`, `page-vdom`, `page-dom`, `page-html`, and `post`
|
|
26
|
+
- Multicore production serving through `--multicore` or `workers: "auto"`
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
## Install
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
Usage
|
|
21
|
-
</h3>
|
|
22
|
-
|
|
23
|
-
Simply generate a static site from a content directory to an output directory with full defuss-MDX (GFM + Frontmatter) support:
|
|
30
|
+
Run directly:
|
|
24
31
|
|
|
25
32
|
```bash
|
|
26
|
-
bunx defuss-ssg build ./
|
|
33
|
+
bunx defuss-ssg build ./my-site
|
|
27
34
|
```
|
|
28
35
|
|
|
29
|
-
Or
|
|
36
|
+
Or add it as a dev dependency:
|
|
30
37
|
|
|
31
|
-
```bash
|
|
32
|
-
bun add -
|
|
38
|
+
```bash
|
|
39
|
+
bun add -D defuss-ssg
|
|
33
40
|
```
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
## Quick Start
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
```text
|
|
45
|
+
my-site/
|
|
46
|
+
├-- pages/
|
|
47
|
+
| ├-- index.mdx
|
|
48
|
+
| └-- api/
|
|
49
|
+
| └-- ping.json.ts
|
|
50
|
+
├-- components/
|
|
51
|
+
| └-- button.tsx
|
|
52
|
+
├-- assets/
|
|
53
|
+
| └-- styles.css
|
|
54
|
+
├-- config.ts
|
|
55
|
+
└-- rpc.ts
|
|
41
56
|
```
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
Minimal config:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { rehypePlugins, remarkPlugins, type SsgConfig } from "defuss-ssg";
|
|
62
|
+
|
|
63
|
+
const config: SsgConfig = {
|
|
64
|
+
pages: "pages",
|
|
65
|
+
output: "dist",
|
|
66
|
+
components: "components",
|
|
67
|
+
assets: "assets",
|
|
68
|
+
tmp: ".ssg-temp",
|
|
69
|
+
plugins: [],
|
|
70
|
+
remarkPlugins: [...remarkPlugins],
|
|
71
|
+
rehypePlugins: [...rehypePlugins],
|
|
72
|
+
rpc: true,
|
|
73
|
+
};
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
defuss-ssg dev ./folder
|
|
75
|
+
export default config;
|
|
47
76
|
```
|
|
48
77
|
|
|
49
|
-
|
|
78
|
+
Example page:
|
|
50
79
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
80
|
+
```mdx
|
|
81
|
+
---
|
|
82
|
+
title: Home
|
|
83
|
+
---
|
|
54
84
|
|
|
55
|
-
|
|
85
|
+
import { Button } from "../components/button.js";
|
|
56
86
|
|
|
57
|
-
|
|
87
|
+
# {meta.title}
|
|
58
88
|
|
|
59
|
-
|
|
89
|
+
This page uses MDX, frontmatter, and a defuss component.
|
|
60
90
|
|
|
61
|
-
|
|
62
|
-
defuss-ssg serve ./folder
|
|
91
|
+
<Button label="Click me" />
|
|
63
92
|
```
|
|
64
93
|
|
|
65
|
-
|
|
94
|
+
Example component:
|
|
66
95
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
96
|
+
```tsx
|
|
97
|
+
export function Button({ label }: { label: string }) {
|
|
98
|
+
return <button type="button">{label}</button>;
|
|
99
|
+
}
|
|
100
|
+
```
|
|
70
101
|
|
|
71
|
-
|
|
102
|
+
Build the site:
|
|
72
103
|
|
|
73
104
|
```bash
|
|
74
|
-
|
|
105
|
+
defuss-ssg build ./my-site
|
|
106
|
+
```
|
|
75
107
|
|
|
76
|
-
|
|
108
|
+
Start Vite-powered development:
|
|
77
109
|
|
|
78
|
-
|
|
110
|
+
```bash
|
|
111
|
+
defuss-ssg dev ./my-site
|
|
112
|
+
```
|
|
79
113
|
|
|
80
|
-
|
|
81
|
-
bun run cli-dev ./example
|
|
114
|
+
Serve the already built output:
|
|
82
115
|
|
|
83
|
-
|
|
84
|
-
|
|
116
|
+
```bash
|
|
117
|
+
defuss-ssg serve ./my-site
|
|
85
118
|
```
|
|
86
119
|
|
|
87
|
-
|
|
120
|
+
`serve` expects existing build output in `dist/`, so run `build` first.
|
|
88
121
|
|
|
89
|
-
|
|
122
|
+
## How It Works
|
|
90
123
|
|
|
91
|
-
|
|
124
|
+
### Dev Mode
|
|
92
125
|
|
|
93
|
-
|
|
94
|
-
import { setup, build, dev, serve } from "defuss-ssg";
|
|
126
|
+
`defuss-ssg dev` starts a Vite server rooted at your project. Requests for MD and MDX pages are resolved through Vite's transform pipeline and rendered on demand with SSR. Page, component, endpoint, RPC, config, and asset changes are coalesced before reload. CSS assets are hot-swapped when possible, and hydration boundaries restore local form and scroll state across component updates.
|
|
95
127
|
|
|
96
|
-
|
|
128
|
+
By default, the CLI keeps `dist/` refreshed during dev as a compatibility fallback for middleware paths. Programmatic users can disable that bridge with `writeDevOutput: false`.
|
|
97
129
|
|
|
98
|
-
|
|
99
|
-
const setupStatus = await setup("./my-site");
|
|
100
|
-
if (setupStatus.code !== "OK") {
|
|
101
|
-
console.error("Setup failed:", setupStatus.message);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
130
|
+
### Build Mode
|
|
104
131
|
|
|
105
|
-
|
|
106
|
-
await build({
|
|
107
|
-
projectDir: "./my-site",
|
|
108
|
-
debug: true,
|
|
109
|
-
});
|
|
132
|
+
`defuss-ssg build` loads `config.ts`, copies the project into `.ssg-temp`, renders each page through a temporary Vite SSR server, applies automatic hydration wrapping, bundles client components, compiles endpoints into `.endpoints`, copies assets into `dist`, and removes the temp directory unless debug mode is enabled.
|
|
110
133
|
|
|
111
|
-
|
|
112
|
-
await dev({
|
|
113
|
-
projectDir: "./my-site",
|
|
114
|
-
debug: true,
|
|
115
|
-
});
|
|
134
|
+
### Serve Mode
|
|
116
135
|
|
|
117
|
-
|
|
118
|
-
await serve({
|
|
119
|
-
projectDir: "./my-site",
|
|
120
|
-
workers: "auto",
|
|
121
|
-
});
|
|
122
|
-
})();
|
|
123
|
-
```
|
|
136
|
+
`defuss-ssg serve` reads the built output from `dist/` and serves it with `defuss-express`. Dynamic endpoint modules are registered at runtime, and `rpc.ts` or `rpc.js` is compiled and initialized automatically when RPC is enabled and `defuss-rpc` is installed.
|
|
124
137
|
|
|
125
|
-
|
|
126
|
-
Overview
|
|
127
|
-
</h3>
|
|
138
|
+
## Endpoints
|
|
128
139
|
|
|
129
|
-
|
|
140
|
+
Endpoint source files live under `pages/` and export HTTP method handlers.
|
|
130
141
|
|
|
131
|
-
|
|
142
|
+
```ts
|
|
143
|
+
import type { APIRoute } from "defuss-ssg";
|
|
132
144
|
|
|
133
|
-
|
|
145
|
+
export const GET: APIRoute = async () => {
|
|
146
|
+
return Response.json({ ok: true, ts: Date.now() });
|
|
147
|
+
};
|
|
148
|
+
```
|
|
134
149
|
|
|
135
|
-
|
|
150
|
+
Supported method exports are `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS`, and `ALL`.
|
|
136
151
|
|
|
137
|
-
|
|
152
|
+
Dynamic routes use bracket syntax:
|
|
138
153
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
- **Dev Mode**: Vite-backed development server with auto-rebuild and full reload
|
|
144
|
-
- **Production Runtime**: `defuss-express` serves static output plus dynamic endpoints and RPC
|
|
145
|
-
- **TypeScript Ready**: Full TypeScript support for components and configuration
|
|
146
|
-
- **Asset Handling**: Automatic copying of static assets to output directory
|
|
147
|
-
- **Flexible Configuration**: Configurable via TypeScript config file with sensible defaults
|
|
154
|
+
```text
|
|
155
|
+
pages/api/[id].json.ts -> /api/:id.json
|
|
156
|
+
pages/feed.xml.ts -> /feed.xml
|
|
157
|
+
```
|
|
148
158
|
|
|
149
|
-
|
|
159
|
+
To pre-render an endpoint during `build`, export `prerender = true`. Dynamic routes can also export `getStaticPaths()`.
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
```ts
|
|
162
|
+
import type { APIRoute } from "defuss-ssg";
|
|
152
163
|
|
|
153
|
-
|
|
164
|
+
export const prerender = true;
|
|
154
165
|
|
|
155
|
-
|
|
166
|
+
export const getStaticPaths = () => [
|
|
167
|
+
{ params: { slug: "hello-world" } },
|
|
168
|
+
{ params: { slug: "release-notes" } },
|
|
169
|
+
];
|
|
156
170
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
│ ├-- index.mdx
|
|
161
|
-
│ └-- blog/
|
|
162
|
-
│ └-- hello-world.mdx
|
|
163
|
-
├-- components/
|
|
164
|
-
│ └-- button.tsx
|
|
165
|
-
├-- assets/
|
|
166
|
-
│ └-- styles.css
|
|
167
|
-
└-- config.ts
|
|
171
|
+
export const GET: APIRoute = async ({ params }) => {
|
|
172
|
+
return new Response(`Post: ${params.slug}`);
|
|
173
|
+
};
|
|
168
174
|
```
|
|
169
|
-
Then run `defuss-ssg build ./my-site` and a `dist` folder will be created with the complete static build.
|
|
170
175
|
|
|
171
|
-
|
|
176
|
+
## RPC
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
</h3>
|
|
176
|
-
|
|
177
|
-
You can customize the paths and behaviour of the build process, by creating a simple `config.ts` file in the project folder.
|
|
178
|
-
|
|
179
|
-
##### Example `config.ts` file
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
import { remarkPlugins, rehypePlugins } from "defuss-ssg";
|
|
178
|
+
RPC is optional and discovered automatically from `rpc.ts` or `rpc.js` in the project root. Install `defuss-rpc` to enable it.
|
|
183
179
|
|
|
180
|
+
```ts
|
|
184
181
|
export default {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
plugins: [],
|
|
182
|
+
mathApi: {
|
|
183
|
+
add: async (a: number, b: number) => a + b,
|
|
184
|
+
},
|
|
185
|
+
greetApi: {
|
|
186
|
+
hello: async (name: string) => `Hello, ${name}!`,
|
|
187
|
+
},
|
|
192
188
|
};
|
|
193
189
|
```
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
`defuss-ssg` plugins can be registered via the `plugins` array and are executed in order of registration, in each build phase.
|
|
198
|
-
|
|
199
|
-
##### Example MDX page (`pages/index.mdx`)
|
|
200
|
-
|
|
201
|
-
```mdx
|
|
202
|
-
---
|
|
203
|
-
title: Home Page
|
|
204
|
-
---
|
|
191
|
+
When RPC is active, `defuss-ssg` exposes:
|
|
205
192
|
|
|
206
|
-
|
|
193
|
+
- `POST /rpc`
|
|
194
|
+
- `POST /rpc/schema`
|
|
207
195
|
|
|
208
|
-
|
|
196
|
+
Set `rpc: false` in `config.ts` to disable RPC discovery.
|
|
209
197
|
|
|
210
|
-
|
|
198
|
+
## Plugins
|
|
211
199
|
|
|
212
|
-
|
|
213
|
-
```
|
|
200
|
+
`defuss-ssg` plugins run in build order and can modify the pipeline at distinct phases.
|
|
214
201
|
|
|
215
|
-
|
|
202
|
+
```ts
|
|
203
|
+
import type { SsgPlugin } from "defuss-ssg";
|
|
216
204
|
|
|
217
|
-
|
|
205
|
+
const htmlStampPlugin: SsgPlugin = {
|
|
206
|
+
name: "html-stamp",
|
|
207
|
+
phase: "page-html",
|
|
208
|
+
mode: "both",
|
|
209
|
+
fn: (html, relativeOutputHtmlFilePath) => {
|
|
210
|
+
return html.replace(
|
|
211
|
+
"</body>",
|
|
212
|
+
`<!-- built:${relativeOutputHtmlFilePath} --></body>`,
|
|
213
|
+
);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
218
216
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
<button type="button" onClick={() => alert("Button clicked!")}>
|
|
223
|
-
{label}
|
|
224
|
-
</button>
|
|
225
|
-
);
|
|
217
|
+
export default {
|
|
218
|
+
plugins: [htmlStampPlugin],
|
|
226
219
|
};
|
|
227
220
|
```
|
|
228
221
|
|
|
222
|
+
Available phases:
|
|
229
223
|
|
|
230
|
-
|
|
224
|
+
- `pre`: before a full build starts
|
|
225
|
+
- `page-vdom`: after page VDOM creation and before render
|
|
226
|
+
- `page-dom`: after DOM render and before serialization
|
|
227
|
+
- `page-html`: after HTML serialization and before write
|
|
228
|
+
- `post`: after the build completes
|
|
231
229
|
|
|
232
|
-
|
|
230
|
+
`page-vdom` hooks receive the page props/module exports as their fifth argument.
|
|
233
231
|
|
|
234
|
-
|
|
232
|
+
## Programmatic API
|
|
235
233
|
|
|
236
|
-
|
|
234
|
+
```ts
|
|
235
|
+
import { build, dev, serve, setup } from "defuss-ssg";
|
|
237
236
|
|
|
238
|
-
|
|
239
|
-
import { rule, transval, access } from 'defuss-transval';
|
|
237
|
+
const projectDir = "./my-site";
|
|
240
238
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
email: string;
|
|
246
|
-
settings: {
|
|
247
|
-
theme: 'light' | 'dark';
|
|
248
|
-
notifications: boolean;
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
posts: Array<{
|
|
252
|
-
title: string;
|
|
253
|
-
published: boolean;
|
|
254
|
-
import { SsgPlugin } from "defuss-ssg";
|
|
239
|
+
const setupStatus = await setup(projectDir);
|
|
240
|
+
if (setupStatus.code !== "OK") {
|
|
241
|
+
throw new Error(setupStatus.message);
|
|
242
|
+
}
|
|
255
243
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return html.replace("old-text", "new-text");
|
|
262
|
-
},
|
|
263
|
-
};
|
|
244
|
+
await build({
|
|
245
|
+
projectDir,
|
|
246
|
+
mode: "build",
|
|
247
|
+
debug: true,
|
|
248
|
+
});
|
|
264
249
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
250
|
+
await dev({
|
|
251
|
+
projectDir,
|
|
252
|
+
port: 3000,
|
|
253
|
+
host: true,
|
|
254
|
+
writeDevOutput: true,
|
|
255
|
+
});
|
|
270
256
|
|
|
271
|
-
|
|
257
|
+
await serve({
|
|
258
|
+
projectDir,
|
|
259
|
+
port: 3000,
|
|
260
|
+
workers: "auto",
|
|
261
|
+
});
|
|
262
|
+
```
|
|
272
263
|
|
|
273
|
-
|
|
274
|
-
- **page-vdom**: After VDOM creation for each page
|
|
275
|
-
- **page-dom**: After DOM rendering for each page
|
|
276
|
-
- **page-html**: After HTML serialization for each page
|
|
277
|
-
- **post**: After build completes
|
|
264
|
+
The main package exports `build`, `dev`, `serve`, `setup`, config defaults, endpoint types, RPC helpers, and plugin types.
|
|
278
265
|
|
|
266
|
+
Advanced subpath exports:
|
|
279
267
|
|
|
280
|
-
|
|
268
|
+
- `defuss-ssg/vite`: exposes `defussSsg()` for custom Vite integration
|
|
269
|
+
- `defuss-ssg/runtime`: exposes the client runtime used for navigation, hydration, and live reload
|
|
281
270
|
|
|
282
|
-
|
|
271
|
+
Most projects only need the main package export.
|
|
283
272
|
|
|
284
|
-
|
|
273
|
+
## CLI Reference
|
|
285
274
|
|
|
286
|
-
|
|
275
|
+
```bash
|
|
276
|
+
defuss-ssg [dev|build|serve] [folder] [--debug] [--multicore]
|
|
287
277
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
---
|
|
278
|
+
No args -> serve .
|
|
279
|
+
Single path -> serve <path>
|
|
280
|
+
Single command -> <command> .
|
|
281
|
+
Command + folder -> <command> <folder>
|
|
293
282
|
```
|
|
294
283
|
|
|
295
|
-
|
|
296
|
-
- **Math Support**: KaTeX rendering with `$...$` and `$$...$$`
|
|
297
|
-
- **Custom Plugins**: Extend MDX processing with remark/rehype plugins
|
|
284
|
+
Commands:
|
|
298
285
|
|
|
299
|
-
|
|
286
|
+
- `dev`: starts the Vite dev server on port `3000` by default
|
|
287
|
+
- `build`: generates the static site into `dist/`
|
|
288
|
+
- `serve`: serves the built output from `dist/`
|
|
300
289
|
|
|
301
|
-
|
|
290
|
+
Flags:
|
|
302
291
|
|
|
303
|
-
|
|
292
|
+
- `--debug` or `-d`: enable verbose logging
|
|
293
|
+
- `--multicore`: use `workers: "auto"` for `serve`
|
|
304
294
|
|
|
305
|
-
|
|
295
|
+
## Local Package Development
|
|
306
296
|
|
|
307
|
-
|
|
308
|
-
2. **Compile MDX**: Process MDX files to ESM JavaScript
|
|
309
|
-
3. **Compile Components**: Bundle components with esbuild
|
|
310
|
-
4. **Evaluate Pages**: Run page functions to generate VDOM
|
|
311
|
-
5. **Render HTML**: Convert VDOM to HTML using defuss/server
|
|
312
|
-
6. **Run Plugins**: Execute plugins at various phases
|
|
313
|
-
7. **Copy Assets**: Copy static assets to output
|
|
314
|
-
8. **Clean Up**: Remove temporary files (unless debug mode)
|
|
297
|
+
To work on `defuss-ssg` inside this monorepo:
|
|
315
298
|
|
|
316
|
-
|
|
299
|
+
```bash
|
|
300
|
+
git clone https://github.com/kyr0/defuss.git
|
|
301
|
+
cd defuss/packages/ssg
|
|
302
|
+
bun install
|
|
303
|
+
bun run build
|
|
304
|
+
bun run cli-dev
|
|
305
|
+
```
|
|
317
306
|
|
|
318
|
-
|
|
307
|
+
The example project used by the package scripts lives in `../../example-ssg/`.
|
|
319
308
|
|
|
320
|
-
|
|
309
|
+
## Benchmarking
|
|
321
310
|
|
|
322
|
-
|
|
323
|
-
defuss-ssg <command> <folder>
|
|
311
|
+
The benchmark scripts are for local experiments, not committed performance guarantees.
|
|
324
312
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
313
|
+
```bash
|
|
314
|
+
bun run bench
|
|
315
|
+
bun run bench:rpc
|
|
328
316
|
```
|
|
329
317
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
<img src="https://raw.githubusercontent.com/kyr0/defuss/refs/heads/main/assets/defuss_comic.png" width="400px" />
|
|
333
|
-
|
|
334
|
-
</p>
|
|
318
|
+
Benchmark result snapshots are written to `.tmp/bench-results.json` by default. Override that path with `RESULTS_FILE=/path/to/file.json` if needed.
|
|
335
319
|
|
|
336
|
-
|
|
337
|
-
<i><b>Come visit us on <code>defuss</code> Island!</b></i>
|
|
338
|
-
</p>
|
|
320
|
+
For local load-balancing experiments, use `scripts/lb.ts` directly.
|
package/dist/cli.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { v as validateProjectDir, b as build } from './vite-
|
|
3
|
-
import { d as dev, s as serve } from './serve-
|
|
2
|
+
import { v as validateProjectDir, b as build } from './vite-DcjFCDSl.mjs';
|
|
3
|
+
import { d as dev, s as serve } from './serve-CSH82zKY.mjs';
|
|
4
4
|
import { join, dirname, resolve } from 'node:path';
|
|
5
5
|
import { existsSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
|
+
import 'node:url';
|
|
9
|
+
import 'defuss/server';
|
|
10
|
+
import 'node:crypto';
|
|
8
11
|
import '@mdx-js/rollup';
|
|
9
12
|
import 'fast-glob';
|
|
10
13
|
import 'vite';
|
|
11
14
|
import 'defuss-vite';
|
|
12
|
-
import 'defuss/server';
|
|
13
|
-
import 'node:url';
|
|
14
15
|
import 'node:os';
|
|
15
16
|
import 'esbuild';
|
|
16
17
|
import 'rehype-katex';
|
|
@@ -21,8 +22,6 @@ import 'remark-gfm';
|
|
|
21
22
|
import 'remark-parse';
|
|
22
23
|
import 'remark-rehype';
|
|
23
24
|
import 'remark-mdx-frontmatter';
|
|
24
|
-
import './tailwind-DV23JSh-.mjs';
|
|
25
|
-
import 'node:crypto';
|
|
26
25
|
import 'defuss-express';
|
|
27
26
|
|
|
28
27
|
const canResolve = (dep, dir) => {
|
|
@@ -174,7 +173,7 @@ Continuing anyway - dependencies may already be available.`
|
|
|
174
173
|
const debug = args.includes("--debug") || args.includes("-d");
|
|
175
174
|
const multicore = args.includes("--multicore");
|
|
176
175
|
const positional = args.filter((a) => !a.startsWith("-"));
|
|
177
|
-
const usage = "Usage: defuss-ssg [dev|build|serve] [folder]\n No args
|
|
176
|
+
const usage = "Usage: defuss-ssg [dev|build|serve] [folder]\n No args => serve .\n Single path => serve <path>\n Single command => <command> .\n Command + folder => <command> <folder>\n Flags: [--debug] [--multicore]";
|
|
178
177
|
let command;
|
|
179
178
|
let folder;
|
|
180
179
|
if (positional.length === 0) {
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var vite = require('./vite-
|
|
3
|
+
var vite = require('./vite-CQJBNUfy.cjs');
|
|
4
|
+
var mdx = require('@mdx-js/rollup');
|
|
4
5
|
var vite$1 = require('vite');
|
|
5
6
|
var defuss = require('defuss-vite');
|
|
6
7
|
var node_fs = require('node:fs');
|
|
7
8
|
var node_path = require('node:path');
|
|
8
9
|
var defussExpress = require('defuss-express');
|
|
9
10
|
require('node:fs/promises');
|
|
10
|
-
require('@mdx-js/rollup');
|
|
11
|
-
require('fast-glob');
|
|
12
|
-
require('defuss/server');
|
|
13
11
|
require('node:url');
|
|
12
|
+
require('defuss/server');
|
|
13
|
+
require('node:crypto');
|
|
14
|
+
require('fast-glob');
|
|
14
15
|
require('node:os');
|
|
15
16
|
require('esbuild');
|
|
16
17
|
require('rehype-katex');
|
|
@@ -21,8 +22,6 @@ require('remark-gfm');
|
|
|
21
22
|
require('remark-parse');
|
|
22
23
|
require('remark-rehype');
|
|
23
24
|
require('remark-mdx-frontmatter');
|
|
24
|
-
require('./tailwind-C4AuHybm.cjs');
|
|
25
|
-
require('node:crypto');
|
|
26
25
|
|
|
27
26
|
const dev = async ({
|
|
28
27
|
projectDir,
|
|
@@ -33,6 +32,7 @@ const dev = async ({
|
|
|
33
32
|
}) => {
|
|
34
33
|
const projectDirStatus = vite.validateProjectDir(projectDir);
|
|
35
34
|
if (projectDirStatus.code !== "OK") return projectDirStatus;
|
|
35
|
+
const config = await vite.readConfig(projectDir, debug);
|
|
36
36
|
const server = await vite$1.createServer({
|
|
37
37
|
root: projectDir,
|
|
38
38
|
configFile: false,
|
|
@@ -52,6 +52,12 @@ const dev = async ({
|
|
|
52
52
|
},
|
|
53
53
|
plugins: [
|
|
54
54
|
defuss({ enableJsxDevMode: true }),
|
|
55
|
+
mdx({
|
|
56
|
+
jsxImportSource: "defuss",
|
|
57
|
+
development: true,
|
|
58
|
+
remarkPlugins: config.remarkPlugins,
|
|
59
|
+
rehypePlugins: config.rehypePlugins
|
|
60
|
+
}),
|
|
55
61
|
...vite.defussSsg({
|
|
56
62
|
projectDir,
|
|
57
63
|
debug,
|
|
@@ -59,7 +65,7 @@ const dev = async ({
|
|
|
59
65
|
})
|
|
60
66
|
]
|
|
61
67
|
});
|
|
62
|
-
await server.listen();
|
|
68
|
+
await server.listen(port);
|
|
63
69
|
server.printUrls();
|
|
64
70
|
return {
|
|
65
71
|
code: "OK",
|
|
@@ -185,8 +191,6 @@ exports.loadEndpointModule = vite.loadEndpointModule;
|
|
|
185
191
|
exports.matchRoutePattern = vite.matchRoutePattern;
|
|
186
192
|
exports.readConfig = vite.readConfig;
|
|
187
193
|
exports.registerEndpoints = vite.registerEndpoints;
|
|
188
|
-
exports.rehypePlugins = vite.rehypePlugins;
|
|
189
|
-
exports.remarkPlugins = vite.remarkPlugins;
|
|
190
194
|
exports.resolveEndpoints = vite.resolveEndpoints;
|
|
191
195
|
exports.routeToExpressPattern = vite.routeToExpressPattern;
|
|
192
196
|
exports.dev = dev;
|