bun-bundler

Bundle JavaScript and TypeScript projects using Bun.build and the bun build CLI.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-bundler-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bun-bundler
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/bun-bundler
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-bundler-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Configuring JavaScript and TypeScript bundling involves many interdependent options like targets, formats, minification, code splitting, and sourcemaps, and getting them wrong produces broken or bloated builds. This Skill provides complete, correct guidance for bundling with Bun's built-in bundler via both the CLI and the Bun.build JavaScript API. ## Core Features & Use Cases - CLI and API Bundling: Covers both bun build command-line flags and the full Bun.build() options object including entrypoints, outdir, target, and format. - Production Optimization: Guidance on minification, code splitting, sourcemaps, tree shaking, define constants, and externalizing dependencies. - Loaders and Plugins: Documents built-in loaders for assets like SVG, PNG, and CSS, plus the plugin API with onResolve and onLoad hooks. - Use Case: A developer migrating from esbuild needs to produce a minified, code-split browser bundle with external sourcemaps and environment defines; this Skill provides the exact Bun.build configuration. ## Quick Start Ask the assistant to bundle your TypeScript entry point for the browser with minification and external sourcemaps using Bun.build.

Frequently Asked Questions about bun-bundler

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I bundle TypeScript with Bun?

Run bun build ./src/index.ts --outdir ./dist from the CLI, or call Bun.build with entrypoints and outdir in a script. Bun transpiles TypeScript natively without extra configuration, and you can add --minify for production output.

How to enable code splitting in Bun.build?

Set splitting: true in Bun.build and provide multiple entrypoints. Bun automatically extracts shared dependencies into separate chunks, which you can name using the naming.chunk pattern with placeholders like [name] and [hash].

Bun bundler vs esbuild for production builds?

Bun's bundler is an esbuild-compatible alternative built on Bun's native engine, supporting similar options like minify, sourcemap, target, and plugins. It integrates directly with the Bun runtime and adds features like bytecode compilation for the bun target.

Does Bun.build support custom file loaders?

Yes, Bun.build supports loaders for extensions like .svg, .png, and .css through the loader option. Available loader types include text, file, base64, dataurl, json, toml, and css, each controlling how the file is exported in the bundle.

Why does Bun build fail with Could not resolve?

The Could not resolve error means an imported module is missing or the path is wrong. Install the missing package, fix the import path, or mark the package as external if it should not be bundled.

Can Bun.build output a single file instead of a directory?

Yes, use the outfile option instead of outdir to write a single bundled file, for example outfile: ./dist/bundle.js. Note that code splitting requires directory output with outdir since it produces multiple chunks.