This document describes Electrobun's build system and cross-platform compilation approach.
Electrobun uses a custom build system (build.ts) that handles:
- Vendoring dependencies (Bun, Zig, CEF, WebView2)
- Building native wrappers for each platform
- Creating distribution packages
- Single
libNativeWrapper.dylibwith weak linking to CEF framework - Uses
-weak_framework 'Chromium Embedded Framework'for optional CEF support - Gracefully falls back to WebKit when CEF is not bundled
- Single
libNativeWrapper.dllwith runtime CEF detection - Links both WebView2 and CEF libraries at build time
- Uses runtime checks to determine which webview engine to use
Dual Binary Approach - Linux builds create two separate native wrapper binaries:
- Size: ~1.46MB
- Dependencies: WebKitGTK, GTK+3, AppIndicator only
- No CEF dependencies linked
- Used when
bundleCEF: falsein electrobun.config
- Size: ~3.47MB
- Dependencies: WebKitGTK, GTK+3, AppIndicator + CEF libraries
- Full CEF functionality available
- Used when
bundleCEF: truein electrobun.config
Unlike macOS and Windows, Linux doesn't have reliable weak linking for shared libraries. Hard linking CEF libraries causes dlopen failures when CEF isn't bundled. The dual binary approach provides:
- Small bundle sizes - Developers can ship lightweight apps without CEF overhead
- Flexibility - Same codebase supports both system WebKitGTK and CEF rendering
- Reliability - No runtime linking failures or undefined symbols
The Electrobun CLI automatically copies the appropriate binary based on the bundleCEF setting:
const useCEF = config.build.linux?.bundleCEF;
const nativeWrapperSource = useCEF
? PATHS.NATIVE_WRAPPER_LINUX_CEF
: PATHS.NATIVE_WRAPPER_LINUX;Both binaries are included in the distributed electrobun npm package, ensuring developers can toggle CEF support without recompilation.
All commands are run from the /package directory:
cd electrobun/package
# Full build with all platforms
bun build.ts
# Development build with the kitchen sink test app
bun dev
# Release build
bun build.ts --release
# CI build
bun build.ts --ci- macOS: ARM64 (Apple Silicon), x64 (Intel)
- Windows: x64 only (ARM Windows users run via automatic emulation)
- Linux: x64, ARM64
Windows builds are created on ARM VMs but target x64 architecture. Both x64 and ARM Windows users use the same x64 binary:
- x64 Windows: Runs natively
- ARM Windows: Runs via automatic Windows emulation layer
This approach simplifies distribution while maintaining compatibility across Windows architectures.
The build system automatically detects the host architecture and downloads appropriate dependencies.