Developing locally
The `smite dev` loop: generators, a node:http server, and auto-reload.
package @smitejs/cli
smite dev is the local-development loop for a single app. It replaces the hand-rolled createServer boilerplate of the first examples with one command that regenerates, bundles, serves, and reloads.
What it does
- Loads
smite.config.tsand compiles the app entries in collect mode. - Runs every plugin in the config — typed client, OpenAPI, anything you add.
- Bundles a runtime server over
node:httpand spawns it as a childnodeprocess. - Watches the sources; on change it re-runs the generators, rebundles with esbuild, and restarts the server.
Keeping the CLI free of generators
@smitejs/cli never imports @smitejs/http or the generator packages. The dev server is a generated entry that imports your app and serveNode from the packages you installed; esbuild bundles it at ALLOW_GLOBAL_REGISTRY: "false" and a child process runs it. The watcher skips generated artifacts (*.client.ts, openapi.json) so regeneration never re-triggers a rebuild.
await bundleDevServer({
cwd,
entry,
alias: sourceAliases,
outfile,
});"globalRegistry"Watching
The watcher fingerprints file mtimes and sizes on a poll interval — portable, no native dependencies — and fires once per change batch.
const watcher = new DevWatcher({
watch: async () => [join(dir, "file.txt")],
intervalMs: 20,
onChange: (paths) => changed.push(...paths),
});
await watcher.poll();[]
[join(dir, "file.txt")]Generators
Every plugin declared in the config runs on each cycle, in declaration order.
await runAll(plugins, { apps: [] });["first", "second"]Extending the server
The scaffolded src/server.ts calls serveNode directly, so you can mount extra routers (docs), rewrite requests (transformRequest), or swap the listener — the dev loop and your production server share one adapter.