왜 빠른가: V8 대신 JavaScriptCore (JIT 최적화 다름) + Zig로 시스템 레이어 최적화
v1.3.10: 문자열 슬라이싱 168배 성능 향상 (JSC 업그레이드)
주요 기능
패키지 매니저
bun init # 프로젝트 초기화bun install # 의존성 설치 (npm 대비 10~30배 빠름)bun add express # 패키지 추가bun remove lodash # 패키지 제거bun update # 업데이트
npm/yarn/pnpm 호환 (package.json, node_modules)
글로벌 캐시 + 하드링크 → 디스크 절약
bun.lockb 바이너리 락파일 (빠른 파싱)
런타임
// TypeScript 그대로 실행 — 설정 불필요const server = Bun.serve({ port: 3000, fetch(req) { return new Response("Hello Bun!"); },});console.log(`Listening on ${server.port}`);
Web Standard API: fetch, Request, Response, WebSocket 네이티브
Node.js 호환: fs, path, http, crypto 등 대부분 호환
Bun.serve(): 내장 HTTP 서버 (Express/Fastify 없이도 가능)
Bun.file(): 빠른 파일 I/O
Bun.sql(): 내장 PostgreSQL/MySQL 클라이언트 (v1.2+)
SQLite: bun:sqlite 네이티브 내장
FFI: bun:ffi로 C/Rust 라이브러리 직접 호출
번들러
bun build ./src/index.ts --outdir ./distbun build ./src/index.ts --compile # 단일 실행 파일bun build ./src/index.ts --compile --target=browser # 단일 HTML (v1.3.10)
esbuild급 속도
--compile: JS/TS를 단일 바이너리로 컴파일 (배포 간편)
--target=browser: JS+CSS+자산 → 단일 HTML 파일 (v1.3.10 신규)