Introduction
Bunup is the ⚡️ blazing-fast build tool for TypeScript libraries, designed for flawless developer experience and speed, powered by Bun.
Performance
Bunup delivers instant builds by design. With Bun's native speed, builds and rebuilds are extremely quick, even in monorepos. See benchmarks.
Quick Start
Quickly scaffold a new modern TypeScript or React library with Bunup in just 10 seconds.
bunx @bunup/cli@latest create
See the Scaffold with Bunup page for more details.
Or, initialize bunup in an existing project:
bunx @bunup/cli@latest init
Prerequisites
Enable isolatedDeclarations
in your tsconfig:
{
"compilerOptions": {
"declaration": true,
"isolatedDeclarations": true
}
}
See why here
Getting Started
Get started with Bunup in seconds - install, configure, and build your TypeScript projects with minimal setup.
Basic Usage
Create a TypeScript file:
export function greet(name: string): string {
return `Hello, ${name}!`;
}
Bundle it with bunup:
bunx bunup src/index.ts
That's it! This creates bundled output in the dist
directory with ESM format (the default), plus TypeScript declaration files (.d.ts
) since the entry point is a TypeScript file.
Using with package.json
First, install bunup as a dev dependency:
bun add --dev bunup
Add a build script to your package.json
:
{
"name": "my-package",
"scripts": {
"build": "bunup src/index.ts"
}
}
Then run:
bun run build
Configuration
Create a bunup.config.ts
file for usage like including plugins, hooks, and advanced options that aren't available via CLI.
For example, you can add the exports plugin to automatically sync your package.json exports on each build - no more manual export management!
import { defineConfig } from 'bunup';
import { exports } from 'bunup/plugins';
export default defineConfig({
entry: 'src/index.ts',
plugins: [exports()],
});
You can also export an array of configurations:
export default defineConfig([
{
name: 'node',
entry: 'src/index.ts',
format: 'esm',
target: 'node',
},
{
name: 'browser',
entry: 'src/index.ts',
format: ['esm', 'iife'],
target: 'browser',
outDir: "dist/browser",
},
]);
Custom Configuration Path
If you need to use a configuration file with a non-standard name or location, you can specify its path using the --config
CLI option:
bunup --config ./configs/custom.bunup.config.ts
Watch Mode
Bunup can watch your files for changes and rebuild automatically:
bunup src/index.ts --watch
Or in package.json:
{
"name": "my-package",
"scripts": {
"build": "bunup src/index.ts",
"dev": "bunup src/index.ts --watch"
}
}
Then run:
bun run dev