In dev mode, kosmo serve can run a sidecar alongside your app, so a worker is up while you work on the routes that feed it. Whether it does is the serve key.
Without serve, a sidecar is built and left alone - it is a build artifact like any other, and starting it is yours. With serve: true, kosmo serve imports the entry into its own Vite environment and calls start().
On a change to anything the entry imports it calls teardown(), then the close function start() returned, re-imports the module and calls start() again.
It is one process, so there is no signal to catch and nothing to wait for on exit - but that also means the close function is the only thing that frees a port.
Return one that actually closes the server, or the next reload hits EADDRINUSE and keeps hitting it until you restart the dev server.
A reload that throws is reported and the dev server stays up; the next good save retries.
Development only
kosmo preview and dist/run.js build sidecars but never start them. Details ›
Typechecking
Nothing to configure. A sidecar lives inside a source folder, and a folder's tsconfig.json already covers everything under it, so pnpm typecheck mailer checks it like any other file in the folder.
A sidecar that wraps third-party JavaScript, or one you simply do not want checked, opts out with the folder-level typecheck key:
defineConfig({
// ...
sidecar: { entry: "./entry.mjs" },
typecheck: false,
});