obuild

Zero-config ESM/TS package builder

MIT 55 个版本
安装
npm install obuild
yarn add obuild
pnpm add obuild
bun add obuild
README

📦 obuild 😯

✅ Zero-config ESM/TS package builder powered by rolldown.

Used by

Usage

CLI

# bundle
npx obuild ./src/index.ts

# transform
npx obuild ./src/runtime/:./dist/runtime

You can use --dir to set the working directory.

If paths end with /, obuild uses transpile mode using oxc-transform instead of bundle mode with rolldown.

Programmatic

import { build } from "obuild";

await build({
  cwd: ".",
  entries: ["./src/index.ts"],
});

Config

You can use build.config.mjs (or .ts) or pass config to build() function.

import { defineBuildConfig } from "obuild/config";

export default defineBuildConfig({
  entries: [
    {
      type: "bundle",
      input: ["./src/index.ts", "./src/cli.ts"],
      // outDir: "./dist",
      // minify: false,
      // stub: false,
      // rolldown: {}, // https://rolldown.rs/reference/config-options
      // dts: {}, // https://github.com/sxzz/rolldown-plugin-dts#options
      // license: { gzip: true }, // emit `THIRD-PARTY-LICENSES.md.gz` (set `false` to disable)
    },
    {
      type: "transform",
      input: "./src/runtime",
      outDir: "./dist/runtime",
      // minify: false,
      // stub: false,
      // oxc: {},
      // resolve: {}
    },
  ],
  hooks: {
    // start: (ctx) => {},
    // end: (ctx) => {},
    // entries: (entries, ctx) => {},
    // rolldownConfig: (config, ctx) => {},
    // rolldownOutput: (output, res, ctx) => {},
  },
});

Stub Mode

When working on a package locally, it can be tedious to rebuild or run the watch command every time.

You can use stub: true (per entry config) or the --stub CLI flag. In this mode, obuild skips the actual build and instead links the expected dist paths to the source files.

  • For bundle entries, .mjs and .d.mts files re-export the source file.
  • For transpile entries, src dir is symlinked to dist.

Caveats:

  • You need a runtime that natively supports TypeScript. Deno, Bun, Vite, and Node.js (1)
  • For transpile mode, you need to configure your bundler to resolve either .ts or .mjs extensions.
  • For bundle mode, if you add a new entry or add/remove a default export, you need to run the stub build again.

(1) For Node.js, you have several options:

  • Using node --experimental-strip-types (Available in 22.6)
  • Using jiti (node --import jiti/register)
  • Using oxc-node (node --import @oxc-node/core/register)
  • Using unloader (node --import unloader/register)

Prior Arts

  • unbuild: Stable solution based on rollup and mkdist.
  • tsdown: Alternative bundler based on rolldown.

License

💛 Released under the MIT license.

版本列表
0.4.38 2026-07-11
0.4.37 2026-06-21
0.4.36 2026-05-22
0.4.35 2026-05-07
0.4.34 2026-05-01
0.4.33 2026-04-02
0.4.32 2026-03-07
0.4.31 2026-02-18
0.4.30 2026-02-18
0.4.29 2026-02-18
0.4.28 2026-02-17
0.4.27 2026-02-06
0.4.26 2026-02-06
0.4.25 2026-02-06
0.4.24 2026-02-05
0.4.23 2026-02-05
0.4.22 2026-01-27
0.4.21 2026-01-27
0.4.20 2026-01-23
0.4.19 2026-01-22
0.4.18 2026-01-20
0.4.17 2026-01-20
0.4.16 2026-01-19
0.4.15 2026-01-19
0.4.14 2026-01-07
0.4.13 2026-01-06
0.4.12 2026-01-06
0.4.11 2026-01-06
0.4.10 2026-01-02
0.4.9 2025-12-17
0.4.8 2025-12-12
0.4.7 2025-12-04
0.4.6 2025-12-04
0.4.5 2025-12-04
0.4.4 2025-12-03
0.4.3 2025-11-25
0.4.2 2025-11-20
0.4.1 2025-11-08
0.4.0 2025-11-08
0.3.2 2025-10-30
0.3.1 2025-10-30
0.3.0 2025-10-26
0.2.1 2025-05-27
0.2.0 2025-05-27
0.1.1 2025-05-15
0.1.0 2025-05-14
0.0.8 2025-05-14
0.0.7 2025-05-13
0.0.6 2025-05-08
0.0.5 2025-05-08
0.0.4 2025-04-22
0.0.3 2025-04-22
0.0.2 2025-04-22
0.0.1 2025-04-16
0.0.0 2024-10-01