Skip to content

Programmatic Usage

Bunup can be used programmatically in your scripts. This is useful when you need custom build workflows or want to integrate bunup into your own tools.

INFO

The build function must be run in the Bun runtime.

Basic Usage

typescript
import { build } from 'bunup';

await build({
  entry: ['src/index.ts'],
  outDir: 'dist',
  format: ['esm', 'cjs'],
  dts: true
});

Options

The build function accepts the same options as defineConfig. See the Options Guide for detailed documentation of all available options.

For TypeScript users, the BuildOptions type is available:

typescript
import { build, type BuildOptions } from 'bunup';

const options: BuildOptions = {
  entry: ['src/index.ts'],
  outDir: 'dist',
  format: ['esm', 'cjs'],
  dts: true
};

await build(options);

The full type definition can be found in the bunup source code.

Released under the MIT License.