Bundling by default. Unlike esbuild, Bun always bundles by default. This is why the
--bundle flag isn’t
necessary in the Bun example. To transpile each file individually, use Bun.Transpiler.Bundler only. Unlike esbuild, Bun’s bundler does not include a built-in development server or file watcher. The
bundler is intended for use in conjunction with
Bun.serve and other runtime APIs to achieve the same effect. As
such, all options relating to HTTP/file watching are not applicable.Performance
With a performance-minded API coupled with the extensively optimized Rust-based JS/TS parser, Bun’s bundler is 1.75x faster than esbuild on esbuild’s three.js benchmark.Bundling 10 copies of three.js from scratch, with sourcemaps and minification
CLI API
Bun and esbuild both provide a command-line interface.terminal
--minify do not accept an argument. Other flags like --outdir <path> do accept an argument; these flags can be written as --outdir out or --outdir=out. Some flags like --define can be specified several times: --define foo=bar --define bar=baz.
JavaScript API
Plugin API
Bun’s plugin API is designed to be esbuild compatible. Bun doesn’t support esbuild’s entire plugin API surface, but the core functionality is implemented. Many third-party esbuild plugins will work out of the box with Bun.Long term, we aim for feature parity with esbuild’s API, so if something doesn’t work please file an issue to help us
prioritize.
myPlugin.ts
onStart, onEnd, onResolve, and onLoad. It does not yet implement the esbuild hooks onDispose and resolve. initialOptions is partially implemented, being read-only and only having a subset of esbuild’s options; use config (same thing but with Bun’s BuildConfig format) instead.
myPlugin.ts
onResolve
- options
- arguments
- results
- 🟢
filter - 🟢
namespace
onLoad
- options
- arguments
- results
- 🟢
filter - 🟢
namespace