---
title: "The Bun Bundler"
description: "Bun now ships a native bundler in beta, exposed as the `bun build` CLI and the `Bun.build()` JavaScript API."
url: "https://swe.quest/articles/the-bun-bundler-1ad40102ca8fa3b8"
canonical: "https://bun.com/blog/bun-bundler"
source: "Bun"
published: "2023-05-16"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 10
tags: ["javascript","build-systems","developer-tools","web-performance"]
---

# The Bun Bundler

A post on [Bun](https://swe.quest/sources/bun.md), published 2023-05-16, 10 min read, Announcement. Original: [https://bun.com/blog/bun-bundler](https://bun.com/blog/bun-bundler)

## Summary

Bun now ships a native bundler in beta, exposed as the \`bun build\` CLI and the \`Bun.build()\` JavaScript API. It shares one plugin API with the runtime, returns Blob-compatible build artifacts, can compile standalone executables, and supports browser, bun and node targets. Bundles built for the bun target carry a \`// @bun\` pragma so the runtime skips re-transpilation. It includes tree shaking (sideEffects, \_\_PURE\_\_, NODE\_ENV/--define, ESM and limited CommonJS-to-ESM conversion), source maps and a new minifier, and it benchmarks at 1.75x faster than esbuild and 220x faster than Webpack on a three.js workload. Only ESM output is supported for now, and its architecture follows esbuild's design.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Web performance](https://swe.quest/tags/web-performance.md) (Web & mobile)

## Prerequisites

- JavaScript module systems (ESM/CommonJS) ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- JavaScript bundlers ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

Bun, Bun.build, esbuild, tree shaking, source maps, React Server Components, Bun.App

## Related posts

- [Bun v1.3.6](https://swe.quest/articles/bun-v1-3-6-82f073799d1ad25c.md): Bun · 2026-01-13 · Medium · 13 min read · JavaScript, Runtimes & VMs, Performance engineering, Build systems
  Bun v1.3.6 adds a built-in Bun.Archive API for creating and extracting tar/gzip archives, a native Bun.JSONC parser, and new Bun.build options for esbuild-compatible metafiles, virtual in-memory files, local cross-compile executables and React Fast Refresh.
- [Bun v0.1.11](https://swe.quest/articles/bun-v0-1-11-608f71de932fd530.md): Bun · 2022-09-07 · Medium · 4 min read · JavaScript, Runtimes & VMs
  Bun v0.1.11 adds a runtime plugin API, loosely modeled on esbuild's, that lets code import file types Bun has no built-in loader for (such as .svelte, .vue, .yaml, .mdx) and dynamically generate ESM/CJS modules, with examples for MDX and YAML loaders.
- [Bun v1.3.1](https://swe.quest/articles/bun-v1-3-1-ee365f019ab94793.md): Bun · 2025-10-22 · Medium · 9 min read · JavaScript, Runtimes & VMs, Build systems, Testing, Developer tools
  Bun v1.3.1 makes \`bun build\` up to 2x faster for symlink-heavy projects (isolated linker, pnpm).
- [Bun v1.1.30](https://swe.quest/articles/bun-v1-1-30-4f8e7c9af8830c50.md): Bun · 2024-10-08 · Medium · 10 min read · JavaScript, Build systems, CSS, Runtimes & VMs, Developer tools
  Bun v1.1.30 adds an experimental CSS parser and bundler, a LightningCSS port rewritten from Rust to Zig.
- [Bun v1.2.17](https://swe.quest/articles/bun-v1-2-17-6bfcdfe2dc03cf80.md): Bun · 2025-06-21 · Medium · 10 min read · JavaScript, Runtimes & VMs, Build systems, Performance engineering
  Bun v1.2.17 adds ahead-of-time bundling for HTML imports in server code, so \`bun build --target=bun\` or \`--compile\` can produce a full-stack build or a single self-contained executable with no runtime bundling.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
