New Native REPL
Bun's REPL has been completely rewritten in Zig, replacing the previous third-party npm package implementation. The new REPL starts instantly without downloading any dependencies and includes a full-featured terminal UI with practical developer conveniences.
Key features include:
- Copy to clipboard — The
.copycommand copies expressions directly to your clipboard - Top-level await — Use async/await natively in the REPL
- Module loading — Both ESM imports and CommonJS require work seamlessly
- Syntax highlighting — JavaScript code is colorized as you type
- Line editing — Emacs keybindings (
Ctrl+A/E,Ctrl+K/U,Ctrl+W,Ctrl+L) for efficient navigation - Persistent history — Command history saved to
~/.bun_repl_historywith Up/Down arrow navigation - Tab completion — Auto-complete for object properties and REPL commands
- Multi-line input — Automatic detection of incomplete expressions with proper continuation
Special variables _ (last result) and _error (last error) are available, and REPL semantics properly handle const/let hoisting, dynamic imports, and object literal detection.
ES Decorators and Browser Compilation
Bun now fully supports TC39 stage-3 standard ES decorators — the modern decorator specification used when experimentalDecorators is disabled in tsconfig.json. This addresses a long-standing feature request dating to 2023. The transpiler now correctly handles decorator metadata via Symbol.metadata, the accessor keyword, and context APIs like ClassMethodDecoratorContext and ClassFieldDecoratorContext.
The --compile --target=browser flag produces self-contained HTML files with all JavaScript, CSS, and assets inlined directly into the output:
- Supports TypeScript, JSX, React, CSS, ESM, and CJS
- Useful for distributing
.htmlfiles that work viafile://URLs without web servers or CORS concerns - Converts
<script src="...">to inline<script>,<link rel="stylesheet">to<style>, and asset references todata:URIs
Usage:
bun build --compile --target=browser ./index.html
All entrypoints must be .html files and cannot use --splitting.