{"id":12934,"library":"bun-bundler","title":"Bun-Bundler: HTML, CSS, JS Bundler for Bun","description":"Bun-Bundler is a modern, ultra-fast asset bundler specifically designed for the Bun runtime environment, currently stable at version 0.2.12. It offers comprehensive capabilities for processing HTML (including Pug templating with includes and layouts), SCSS/CSS (with autoprefixing), JavaScript (bundling and minification via `Bun.build`), and static assets. Key features include SVG sprite generation, parallel image optimization with caching, and a development server with hot reload. It differentiates itself through its tight integration with Bun, leveraging Bun's speed and native APIs, and providing both a JavaScript API for advanced scripting and a zero-config-friendly CLI driven by JSON configuration files. Release cadence is rapid, reflecting its pre-1.0 development status, with potential for frequent API adjustments.","status":"active","version":"0.2.12","language":"javascript","source_language":"en","source_url":"https://github.com/jsqrt/bun-bundler","tags":["javascript","typescript"],"install":[{"cmd":"npm install bun-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add bun-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add bun-bundler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required runtime environment (>=1.0.0) for all bundling and development server operations.","package":"bun","optional":false}],"imports":[{"note":"The primary Bundler class is a default export, reflecting its central role. This package is ESM-first and built for the Bun runtime.","wrong":"import { Bundler } from 'bun-bundler';\nconst Bundler = require('bun-bundler');","symbol":"Bundler","correct":"import Bundler from 'bun-bundler';"},{"note":"Utility classes like ImageProcessor, SpriteBuilder, and Server are named exports from the 'bun-bundler/modules' submodule.","wrong":"import ImageProcessor from 'bun-bundler/modules';\nimport { ImageProcessor } from 'bun-bundler';","symbol":"ImageProcessor","correct":"import { ImageProcessor } from 'bun-bundler/modules';"},{"note":"The development server functionality is provided via the named 'Server' export from the 'bun-bundler/modules' submodule.","wrong":"import Server from 'bun-bundler/modules';\nimport { Server } from 'bun-bundler';","symbol":"Server","correct":"import { Server } from 'bun-bundler/modules';"}],"quickstart":{"code":"import Bundler from 'bun-bundler';\nimport { ImageProcessor, SpriteBuilder } from 'bun-bundler/modules';\n\nconst bundler = new Bundler();\nconst imgProcessor = new ImageProcessor();\nconst spriteBuilder = new SpriteBuilder();\n\nbundler.build({\n  dist: './build',\n  sass: './src/scss/app.scss',\n  cssDist: './build/css/',\n  js: './src/js/app.js',\n  jsDist: './build/js/',\n  html: './src/pug/',\n  htmlDist: './build',\n  staticFolders: ['./src/images/', './src/fonts/', './src/static/'],\n  assembleStyles: './build/css/app.css',\n  production: true,\n  onBuildComplete: () => {\n    imgProcessor.start({ entry: './build/images' });\n    spriteBuilder.start({\n      dist: './build/images/sprite/sprite.svg',\n      entry: './build/',\n      spriteIconSelector: 'svg[data-sprite-icon]',\n    });\n  },\n}).catch(error => {\n  console.error('Build failed:', error);\n  process.exit(1);\n});\n","lang":"typescript","description":"This quickstart demonstrates a full production build workflow using the JavaScript API, including HTML (Pug), SCSS, JavaScript bundling, and post-build image optimization and SVG sprite generation."},"warnings":[{"fix":"Always review the release notes and migration guides (if available) when upgrading to a new version. Pin exact versions in `package.json` to prevent unexpected breakages.","message":"As a pre-1.0 package (current version 0.2.12), the API of `bun-bundler` is subject to frequent changes. Breaking changes may occur in minor or even patch versions.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Ensure Bun version 1.0.0 or greater is installed globally and that scripts are run using `bun run <script>`.","message":"This bundler explicitly requires the Bun runtime. It will not work with Node.js or Deno due to its reliance on Bun's native APIs and build processes.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use `import Bundler from 'bun-bundler';` for the main bundler, and `import { ImageProcessor, Server } from 'bun-bundler/modules';` for utilities.","message":"Core `Bundler` class is a default export, while utility classes (`ImageProcessor`, `SpriteBuilder`, `Server`) are named exports from a separate submodule (`bun-bundler/modules`). Mixing these up leads to import errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install or upgrade Bun to version 1.0.0 or newer (e.g., `curl -fsSL https://bun.sh/install | bash` or `bun upgrade`).","cause":"The Bun runtime is either not installed on your system or the installed version is older than 1.0.0, which is a minimum requirement.","error":"Error: No Bun runtime found or version is incompatible. Bun >=1.0.0 required."},{"fix":"Change your import statement to `import Bundler from 'bun-bundler';`.","cause":"You are attempting to import the `Bundler` class as a named export (`import { Bundler }`), but it is exported as a default export.","error":"SyntaxError: Named export 'Bundler' not found. Did you mean to import it as a default import?"},{"fix":"Ensure that utility classes like `ImageProcessor`, `SpriteBuilder`, or `Server` are imported with the correct path: `import { ImageProcessor } from 'bun-bundler/modules';`.","cause":"This error typically occurs if you're trying to import utility modules directly from the main package path or if the 'modules' submodule path is incorrect.","error":"Error: Cannot find module 'bun-bundler/modules' from '<your-project-path>'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"bun-bundler"}