Compile
Compile your entire app into a single standalone executable: no runtime, no node_modules, no external files needed.
#Compiling Your App
The absolute compile command builds your assets, pre-renders all pages, and compiles everything into a single binary using Bun's bun build --compile:
# Compile everything into a single standalone binary
absolute compile
# With options
absolute compile src/backend/server.ts --outdir dist --outfile my-app$ absolute compileBuilding assets (3.31s) Bundling production server (614ms) Pre-rendering pages (5 pages, 981ms) Compiling standalone executable (110ms) Compiled to ./compiled-server (97MB) in 5.02s Run with: ./compiled-server
#Running the Binary
The compiled binary is fully self-contained. Copy it to any machine and run it: no Bun, no Node.js, no source files, and no node_modules needed:
# Run the compiled binary : no dependencies needed
./compiled-server
# Or set a custom port
PORT=8080 ./compiled-server#What's Embedded
The compiled binary includes everything your app needs to run:
Pre-rendered Pages
All pages are pre-rendered at compile time and embedded as static HTML that hydrates on the client.
Client Bundles
JavaScript bundles for React, Svelte, Vue, Angular, and HTML: all framework client code.
Web Workers
Worker scripts are embedded and served from Bun’s virtual filesystem. Workers load and execute normally.
Static Assets
CSS, images, SVGs, fonts, favicons: every asset is embedded with correct MIME types and cache headers.
#Runtime Contract
absolute compile uses the same production build pipeline as absolute start. It builds the app, bundles the production server, pre-renders the discovered/static pages, and embeds a runtime fallback for routes that still need server handling.
- Pre-rendered pages are served immediately from the executable and then hydrate on the client.
- Runtime fallback handles API routes, dynamic pages, redirects, headers, cookies, request bodies, errors, and not-found boundaries.
- Environment vars come from the process running the executable. Code that reads env at module load runs when the executable starts; code that reads env inside a handler runs per request.
- Concurrent builds or compiles targeting the same output directory are serialized so they cannot corrupt each other's output.
#Runtime Files
Compile can embed server-side files when the path is static enough to discover at compile time. These patterns are supported:
// Embedded automatically
const templateUrl = new URL('./runtime/template.html', import.meta.url);
const html = await Bun.file(templateUrl).text();
// Also embedded when each segment is static
const textPath = join(import.meta.dir, 'runtime', 'message.txt');
const text = await Bun.file(textPath).text();
const jsonPath = resolve(import.meta.dir, 'runtime', 'data.json');
const json = await Bun.file(jsonPath).json();Fully dynamic file paths cannot be discovered safely. Keep user uploads, generated files, SQLite databases, and other mutable runtime data outside the executable and read them from a configured runtime path.
// Not auto-discoverable at compile time
const name = request.query.name;
const file = await Bun.file(join(import.meta.dir, 'uploads', name)).text();
// Put user uploads, generated files, or databases outside the compiled binary
// and read them from a configured runtime path instead.#Caveats
- The final executable is intended to run without your source tree or
node_modules, but it still needs whatever external services your app uses, such as databases, queues, object storage, or third-party APIs. - Compile embeds static assets and supported runtime file references. It does not snapshot arbitrary runtime directories or user-generated data.
- The last build or compile that targets an output directory owns that directory. Workspace projects should use separate
buildDirectoryvalues unless they intentionally want last-write-wins output.
#CLI Options
src/backend/server.ts)dist)compiled-server)absolute.config.ts#Package Scripts
Add these scripts to your package.json for easy access:
{
"scripts": {
"dev": "absolute dev",
"start": "absolute start",
"compile": "absolute compile",
"serve": "./compiled-server"
}
}