oven-sh/bun
Fun facts
A grab-bag of trivia gleaned while assembling this wiki. None of this is essential — it's just interesting.
- The first commit message is literally
woot(2021-04-17). Jarred Sumner. src/css/css_parser.zigis the largest single Zig source file in the repo, at ~298 KB. It's also a port of Lightning CSS (originally Rust).src/js_printer.zigis the second-largest, at ~260 KB. The printer is intentionally fat — most code-emission decisions live there rather than in transformations.bun discordis two lines of code that open the Discord invite URL.src/cli/add_completions.zigis ~301 KB — almost entirely a snapshot of popular npm package names forbun addshell completions.- The MIME type table (
src/http/mime_type_list_enum.zig, ~256 KB) is generated frommime_type_list.txt. - The
internal-module-registry-scanner.tsassigns numeric IDs to built-in modules in alphabetical order. Inserting a new file insrc/js/node/shifts every later module's ID, but the scanner regenerates so consumers don't notice. - The
$prefix insrc/js/files is rewritten to__intrinsic__during preprocessing, then to@before the JSC builtin compiler sees it. Three names for the same concept depending on which tool's view you're in. bun.reportURLs are actually pretty long — the encoded payload contains a full demangled stack trace, register state, and source-map indexes. The decoder runs server-side at bun.report and shows a human page.- The repo's "robobun" account has 730 commits in the last year — more than any human. It's the bot that handles version bumps and CI signal.
- Bun has its own line editor for the REPL (
src/repl.zig, ~67 KB). No GNU readline dependency. Yes, it has tab completion. - The
--print/-pflag wraps the input in aconsole.log(...). The-eflag doesn't. They're otherwise the same code path. Bun.spawnSyncruns a child process synchronously without parking the JS event loop. It uses a separateSpawnSyncEventLoop(src/bun.js/event_loop/SpawnSyncEventLoop.zig) that ticks only the I/O backing the child's pipes.- Bun ships its own HTTP/3 client (
lsquic+lsqpack) but not yet an HTTP/3 server (work in progress as of 1.3). - The crash handler turns OOM into a
bun.report-shaped crash with a real backtrace.bun.handleOom(...)is the project-standard way to call allocators. - WebKit/JSC swaps
hostandhostnamesemantics relative to JS —url.host()returns hostname without port,url.hostname()returns hostname with port. Documented insrc/CLAUDE.mdprecisely because it's a footgun. src/bun.js/api/Glob.classes.tsplussrc/bun.js/api/glob.zigis the canonical "small JS class" pair to look at if you want to understand the codegen pipeline. The C++ side is fully generated.- The shell (
Bun.$,src/shell/) is its own POSIX-shell-ish parser-interpreter, not a wrapper around/bin/sh. It runs identically on Windows. - The branch-name gate (
claude/) is real — CI ignores branches without that prefix. bun-types/is a separate npm-published package (bun-types) for users who want Bun's globals available in TS without installing Bun itself.BunDebugger.cppandBunInspector.cppare mostly thin wrappers around JSC's standard inspector protocol — Chrome DevTools attaches tobun --inspectwith no special protocol.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.