CodeVetter · Repo Unpack · System map
evanw/esbuild
The module is github.com/evanw/esbuild. The process entry is cmd/esbuild, which either runs the CLI or a stdin/stdout service. Bundling lives under internal/ and is wrapped by pkg/api. There is no database: inputs are files or stdin, outputs are files, stdout, or in-memory bytes. The JS API in lib/ is compiled into the published npm packages and is not a separate server. Official builds pin Go 1.26.5, keep the language at Go 1.13, and disable cgo.
- go.mod declares module github.com/evanw/esbuild, sets go 1.13 on purpose so old OS toolchains can still build it, and requires only golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8, which the comment says must not be upgraded.
- The native entrypoint is main() in cmd/esbuild/main.go. It handles --help, --version (printed from esbuildVersion), hidden --trace/--heap/--cpuprofile/--timing, and --service=<hostVersion>, which must equal the binary version or the process exits 1.
- version.txt and cmd/esbuild/version.go both say 0.28.2, matching npm/esbuild/package.json and npm/esbuild-wasm/package.json.
- pkg/api exposes Build, Transform, and Context (Rebuild, Watch, Serve, Cancel, Dispose). pkg/cli.Run and RunWithPlugins invoke the same CLI parser without spawning a child process; ParseBuildOptions, ParseTransformOptions, and ParseServeOptions reuse that parser.
- The bundler pipeline is implemented in internal/bundler.ScanBundle and (*Bundle).Compile. Compile calls a Linker, which production code passes as linker.Link. Docs place both phases in internal/bundler/bundler.go.
- Parsing, printing, resolution, and helpers are split across internal/js_parser, internal/js_printer, internal/css_parser, internal/css_printer, internal/resolver, internal/runtime, internal/cache, internal/compat, and internal/config. JS parse entry is js_parser.Parse; CSS parse entry is css_parser.Parse; print entries are js_printer.Print and css_printer.Print.
- File IO goes through internal/fs.FS so tests can mock it and so Yarn PnP zip installs can be overlaid. fs.go documents the abstraction; fs_zip.go wraps an inner FS and treats zip files as directories, including Yarn __virtual__ and $$virtual path segments.
- The Makefile default target builds with CGO_ENABLED=0, -ldflags=-s -w -buildid=, -buildvcs=false, and -trimpath. go.version is 1.26.5. The go-compiler target downloads that Go source and comments out ctxt.buildinfo() so go version ./esbuild does not embed the toolchain version.
- make no-filepath fails the build if any Go file under cmd, internal, or pkg imports path/filepath, citing golang.org/issue/43768. CI runs that check on Ubuntu.
- WebAssembly builds use main_wasm.go under //go:build js && wasm. That file rejects --trace, --heap, and --cpuprofile and sets isServeUnsupported to true, so the dev server is not available in WASM.
- npm/esbuild postinstall is node install.js. optionalDependencies lists per-OS @esbuild/* packages at 0.28.2, and esbuild.binaryHashes stores sha256 digests of those binaries. esbuild-wasm has no optionalDependencies and points browser at lib/browser.js.
- GitHub Actions workflows are ci.yml (push, PR, dispatch), publish.yml (push to main when version.txt changes), e2e.yml (cron every 6 hours plus dispatch), and validate.yml (tags v* and dispatch running make validate-builds).