Zero-config bundler for JS/TS packages, package.json as configuration.

Installation

npm install --save-dev bunchee typescript

Features

🚀 Zero Configuration

You already have package.json exports, why need another config?

📦 Multiple Formats

Supports ESM, CommonJS, and TypeScript declarations

⚡ Fast Builds

Powered by Rollup and SWC for optimal performance

🎯 Simple & Smart

Automatically externalization dependencies, lint package.json. Works with monorepos.

Configuration

Create entry files of your library and package.json.

$ cd ./coffee
$ mkdir src && touch ./src/index.ts

Add the exports in package.json.

{
  "name": "coffee",
  "type": "module",
  "main": "./dist/index.js",
  "scripts": {
    "build": "bunchee"
  }
}

Build

$ npm run build

Output

$ Exports  File             Size
$ .        dist/index.js    5.6 kB

Learn

Entry & Convention

Files in src/ folder match export names in package.json:

FileExport 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. Release yourself from thinking of the bundling mess.