ESBUILD(1)

πŸ“¦
version 0.28.2 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ESBUILD(1) β€” the esbuild Manual πŸ’–

okay bestie, sit down, hydrate, because we are about to talk about the fastest little build tool in the whole group chat. this is the manual page for esbuild, and yes it lives in the esbuild Manual section, and yes it's giving main character energy. periodt.


✨ NAME ✨

esbuild β€” an extremely fast JavaScript bundler and minifier πŸ¦‹


🌸 SYNOPSIS 🌸

esbuild [options] [entry points]

πŸ’… DESCRIPTION πŸ’…

esbuild is a JavaScript bundler and minifier. it packages up JavaScript and TypeScript code for distribution on the web. that's it, that's the job, and it does it so fast it's actually rude.

now β€” why would anyone build another JavaScript build tool, you ask? valid question, queen. the tea is this: the current build tools for the web are at least an order of magnitude slower than they should be. not a little slower. an order of magnitude. 😭

the hope is that this project serves as an β€œexistence proof” that JavaScript tooling can be much, much faster. and bestie, it ate. πŸ”₯


πŸŽ€ SIMPLE OPTIONS πŸŽ€

  • --bundle β€” bundle ALL the dependencies into the output files. everyone gets in the car. πŸš—
  • --define:K=V β€” substitute K with V while parsing
  • --external:M β€” exclude module M from the bundle (you can use * wildcards, go wild) πŸ™ˆ
  • --format=... β€” output format (iife | cjs | esm, no default when not bundling, otherwise default is iife when platform is browser and cjs when platform is node)
  • --loader:X=L β€” use loader L to load file extension X, where L is one of: base64 | binary | copy | css | dataurl | empty | file | global-css | js | json | jsx | local-css | text | ts | tsx
  • --minify β€” minify the output (this sets all the --minify-* flags, so it's a package deal πŸ’…)
  • --outdir=... β€” the output directory (for multiple entry points)
  • --outfile=... β€” the output file (for one entry point)
  • --packages=... β€” set to external to avoid bundling any package
  • --platform=... β€” platform target (browser | node | neutral, default browser)
  • --serve=... β€” start a local HTTP server on this host:port for outputs
  • --sourcemap β€” emit a source map
  • --splitting β€” enable code splitting (currently only for esm)
  • --target=... β€” environment target (e.g. es2017, chrome58, firefox57, safari11, edge16, node10, ie9, opera45, default esnext)
  • --watch β€” watch mode: rebuild on file system changes (it stops when stdin is closed, use β€œ--watch=forever” to ignore stdin)

πŸ‘‘ ADVANCED OPTIONS πŸ‘‘

  • --allow-overwrite β€” allow output files to overwrite input files. chaotic. be careful, bestie. ⚠️
  • --analyze β€” print a report about the contents of the bundle (use β€œ--analyze=verbose” for a detailed report)
  • --asset-names=... β€” path template to use for file loader files (default [name]-[hash])
  • --banner:T=... β€” text to be prepended to each output file of type T where T is one of: css | js
  • --certfile=... β€” certificate for serving HTTPS (see also β€œ--keyfile”)
  • --charset=utf8 β€” do not escape UTF-8 code points
  • --chunk-names=... β€” path template to use for code splitting chunks (default [name]-[hash])
  • --color=... β€” force use of color terminal escapes (true | false)
  • --drop:... β€” remove certain constructs (console | debugger)
  • --drop-labels=... β€” remove labeled statements with these label names
  • --entry-names=... β€” path template to use for entry point output paths (default [dir]/[name], can also use [hash])
  • --footer:T=... β€” text to be appended to each output file of type T where T is one of: css | js
  • --global-name=... β€” the name of the global for the IIFE format
  • --ignore-annotations β€” enable this to work with packages that have incorrect tree-shaking annotations
  • --inject:F β€” import the file F into all input files and automatically replace matching globals with imports
  • --jsx-dev β€” use React's automatic runtime in development mode
  • --jsx-factory=... β€” what to use for JSX instead of React.createElement
  • --jsx-fragment=... β€” what to use for JSX instead of React.Fragment
  • --jsx-import-source=... β€” override the package name for the automatic runtime (default β€œreact”)
  • --jsx-side-effects β€” do not remove unused JSX expressions
  • --jsx=... β€” set to β€œautomatic” to use React's automatic runtime or to β€œpreserve” to disable transforming JSX to JS
  • --keep-names β€” preserve β€œname” on functions and classes
  • --keyfile=... β€” key for serving HTTPS (see also β€œ--certfile”)
  • --legal-comments=... β€” where to place legal comments (none | inline | eof | linked | external, default eof when bundling and inline otherwise)
  • --line-limit=... β€” lines longer than this will be wrap onto a new line
  • --log-level=... β€” disable logging (verbose | debug | info | warning | error | silent, default info)
  • --log-limit=... β€” maximum message count or 0 to disable (default 6)
  • --log-override:X=Y β€” use log level Y for log messages with identifier X
  • --main-fields=... β€” override the main file order in package.json (default β€œbrowser,module,main” when platform is browser and β€œmain,module” when platform is node)
  • --mangle-cache=... β€” save β€œmangle props” decisions to a JSON file
  • --mangle-props=... β€” rename all properties matching a regular expression
  • --mangle-quoted=... β€” enable renaming of quoted properties (true | false)
  • --metafile=... β€” write metadata about the build to a JSON file (see also: https://esbuild.github.io/analyze/)
  • --minify-whitespace β€” remove whitespace in output files
  • --minify-identifiers β€” shorten identifiers in output files
  • --minify-syntax β€” use equivalent but shorter syntax in output files
  • --out-extension:.js=.mjs β€” use a custom output extension instead of β€œ.js”
  • --outbase=... β€” the base path used to determine entry point output paths (for multiple entry points)
  • --preserve-symlinks β€” disable symlink resolution for module lookup
  • --public-path=... β€” set the base URL for the file loader
  • --pure:N β€” mark the name N as a pure function for tree shaking
  • --reserve-props=... β€” do not mangle these properties
  • --resolve-extensions=... β€” a comma-separated list of implicit extensions (default β€œ.tsx,.ts,.jsx,.js,.css,.json”)
  • --serve-fallback... β€” serve this HTML page when the request doesn't match
  • --servedir=... β€” what to serve in addition to generated output files
  • --source-root=... β€” sets the β€œsourceRoot” field in generated source maps
  • --sourcefile=... β€” set the source file for the source map (for stdin)
  • --sourcemap=external β€” do not link to the source map with a comment
  • --sourcemap=inline β€” emit the source map with an inline data URL
  • --sources-content=false β€” omit β€œsourcesContent” in generated source maps
  • --supported:F=... β€” consider syntax F to be supported (true | false)
  • --tree-shaking=... β€” force tree shaking on or off (false | true)
  • --tsconfig=... β€” use this tsconfig.json file instead of other ones
  • --tsconfig-raw=... β€” override all tsconfig.json files with this string
  • --version β€” print the current version (0.25.0) and exit

🌈 EXAMPLES 🌈

esbuild --bundle entry_point.js --outdir=dist --minify --sourcemap
    # Produces dist/entry_point.js and dist/entry_point.js.map

esbuild --bundle entry_point.js --outfile=out.js --loader:.js=jsx
    # Allow JSX syntax in .js files

esbuild example.js --outfile=out.js --define:RELEASE=true
    # Substitute the identifier RELEASE for the literal true

esbuild --minify --loader=ts < input.ts > output.js
    # Provide input via stdin, get output via stdout

esbuild app.ts --bundle --watch
    # Automatically rebuild when input files are changed

esbuild app.ts --bundle --servedir=www --outdir=www/js
    # Start a local HTTP server for everything in β€œwww”

look at those. so clean. so crisp. 🧚


🫢 AUTHOR 🫢

esbuild is written by Evan Wallace. absolute icon. πŸ‘‘

this manual page is prepared for Debian by Anthony Fok using information from upstream README.md and output of esbuild --help. thank you for your service. 🫑


Copyright Β© 2020 Evan Wallace License: MIT (Expat)


πŸ¦‹ SEE ALSO πŸ¦‹


okay that's the whole thing, no cap, every single flag accounted for. πŸ’œ

this was esbuild 0.25.0, dated 2025-02-13, straight out of the esbuild Manual. go build something iconic bestie, and remember β€” bundle responsibly. πŸ’…βœ¨

πŸ“¦ where this page comes from