{"id":18186,"library":"bun-bundle","title":"bun-bundle","description":"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.","status":"active","version":"4.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/cdleveille/bun-bundle","tags":["javascript","bun","bundle","bundler","build","esm","module","typescript"],"install":[{"cmd":"npm install bun-bundle","lang":"bash","label":"npm"},{"cmd":"yarn add bun-bundle","lang":"bash","label":"yarn"},{"cmd":"pnpm add bun-bundle","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency: requires Bun to execute the bundler (uses Bun.build under the hood)","package":"bun","optional":false}],"imports":[{"note":"bundle is a named export, not default. Incorrect default imports will result in undefined.","wrong":"import bundle from 'bun-bundle'","symbol":"bundle","correct":"import { bundle } from 'bun-bundle'"},{"note":"In v2.1.1, the type was named BunBundleBuildConfig, but it was renamed to BunBundleConfig in v3+.","wrong":"import { BunBundleBuildConfig } from 'bun-bundle'","symbol":"BunBundleConfig","correct":"import { BunBundleConfig } from 'bun-bundle'"},{"note":"The package is ESM-only since v3. CommonJS require will cause a Module not found error.","wrong":"const { bundleSync } = require('bun-bundle')","symbol":"bundleSync","correct":"import { bundleSync } from 'bun-bundle'"}],"quickstart":{"code":"import { bundle } from 'bun-bundle';\n\nconst result = await bundle({\n  entrypoints: ['./src/index.ts'],\n  outdir: './dist',\n  target: 'bun',\n  format: 'esm',\n  splitting: true,\n  sourcemap: 'external',\n  minify: true,\n});\n\nconsole.log(`Bundled ${result.outputs.length} files successfully`);\n","lang":"typescript","description":"Demonstrates basic usage of the bundle function with common options: entrypoints, output directory, target, format, and minification."},"warnings":[{"fix":"Update your code to use the new flat configuration object. Refer to the v3 migration guide.","message":"The API was simplified in v3.0.0, removing many previously required options and changing the function signature.","severity":"breaking","affected_versions":">=3.0.0 <3.0.0"},{"fix":"If you were using implicit JS entrypoints, migrate to explicit entrypoints in your configuration.","message":"v4.0.0 introduced support for HTML entrypoints. Existing code that relied on default JS-only entrypoints may need to specify entrypoints explicitly.","severity":"breaking","affected_versions":"<4.0.0"},{"fix":"Ensure you run your script with Bun (e.g., bun run build.js). Do not use node.","message":"bun-bundle requires Bun runtime to be installed globally or in the project. Running the bundler in Node.js will fail with a runtime error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set target: 'bun' in your configuration.","message":"The 'target' option must be set to 'bun' for optimal compatibility. Using 'node' or 'browser' may cause issues with Bun-specific features like node:buffer.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'bun install bun-bundle' (or 'npm install') and use ESM imports (import ... from 'bun-bundle').","cause":"Project not installed or using CommonJS require in an ESM-only package (v3+).","error":"Error: Cannot find module 'bun-bundle'"},{"fix":"Change 'import bundle from' to 'import { bundle } from'.","cause":"Default import used instead of named import.","error":"TypeError: bundle is not a function"},{"fix":"Use 'BunBundleConfig' instead.","cause":"Using old type name BunBundleBuildConfig from v2.x.","error":"Error: BundleBuildConfig is not a type"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}