bunchee
Zero-config bundler for JS/TS packages — use your package.json as the config.
➜~/project$npm install --save-dev bunchee typescript
➜~/project$
{
"name": "coffee",
"type": "module",
"main": "./dist/index.js",
"scripts": {
"build": "bunchee"
}
}
➜~/project$
Exports File Size
. dist/index.js 5.6 kB
# Why bunchee?
- Zero config - package.json as config
- Auto-generates TypeScript declarations
- Supports ESM, CJS, or dual packages
- Tree-shakeable and monorepo friendly
# Perfect for
- npm packages and component libraries
- Node.js tools, CLI apps, and utilities
- Monorepo workspaces with shared packages
# Learn
## Entry & Convention
Files in src/ folder match export names in package.json:
+--------------------------+---------------------+
| File | Export Name |
+--------------------------+---------------------+
| src/index.ts | "." (default) |
| src/lite.ts | "./lite" |
| src/react/index.ts | "./react" |
+--------------------------+---------------------+
## Directives
Bunchee can manage multiple directives such as "use client", "use server", or "use cache" and automatically split your code into different chunks and preserve the directives properly.
## Wildcard Exports
Use wildcard patterns in exports to dynamically export subpaths:
// package.json
{
"exports": {
"./features/*": "./dist/features/*.js"
}
}
// Output:
// "./features/auth" -> "./dist/features/auth.js"
// "./features/user" -> "./dist/features/user.js"
## Native Addon (.node) Support
supports bundling native Node.js addon files (`.node` binaries).
// src/index.js
import addon from './native-addon.node'
// The .node file is copied to dist/ and
// the import is rewritten to load it at runtime