nowaki 0.15.0 → 0.16.1

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.
Files changed (3) hide show
  1. package/README.md +37 -0
  2. package/bin/nowaki.js +17 -3
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -31,6 +31,43 @@ nowaki prerender [dir] # Static site generation (SSG)
31
31
 
32
32
  Scaffold a new app with `npm create nowaki@latest my-app`.
33
33
 
34
+ ### First-load JS per route
35
+
36
+ `nowaki build` (and `nowaki prerender`) prints the gzip size of the JS each page route loads
37
+ first: the islands runtime and the islands the page can render, through its layouts and
38
+ components, plus the live runtime for live islands. The lazy SPA router chunk is not counted.
39
+ The same data goes to `dist/route-js.json`.
40
+
41
+ A route can set a budget in KB. The build **fails** when the route goes over it:
42
+
43
+ ```tsx
44
+ export const budget = { js: 12 }; // at most 12 KB of gzip JS on first load
45
+ export const budget = { js: 0 }; // a content page: no client JS at all
46
+ ```
47
+
48
+ The value must be a number literal. An unreadable `budget` fails the build instead of being
49
+ ignored.
50
+
51
+ ### MCP for coding agents
52
+
53
+ While `nowaki dev` runs, it serves a read-only [MCP](https://modelcontextprotocol.io)
54
+ endpoint at `http://127.0.0.1:<port>/__nowaki/mcp`; the startup banner prints it.
55
+ Add it to Claude Code with:
56
+
57
+ ```bash
58
+ claude mcp add --transport http nowaki http://127.0.0.1:3000/__nowaki/mcp
59
+ ```
60
+
61
+ Tools:
62
+
63
+ - `routes`: the route table in match order (pattern, file, page/API, exports such as `revalidate` and `csrf`), plus layouts, middleware, and boundaries
64
+ - `module_graph`: what a file imports and which files import it, and the islands with their `live` flag
65
+ - `recent_errors`: the last 50 build, SSR, live, and HMR errors, with time, file, and stack
66
+ - `dev_config`: port, `--host`, plugins, `NOWAKI_*` flags, and Jetstream connections and rooms
67
+
68
+ The endpoint answers only requests from this machine (loopback peer, `Host`, and
69
+ `Origin`), even with `--host`. `nowaki start` and the deploy adapters don't serve it.
70
+
34
71
  ## How it works
35
72
 
36
73
  The native binary is distributed as platform-specific optional dependencies
package/bin/nowaki.js CHANGED
@@ -1,8 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- // Forwards args and stdio unchanged to the prebuilt Rust nowaki binary.
5
- // No postinstall: the platform package is resolved and exec'd at runtime.
4
+ // Runs the prebuilt Rust nowaki binary with the same args, env, and stdio.
5
+ // No postinstall: the platform package is resolved at runtime.
6
+ //
7
+ // On Unix the Node process is replaced by the binary (process.execve, Node >= 22.15 / 23.11),
8
+ // so no Node process stays resident next to `nowaki start` (about 45 MB, #91) and signals reach
9
+ // the binary directly. Elsewhere (Windows, older Node) it falls back to a child process.
6
10
 
7
11
  const { spawnSync } = require("node:child_process");
8
12
  const { resolveBinary } = require("../lib/resolve.js");
@@ -15,7 +19,17 @@ try {
15
19
  process.exit(1);
16
20
  }
17
21
 
18
- const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
22
+ const args = process.argv.slice(2);
23
+
24
+ if (typeof process.execve === "function" && process.platform !== "win32") {
25
+ try {
26
+ process.execve(binary, [binary, ...args], process.env); // does not return on success
27
+ } catch {
28
+ // e.g. a noexec mount: fall through to spawnSync, which reports its own error
29
+ }
30
+ }
31
+
32
+ const result = spawnSync(binary, args, { stdio: "inherit" });
19
33
 
20
34
  if (result.error) {
21
35
  console.error(`[nowaki] failed to launch the binary: ${result.error.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nowaki",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "description": "The Nowaki CLI — Rust-powered bundler, dev server, and SSG for the Nowaki web framework",
5
5
  "license": "MIT",
6
6
  "author": "Tettu0530",
@@ -28,11 +28,11 @@
28
28
  "lib/"
29
29
  ],
30
30
  "optionalDependencies": {
31
- "@nowaki-dev/cli-darwin-arm64": "0.15.0",
32
- "@nowaki-dev/cli-darwin-x64": "0.15.0",
33
- "@nowaki-dev/cli-linux-x64-gnu": "0.15.0",
34
- "@nowaki-dev/cli-linux-arm64-gnu": "0.15.0",
35
- "@nowaki-dev/cli-win32-x64": "0.15.0"
31
+ "@nowaki-dev/cli-darwin-arm64": "0.16.1",
32
+ "@nowaki-dev/cli-darwin-x64": "0.16.1",
33
+ "@nowaki-dev/cli-linux-x64-gnu": "0.16.1",
34
+ "@nowaki-dev/cli-linux-arm64-gnu": "0.16.1",
35
+ "@nowaki-dev/cli-win32-x64": "0.16.1"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=22"