Détail du package

obuild

unjs301MIT0.2.1

Zero-config ESM/TS package builder

readme

📦 obuild 😯

✅ Zero-config ESM/TS package builder.

Powered by oxc, rolldown and rolldown-plugin-dts.

The obuild project aims to be the next-generation successor to the current unbuild.

  • 👌 Focus on ESM compatibility.
  • 🌱 Fresh rewrite with cleanups and removal of legacy features.
  • 🚀 Using oxc (for transform) and rolldown (for bundle) for much faster builds!

Some differences are not easy to adopt. Developing as a standalone project allows for faster progress and dogfooding in real projects.

Proof of concept

[!IMPORTANT]

This is a proof-of-concept project.

Features are incomplete, and API and output behavior may change between 0.x versions.

Feedback and contributions are very welcome! If you'd like to make changes with more than a few lines of code, please open an issue first to discuss.

Currently 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";

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
    },
    {
      type: "transform",
      input: "./src/runtime",
      outDir: "./dist/runtime",
      // minify: false,
      // stub: false,
      // oxc: {},
    },
  ],
  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.

changelog

Changelog

v0.2.1

compare changes

🩹 Fixes

  • Programmatic build with string entries (#30)

💅 Refactors

🏡 Chore

❤️ Contributors

v0.2.0

compare changes

🚀 Enhancements

  • Passthrough stub mode (#28)
  • Add +x permission to CLI entries (#26)
  • ⚠️ Allow passing all dts options for bundle (2bab1e8)
  • ⚠️ Allow passing all oxc-transform options (5729956)
  • Allow passing all rolldown config to build entries (edd39af)
  • ⚠️ Unified config for programmatic api (33a5869)

📖 Documentation

🏡 Chore

✅ Tests

⚠️ Breaking Changes

  • ⚠️ Allow passing all dts options for bundle (2bab1e8)
  • ⚠️ Allow passing all oxc-transform options (5729956)
  • ⚠️ Unified config for programmatic api (33a5869)

❤️ Contributors

v0.1.1

compare changes

🚀 Enhancements

🩹 Fixes

  • Default rolldown platform to neutral (2930787)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.1.0

compare changes

🚀 Enhancements

  • ⚠️ Map dist paths based on source (4170d54)

💅 Refactors

  • Show dist info in cli output (a6d475b)

⚠️ Breaking Changes

  • ⚠️ Map dist paths based on source (4170d54)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.8

compare changes

🚀 Enhancements

  • Support minify and declaration options (per entry) (#20)

💅 Refactors

  • Switch to tinyglobby (#22)

🏡 Chore

❤️ Contributors

v0.0.7

compare changes

🚀 Enhancements

🩹 Fixes

  • Safe hash for rolldown chunks (7c8dacc)

📦 Build

🏡 Chore

❤️ Contributors

v0.0.6

compare changes

🩹 Fixes

  • Externalize subpath exports of deps as well (d6343a0)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.5

compare changes

🚀 Enhancements

  • Support build.config (#9)
  • Expose programmatic build (e35a743)
  • cli: Support multi input bundle entries (e5e2b61)
  • Basic hooks via config (3ac4a9a)

🩹 Fixes

  • Correct the src directory in the transform complete message (#10)

🏡 Chore

❤️ Contributors

v0.0.4

compare changes

🩹 Fixes

  • Increase node compat by conditionally using fs.glob (7bb2595)

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.3

compare changes

🚀 Enhancements

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.2

compare changes

🏡 Chore

🤖 CI

❤️ Contributors

  • Pooya Parsa (@pi0)

v0.0.1

📦 Build

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)