Registry / devops / bunflare

bunflare

JSON →
library0.2.25jsnpmunverified

Bunflare v0.2.25 is a Bun bundler plugin that transforms Bun-native APIs (e.g., Bun.serve, bun:sqlite, Bun.password.hash) into Cloudflare Workers equivalents at build time. It targets developers who want Bun's DX but need to deploy to Cloudflare Workers. Key differentiators: zero runtime overhead (transform happens at build time), no code changes required for the developer, supports auto-discovery from wrangler.jsonc, and covers a wide range of Bun APIs including D1, KV, R2, Hyperdrive, WebCrypto, Workers Assets, and fullstack builds. Released as a dev dependency, it requires Bun >=1.0.0 and optionally integrates with Hono and Drizzle ORM. The package ships with TypeScript types. The project is actively maintained with recent commits.

npm install bunflare
INSTALL
IMPORT
SIG · BUNFLARE
B
bunflare
devopsjavascriptv0.2.25
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default (BunflareConfig type)
import type { BunflareConfig } from 'bunflare'
import { BunflareConfig } from 'bunflare' // BunflareConfig is a type, not a value
BunflareConfig is a TypeScript type, imported with 'import type' to avoid runtime errors.
default (plugin)
import bunflare from 'bunflare'
const bunflare = require('bunflare') // Bunflare is ESM-only, require() fails
The package is ESM-only. Use import statement.
CloudflareBindings (interface)
interface CloudflareBindings { } // augmented by 'wrangler types' into worker-configuration.d.ts
import { CloudflareBindings } from 'bunflare' // CloudflareBindings is not exported from bunflare
CloudflareBindings is a global interface you declare yourself, often populated by 'wrangler types' generation.

Shows minimal setup: install as devDep, create config with entrypoint, write standard Bun code, build with `bun bunflare`.

// Install: bun add -d bunflare // bunflare.config.ts import type { BunflareConfig } from 'bunflare'; export default { entrypoint: './index.ts', // Optional: bindings are auto-discovered from wrangler.jsonc // sqlite: { binding: 'DB' }, } satisfies BunflareConfig; // index.ts (source code, unchanged) Bun.serve({ port: 3000, fetch(request) { return new Response('Hello from Bun!'); }, }); // Build command: // bun bunflare // Outputs Cloudflare Worker-compatible bundle to dist/worker.js
Debug
Known issues
breakingBunflare v0.2.x requires Bun >=1.0.0. Older Bun versions may produce errors or fail to load the plugin.
fix
Upgrade Bun to >=1.0.0 and bunflare to latest.
affects: <0.2.0
breakingBunflare transforms Bun.serve into Cloudflare Workers fetch handler. If your Bun.serve uses advanced features (e.g., TLS options, unix sockets), those will not work on Workers and build may fail.
fix
Avoid TLS/unix socket options in Bun.serve. Use regular HTTP/HTTPS or omit options.
affects: >=0.1.0
deprecatedThe `bunflare` CLI command is being phased out in favor of `bun bunflare`. Running `npx bunflare` may produce deprecation warnings.
fix
Use `bun bunflare` (if using Bun) or add a script in package.json: "build": "bun bunflare".
affects: >=0.2.0
gotchaBunflare automatically discovers bindings from wrangler.jsonc. If the file is missing or misconfigured, bindings (D1, KV, R2) will not work at runtime on Workers.
fix
Ensure wrangler.jsonc exists with correct binding names. Use explicit config in bunflare.config.ts if needed.
affects: >=0.2.0
gotchaTypeScript type augmentation for Bun.env requires a manual global.d.ts and running 'wrangler types'. Without it, TypeScript errors appear on Bun.env.KEY usage.
fix
Create global.d.ts with the snippet from the readme and run 'wrangler types' to generate worker-configuration.d.ts.
affects: >=0.1.0
gotchaUsing bun:sqlite with Drizzle ORM requires drizzle-orm as peer dependency. Not installing it will cause runtime errors when SQL queries are executed via Drizzle on D1.
fix
Install drizzle-orm: bun add drizzle-orm
affects: >=0.2.0
Errors
Common errors & fixes
ReferenceError: Bun is not defined
Trying to run Bun-specific code in a Cloudflare Workers environment without building with Bunflare.
fix
Ensure your build step uses 'bun bunflare' or the Bunflare plugin, and deploy the output bundle (not the source).
Cannot find module 'bunflare' or its corresponding type declarations.
Bunflare not installed or missing in tsconfig's 'types' or 'includes'.
fix
Run 'bun add -d bunflare' and ensure your tsconfig includes node_modules/@types or the package types.
SyntaxError: Unexpected token 'export'
Attempting to require() an ESM-only package with CommonJS require() in Node.js.
fix
Switch to ESM (use import statements) or use a dynamic import: const bunflare = await import('bunflare')
Binding 'DB' not found in environment
Cloudflare Worker doesn't have a D1 binding named 'DB', or the binding name in bunflare.config.ts doesn't match the deployed binding.
fix
Verify the binding name in wrangler.jsonc and your config match. Also check that the D1 database is created and bound in Cloudflare dashboard.
Type 'BunflareConfig' is not assignable to type 'BunflareConfig' (different namespaces)
Type conflict when importing BunflareConfig from both bunflare and another module that re-exports it.
fix
Use import type { BunflareConfig } from 'bunflare' consistently and avoid re-exporting from other files.
Upgrade
Version history
0.2.25latest on npm
Audit
Dependencies
honooptionalRequired for fullstack/SPA builds using Hono routes converted to Cloudflare Workers fetch handlers
drizzle-ormoptionalRequired for D1 SQL integration when using Drizzle ORM with the SQLite shim
Agent activity
49 hits · last 30 days
node
44
OpenAI (training)
1
Resources