deno compile to create self-contained executables for JavaScript and TypeScript applications across multiple platforms.
Available Bundlers
Deno bundlers support 5 target platforms:| Bundler Name | Target Platform | Use Case |
|---|---|---|
deno-x86_64-linux | x86_64 Linux | Servers, cloud deployments |
deno-aarch64-linux | ARM64 Linux | Raspberry Pi, ARM servers |
deno-x86_64-darwin | Intel macOS | Intel Mac distribution |
deno-aarch64-darwin | Apple Silicon macOS | M1/M2/M3 Mac distribution |
deno-x86_64-windows | x86_64 Windows | Windows desktop/server |
Deno bundlers automatically append
.exe extension to Windows binaries.How It Works
The Deno bundler:- Fetches denort - Downloads the Deno runtime for the target platform
- Finds entrypoint - Reads
package.jsonfor themainfield (defaults tobuild/index.js) - Compiles - Uses
deno compilewith--targetto create a standalone executable - Packages - Places the binary in
$out/bin/with proper naming
Implementation Details
Frombundlers/deno/default.nix:50-76:
Basic Usage
Cross-Compile for Linux
/nix/store/...-my-deno-app-x86_64-linux/bin/my-deno-app
Cross-Compile for macOS Apple Silicon
/nix/store/...-my-deno-app-aarch64-darwin/bin/my-deno-app
Cross-Compile for Windows
/nix/store/...-my-deno-app-x86_64-windows/bin/my-deno-app.exe
Multi-Platform Build
Create binaries for all platforms in one script:Configuration
Entrypoint Detection
The bundler automatically detects your application’s entrypoint:- Reads
package.jsonfor themainfield - Falls back to
build/index.jsif not specified
Deno Compile Flags
The bundler uses thesedeno compile flags:
--no-check- Skip type checking (assumes already checked during build)--allow-env- Allow environment variable access--allow-net- Allow network access--target- Specify target platform
Advanced Usage
Custom Bundler Configuration
Override the default bundler to add custom permissions:Supported Deno Targets
Frombundlers/deno/all.nix:4-25, the bundler maps Nix systems to Deno targets:
Troubleshooting
Binary Size
Deno binaries are typically 60-100 MB because they include the V8 runtime.Missing Entrypoint
If the bundler can’t find your entrypoint:main field to package.json or ensure build/index.js exists.
Permission Errors
If your app fails at runtime with permission errors:--allow-read).
Performance
Build Time
Deno compilation is fast:- Small apps (< 100 KB): ~2-5 seconds
- Medium apps (< 1 MB): ~5-10 seconds
- Large apps (> 1 MB): ~10-20 seconds
Runtime Performance
Compiled Deno binaries have:- Startup: ~10-50ms overhead
- Execution: Near-native V8 performance
- Memory: Base ~20-30 MB (V8 runtime)
Related Topics
Go Bundlers
Smaller binaries with Go cross-compilation
Docker Bundlers
Containerize Deno applications
