Registry / devops / bun-bundle

bun-bundle

JSON →
library4.0.3jsnpmunverified

bun-bundle is a lightweight module bundler that wraps Bun.build, providing a simplified API for bundling JavaScript and TypeScript projects. As of version 4.0.3 (released in late 2024), it supports ESM output, HTML entrypoints, and conditional entry naming. Compared to Bun's native build API, bun-bundle offers a less opinionated configuration and automatic handling of common patterns. It is actively maintained with frequent releases, focusing on simplicity and ease of use for projects targeting Bun runtime.

npm install bun-bundle
INSTALL
IMPORT
SIG · BUN-BUNDLE
B
bun-bundle
devopsjavascriptv4.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bundle
import { bundle } from 'bun-bundle'
import bundle from 'bun-bundle'
bundle is a named export, not default. Incorrect default imports will result in undefined.
BunBundleConfig
import { BunBundleConfig } from 'bun-bundle'
import { BunBundleBuildConfig } from 'bun-bundle'
In v2.1.1, the type was named BunBundleBuildConfig, but it was renamed to BunBundleConfig in v3+.
bundleSync
import { bundleSync } from 'bun-bundle'
const { bundleSync } = require('bun-bundle')
The package is ESM-only since v3. CommonJS require will cause a Module not found error.

Demonstrates basic usage of the bundle function with common options: entrypoints, output directory, target, format, and minification.

import { bundle } from 'bun-bundle'; const result = await bundle({ entrypoints: ['./src/index.ts'], outdir: './dist', target: 'bun', format: 'esm', splitting: true, sourcemap: 'external', minify: true, }); console.log(`Bundled ${result.outputs.length} files successfully`);
Debug
Known issues
breakingThe API was simplified in v3.0.0, removing many previously required options and changing the function signature.
fix
Update your code to use the new flat configuration object. Refer to the v3 migration guide.
affects: >=3.0.0 <3.0.0
breakingv4.0.0 introduced support for HTML entrypoints. Existing code that relied on default JS-only entrypoints may need to specify entrypoints explicitly.
fix
If you were using implicit JS entrypoints, migrate to explicit entrypoints in your configuration.
affects: <4.0.0
gotchabun-bundle requires Bun runtime to be installed globally or in the project. Running the bundler in Node.js will fail with a runtime error.
fix
Ensure you run your script with Bun (e.g., bun run build.js). Do not use node.
affects: >=1.0.0
gotchaThe 'target' option must be set to 'bun' for optimal compatibility. Using 'node' or 'browser' may cause issues with Bun-specific features like node:buffer.
fix
Set target: 'bun' in your configuration.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'bun-bundle'
Project not installed or using CommonJS require in an ESM-only package (v3+).
fix
Run 'bun install bun-bundle' (or 'npm install') and use ESM imports (import ... from 'bun-bundle').
TypeError: bundle is not a function
Default import used instead of named import.
fix
Change 'import bundle from' to 'import { bundle } from'.
Error: BundleBuildConfig is not a type
Using old type name BunBundleBuildConfig from v2.x.
fix
Use 'BunBundleConfig' instead.
Upgrade
Version history
4.0.3latest on npm
Audit
Dependencies
bunrequiredRuntime dependency: requires Bun to execute the bundler (uses Bun.build under the hood)
Agent activity
6 hits · last 30 days
node
4
Resources
bun-bundle — npm install bun-bundle · libregistry