LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

esbuild

Extremely fast JavaScript and TypeScript bundler

TLDR

Bundle JavaScript file
$ esbuild [app.js] --bundle --outfile=[out.js]
copy
Bundle with minification
$ esbuild [app.js] --bundle --minify --outfile=[out.js]
copy
Bundle TypeScript
$ esbuild [app.ts] --bundle --outfile=[out.js]
copy
Watch mode
$ esbuild [app.js] --bundle --watch --outfile=[out.js]
copy
Start dev server
$ esbuild [app.js] --bundle --serve=[8000]
copy
Bundle for browser
$ esbuild [app.js] --bundle --platform=browser --outfile=[out.js]
copy
Generate source maps
$ esbuild [app.js] --bundle --sourcemap --outfile=[out.js]
copy

SYNOPSIS

esbuild [options] [entrypoints_...]

DESCRIPTION

esbuild is an extremely fast JavaScript and TypeScript bundler and minifier. Written in Go, it's 10-100x faster than traditional bundlers like webpack or Parcel.The tool handles bundling, minification, code splitting, tree shaking, and transpilation. It supports JSX, TypeScript, and modern JavaScript features without configuration.esbuild's speed makes it ideal for development builds and as a lower-level tool in build pipelines.

PARAMETERS

ENTRYPOINTS_

Input files to process.
--bundle
Bundle dependencies.
--outfile FILE
Output file path.
--minify
Minify output.
--watch
Rebuild on changes.
--serve [PORT]
Start development server.
--platform PLATFORM
Target: browser, node, neutral.
--sourcemap
Generate source maps.
--target VERSION
JavaScript target version, e.g. es2020 or chrome100.
--outdir DIR
Output directory (use instead of --outfile when there are multiple outputs).
--format FORMAT
Output module format: iife, cjs or esm.
--loader:.ext=loader
How to load a given file extension (js, ts, jsx, json, text, base64, dataurl, file, ...).
--define:K=V
Substitute a global identifier with a constant expression at build time.
--external:pkg
Exclude a package from the bundle and leave the import in place.
--splitting
Enable code splitting (esm format only).
--metafile FILE
Write a JSON file describing the build, for bundle analysis.
--help
Display help information.

INSTALL

sudo apt install esbuild
copy
sudo pacman -S esbuild
copy
sudo apk add esbuild
copy
sudo zypper install esbuild
copy
brew install esbuild
copy
nix profile install nixpkgs#esbuild
copy

CAVEATS

Plugin ecosystem smaller than webpack. Some transformations not supported. Configuration differs from other bundlers. May need plugins for complex setups.

HISTORY

esbuild was created by Evan Wallace (co-founder of Figma) and released in 2020. Its dramatic speed improvement over existing tools came from being written in Go with parallelization.

SEE ALSO

webpack(1), rollup(1), vite(1), swc(1)

RESOURCES

Copied to clipboard
Kai