CLI
mion compile runs the same compiler as the Vite plugin, the way tsc does: it rewrites your mion calls, emits .js files to your tsconfig outDir, writes the generated modules and the batch transport under the gen dir, and reports type errors. Use it when a project has no bundler, or when you want plain emitted files.
A type error makes it exit with code 1. With noEmitOnError in your tsconfig, it writes no file.
To publish your API's types with mion api-types, see API Types.
Compiling a Project
Run it from the project that holds your client and server code. It finds every batch([...]) and inline inputFrom mapper in the program, and imports the batch table from the emitted file that calls createMionRouter. Client and server get the same batch ids and mapper hashes.
mion compile --tsconfig tsconfig.json
Compiling a Fetching Client
By default a client ships the compiled functions of the routes it calls. Pass --client-routes fetch to fetch them from the server at runtime instead, like client.routes on the Vite plugin:
mion compile --tsconfig tsconfig.json --client-routes fetch
clientRoutes ('bundle' or 'fetch').Checking a Client Against Its Server
mion api-check compares a client build with a server build, for example a mobile client already in users' hands with the server you are about to deploy. It reads two manifests under <genDir>/api/: manifest.json lists the server's routes and the ids of their compiled types, client-manifest.json what the client bundled.
mion api-check --server-gen-dir .mion --client-gen-dir ../released-client/.mion
It exits 0 when every bundled route matches the server, 1 with one line per difference (the route, the field, both values), and 2 when a manifest is missing or invalid, or a flag is wrong.
API Check in CI
mion api-check needs no network, only the two build outputs, so it fits any CI job that has both:
- run: mion compile --tsconfig tsconfig.json --gen-dir .mion
- run: mion api-check --server-gen-dir .mion --client-gen-dir released-client/.mion
Output Locations
The gen dir defaults to .mion in the directory you run from. Set genDir in the tsconfig entry or pass --gen-dir to change it. Every import between these files is relative, so the emitted tree runs wherever you deploy it.
| Output | Location |
|---|---|
Emitted .js (and source maps when the tsconfig asks for them), or .ts with --emit-mode ts | The tsconfig outDir |
| Generated validation and JSON round trip functions | <genDir>/types/ |
| Batch table and mapper modules | <genDir>/rpc/ |
| Bundled route modules and the two manifests | <genDir>/api/ |
mion compile --no-emit checks a project and reports type errors and build diagnostics without writing anything, like tsc --noEmit.Shared Options
Every project option from the RunTypes configuration works as a kebab-case flag (--emit-mode, --gen-dir, --hash-length). A flag wins over the tsconfig entry, which wins over the default. Run mion compile -h for the full list.