# esbuild — Extremely Fast JavaScript Bundler > esbuild is an extremely fast JavaScript/TypeScript bundler written in Go. 10-100x faster than webpack/Rollup. Powers Vite, Bun, and many modern build tools as their underlying transform engine. ## Install Save in your project root: ## Quick Use ```bash npm i -D esbuild ``` CLI: ```bash npx esbuild src/app.ts --bundle --outfile=dist/app.js \ --platform=browser --target=es2020 --minify ``` JS API: ```js import { build } from "esbuild"; await build({ entryPoints: ["src/app.ts"], bundle: true, outfile: "dist/app.js", platform: "browser", target: "es2020", minify: true, sourcemap: true, }); ``` ## Intro esbuild is an extremely fast JavaScript/TypeScript bundler written in Go by Evan Wallace (Figma co-founder). Benchmark: bundles the three.js codebase (10K modules) in ~0.3s — compared to ~35s for webpack. Powers Vite, Bun, Snowpack, and many tools as their transform engine. - **Repo**: https://github.com/evanw/esbuild - **Stars**: 39K+ - **Language**: Go - **License**: MIT ## What esbuild Does - **Bundling** — merge modules into one file - **TypeScript** — strip types (no type check) - **JSX** — transform JSX to JS - **Minification** — tree-shake + compress - **Tree shaking** — remove unused exports - **Source maps** — for debugging - **Plugin API** — custom loaders and resolvers - **Splitting** — code splitting for dynamic imports - **Watch mode** — incremental rebuilds ## Architecture Written in Go for parallelism (Go is 10x faster than JS for this kind of work + perfect concurrency). Parses, transforms, and prints all in one pass without intermediate AST serialization. No babel, no multiple plugins stacking up overhead. ## Self-Hosting Bundled as a binary via npm. Ships in your build pipeline. ## Key Features - 10-100x faster than webpack/Rollup - TypeScript + JSX out of the box - Tree shaking - Minification - Source maps - CSS bundling (basic) - Plugin API - Incremental watch mode - WASM build available ## Comparison | Tool | Speed | Features | Plugins | |---|---|---|---| | esbuild | Fastest | Minimal | Limited | | Rollup | Medium | Mature | Huge ecosystem | | webpack | Slow | Most features | Huge ecosystem | | Rolldown | Very fast | WIP | Rollup-compatible | | Rspack | Very fast | webpack-compatible | webpack ecosystem | ## 常见问题 FAQ **Q: 为什么这么快?** A: Go 写的(原生并行)+ 零中间 AST + 单遍解析+转换+打印 + 精简 plugin API。Evan 写过详细的 architecture doc。 **Q: 生产环境能用吗?** A: 能。Figma、Vite、Bun 都在生产用。但不做类型检查,需配合 `tsc --noEmit` 单独跑。 **Q: 和 Vite 的关系?** A: Vite 开发模式用 esbuild 做依赖预打包;生产构建用 Rollup(因 plugin 生态更成熟)。 ## 来源与致谢 Sources - Docs: https://esbuild.github.io - GitHub: https://github.com/evanw/esbuild - License: MIT --- Source: https://tokrepo.com/en/workflows/ee954487-3577-11f1-9bc6-00163e2b0d79 Author: AI Open Source