esbuild
Bundle JavaScript and TypeScript code quickly
TLDR
Bundle a JavaScript application and print to stdout
Bundle a JSX application from stdin
Bundle and minify a JSX application with source maps in production mode
Bundle a JSX application for a comma-separated list of browsers
Bundle a JavaScript application for a specific node version
Bundle a JavaScript application enabling JSX syntax in .js files
Bundle and serve a JavaScript application on an HTTP server
Bundle a list of files to an output directory
SYNOPSIS
esbuild [options] [--] [entry-points...]
PARAMETERS
--bundle
Bundle input files together into a single output file (default: false)
--splitting
Enable code splitting (requires --format=esm --platform=browser) (default: false)
--format=<format>
Set output format: esm, cjs, iife, or umd (default: detect from outfile)
--platform=<platform>
Target platform: browser, node, or neutral (default: browser)
--target=<target>
Environment target such as es2020, chrome58, or node16 (default: browserslist)
--outfile=<file>
Write single output file to disk
--outdir=<dir>
Write multiple output files to directory
--out-extension:.<ext>=<ext>
Force output extension, e.g. --out-extension:.js=.mjs
--entry-names=<tmpl>
Template for entry point filenames, e.g. [dir]/[name]-[hash].js
--chunk-names=<tmpl>
Template for code splitting chunk filenames
--asset-names=<tmpl>
Template for non-JS asset filenames
--loader:<ext>=<loader>
Loader for files: js, jsx, ts, tsx, css, file, copy, text, json, base64 (repeatable)
--external:<name>
Exclude symbol from bundling (repeatable)
--global-name=<name>
Global name for UMD/IIFE (repeatable)
--sourcemap
Emit source map (inline, external, both) (default: false)
--minify
Minify JS (syntax, whitespace, identifiers)
--metafile=<file>
Emit build metadata JSON
--jsx=<hint>
transform or preserve JSX (default: transform)
--jsx-factory=<ident>
JSX factory function (default: React.createElement)
--define:<name>=<value>
Replace expression with constant (repeatable)
--inject=<file>
Inject globals from JS file (repeatable)
--banner:<type>=<text>
Prepend banner to output (js, css) (repeatable)
--watch
Watch files and rebuild on change
--serve=<host:port>
Start dev server (default: localhost:8000)
--servedir=<dir>
Serve static files from dir (default: .) (repeatable)
--log-level=<level>
verbose, debug, info, warning, error, silent
--color=<bool>
Force color in terminal output
--write
Enable/disable writing to disk (default: true)
DESCRIPTION
esbuild is an extremely fast bundler and minifier for JavaScript, TypeScript, and related assets. Written in Go, it achieves 10-100x speedups over JavaScript-based tools like webpack, Rollup, Terser, or Babel by using parallelism, low-level optimizations, and skipping unnecessary AST parsing.
Key features include bundling multiple modules, code splitting, tree shaking, minification, source map generation, transpilation (ES5-ES2022+), JSX transformation, CSS/JSON asset handling, and a built-in dev server. It supports ESM, CJS, IIFE, and UMD formats for browser, Node.js, or neutral platforms.
Usage spans web apps, Node.js servers, libraries, and CI builds. Install globally via npm: npm install -g esbuild, or use locally with npx. No runtime deps; single binary ~10MB. Ideal for large codebases where build time matters.
Limitations: fewer plugins than webpack; focused on core speed.
CAVEATS
Not a standard Linux utility; requires separate installation. Lacks extensive plugin ecosystem compared to webpack. Binary size ~10MB but no Node.js runtime needed.
INSTALLATION
npm install esbuild --save-dev
Or download standalone binary from GitHub releases for Linux x64/arm64.
BASIC EXAMPLES
esbuild app.js --bundle --outfile=out.js
esbuild src/*.ts --bundle --outdir=dist --format=esm --platform=node --watch
esbuild --serve=localhost:8080 --servedir=public
HISTORY
Created by Evan Wallace (Segment.io/Grammarly) and open-sourced in September 2020 under MIT. Rapid adoption due to speed benchmarks; v0.8+ added TypeScript/JSX. Actively maintained with frequent releases.


