ESBUILD(1)

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.

Why build another JavaScript build tool? The current build tools for the web are at least an order of magnitude slower than they should be. It is hoped that this project serves as an “existence proof” that JavaScript tooling can be much, much faster.

SIMPLE OPTIONS

--bundle
    Bundle all dependencies into the output files

--define:K=V
    Substitute K with V while parsing

--external:M
    Exclude module M from the bundle (can use * wildcards)

--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: js | jsx | ts | tsx | json | text | base64 | file | dataurl | binary

--minify
    Minify the output (sets all --minify-* flags)

--outdir=...
    The output directory (for multiple entry points)

--outfile=...
    The output file (for one entry point)

--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, default esnext)

--watch
    Watch mode: rebuild on file system changes

ADVANCED OPTIONS

--allow-overwrite
    Allow output files to overwrite input files

--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

--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)

--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

--inject:F
    Import the file F into all input files and automatically replace matching globals with imports

--jsx-factory=...
    What to use for JSX instead of React.createElement

--jsx-fragment=...
    What to use for JSX instead of React.Fragment

--keep-names
    Preserve “name” on functions and classes

--legal-comments=...
    Where to place license comments (none | inline | eof | linked | external, default eof when bundling and inline otherwise)

--log-level=...
    Disable logging (verbose | debug | info | warning | error | silent, default info)

--log-limit=...
    Maximum message count or 0 to disable (default 10)

--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)

--metafile=...
    Write metadata about the build to a JSON file

--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

--resolve-extensions=...
    A comma-separated list of implicit extensions (default “.tsx,.ts,.jsx,.js,.css,.json”)

--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

--tree-shaking=...
    Set to “ignore-annotations” to work with packages

--tsconfig=...
    Use this tsconfig.json file instead of other ones

--version
    Print the current version (0.11.16) 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”

AUTHOR
esbuild is written by Evan Wallace.

This manual page is prepared for Debian by Anthony Fok using information from upstream README.md and output of esbuild --help.

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

SEE ALSO
Documentation: https://esbuild.github.io/

Repository: https://github.com/evanw/esbuild