Build Command
burger-api build [file] builds your project for a deployment target. The entry defaults to src/index.ts, src/index.js, or src/index.mjs. Routes are discovered at build time (via burger.build.ts or conventions) and compiled ahead of time (AOT) so production never depends on filesystem scanning.
Options:
--target <platform>:bun(default),node,cloudflare,deno,vercel(orbrowser, a rawBun.buildpassthrough for bundling client-side code)--outfile <path>: Output path; defaults depend on--target(see table below)--compile: Compile to a standalone executable instead of bundling (--target=bunonly, see Build Exec). On Windows, the emitted file is<outfile>.exewhen the outfile does not already end in.exe; the CLI prints that real path.--no-bytecode: Disable bytecode compilation (--compileonly)--minify: Minify output (bun/nodetargets only)--sourcemap <type>:inline,linked, ornone(bun/nodetargets only)--no-bun-check: Skip the Bun-only API warning for portable targets
Default --outfile per target:
| Target | Default output | What builds it |
|---|---|---|
bun | .build/bundle/app.js | Bun.build(), a self-contained entry file |
node | .build/bundle/app.js | Bun.build({ target: 'node' }) |
cloudflare | .build/cloudflare/index.ts | wrangler (not this CLI) |
deno | .build/deno/index.ts | deno (not this CLI) |
vercel | api/index.ts | vercel (not this CLI) |
Examples
# Bun (default), self-contained bundle
burger-api build src/index.ts
# Node.js, uses @burger-api/node-server's serve() instead of app.serve()
burger-api build src/index.ts --target=node
# Cloudflare Workers, generates .build/cloudflare/index.ts + wrangler.toml
# (only if wrangler.toml doesn't already exist), then hand off to wrangler
burger-api build src/index.ts --target=cloudflare
wrangler dev
# Deno, generates .build/deno/index.ts + deno.json
burger-api build src/index.ts --target=deno
deno serve --port 8000 .build/deno/index.ts
# Vercel, generates api/index.ts + vercel.json
burger-api build src/index.ts --target=vercel
vercel dev
# Standalone binary (Bun only)
burger-api build src/index.ts --compile --outfile=my-app
What differs per target
For bun and node, this command runs Bun.build() and produces one
bundled entry file. Projects with pages also emit the page assets next to
it, so deploy the whole directory. For cloudflare, deno, and vercel, there's no long-running
process to bundle for. The generated entry (a plain .ts file exporting
{ fetch: toFetchHandler(app) }) is handed to the platform's own tool to
bundle and deploy, the same way a hand-written project on that platform
already works. burger-api build never re-implements wrangler/deno/
vercel's own bundler.
A project's declared target is baked into the build as
ServerOptions.runtimeTarget, and a WebSocket route on a target that can't
support it (vercel) fails the build immediately with a clear error. See
Compatibility for what each target supports.
Bun-only code on portable targets
Building for cloudflare, deno, vercel, or node prints one warning
listing any user source file that imports bun/bun:*, uses the Bun.
global, or calls Bun's pub/sub (ctx.publish(), ws.publish(),
server.publish()). Those runtimes have no Bun globals, so the code would
fail in the platform's bundler later. The build still succeeds; remove the
Bun-only code before deploying, or pass --no-bun-check to skip the scan.
Text in comments and string literals is ignored, and a file that
feature-checks Bun with typeof Bun is portable for its Bun. uses (but not
for its bun/bun:* imports or publish calls).
Platform config files (wrangler.toml, deno.json, vercel.json) are
scaffolded automatically only when one doesn't already exist; an
existing config is never overwritten.
Production flow on Bun/Node: run burger-api build, then start the server
with burger-api start (Bun) or node <outfile> (Node, via
@burger-api/node-server). On Cloudflare/Deno/Vercel, wrangler deploy/deno deploy/vercel --prod take over from there.
See CLI Tool.