How evanw/esbuild works
esbuild is a fast JavaScript and CSS bundler with CLI, Go, and JavaScript APIs. A typical build starts with a user invoking an API, resolves entry points and dependencies, parses and transforms source, links modules, then prints generated files and optional source maps. The README also documents plugins, watch mode, a local server, tree shaking, and minification. The graph reflects documented capabilities and indexed module references; unsampled implementation details are represented cautiously rather than treated as inspected.
Main entry points: bundler.go Build and transform · api_impl.go Go API · linker.go Linker · index.ts Compatibility table generator
Components 24
Interfaces and lifecycle
- CLI
pkg/cli/cli_impl.go - Go API
pkg/api/api_impl.go - JavaScript API
lib/npm/node.ts - Service protocol
cmd/esbuild/service.go - Watch and serve
pkg/api - Plugin hooks
pkg/api/api_impl.go
Build orchestration
- Build and transform
internal/bundler/bundler.go - Module resolver
internal/resolver/resolver.go - Module graph
internal/graph/graph.go - Linker
internal/linker/linker.go - Generated files
internal/bundler
Language processing
- JS lexer
internal/js_lexer/js_lexer.go - JS parser and lowering
internal/js_parser - JS printer
internal/js_printer/js_printer.go - CSS parser
internal/css_parser/css_parser.go - CSS printer
internal/css_printer/css_printer.go - Source maps
internal/sourcemap/sourcemap.go
Compatibility data
- Runtime compatibility
internal/compat - Compatibility table generator
compat-table/src/index.ts - JavaScript support data
compat-table/src/js_table.ts - CSS support data
compat-table/src/css_table.ts - MDN data source
compat-table/src/mdn.ts - Can I Use data source
compat-table/src/caniuse.ts
Other components
- Developer
Connections 27
- Developer → CLI: invokes
- Developer → Go API: uses
- Developer → JavaScript API: uses
- CLI → Go API: calls
pkg/cli/cli_impl.go - JavaScript API → Service protocol: exchanges requests
- Go API → Build and transform: builds or transforms
- Go API → Linker: links build output
- Go API → Watch and serve: supports lifecycle
- Go API → Plugin hooks: registers hooks
pkg/api/api_impl.go - Build and transform → Module resolver: resolves imports
internal/bundler/bundler.go - Build and transform → JS lexer: scans JavaScript
internal/bundler/bundler.go - Build and transform → JS parser and lowering: parses JavaScript
internal/bundler/bundler.go - Build and transform → CSS parser: parses CSS
internal/bundler/bundler.go - Build and transform → Module graph: builds module graph
internal/bundler/bundler.go - Linker → Module graph: reads module graph
internal/linker/linker.go - Linker → JS printer: prints JavaScript
internal/linker/linker.go - Linker → CSS printer: prints CSS
internal/linker/linker.go - Linker → Generated files: generates files
internal/linker/linker.go - Build and transform → Generated files: emits build results
- JS printer → Source maps: adds mappings
internal/js_printer/js_printer.go - CSS printer → Source maps: adds mappings
internal/css_printer/css_printer.go - JS parser and lowering → Runtime compatibility: checks targets
internal/js_parser/js_parser_lower.go - CSS parser → Runtime compatibility: checks support
internal/css_parser/css_parser.go - Compatibility table generator → JavaScript support data: generates table
compat-table/src/index.ts - Compatibility table generator → CSS support data: generates table
compat-table/src/index.ts - Compatibility table generator → MDN data source: uses data
compat-table/src/index.ts - Compatibility table generator → Can I Use data source: uses data
compat-table/src/index.ts