A build tool with typed configuration.
This tool is a thin abstraction on top of unbuild. It centralizes your build configuration, which helps us consistently build opensource packages that support both module systems (CJS and ESM).
# w/ pnpm
pnpm add -D @pkg-tools/build @pkg-tools/config
# w/ yarn
yarn add -D @pkg-tools/build @pkg-tools/config
# w/ npm
npm install -D @pkg-tools/build @pkg-tools/config
In your package.json
, you can use the exported cli build
in your build script e.g.
"scripts": {
"build": "build"
"dev": "build -w"
"stub": "build -s"
}
Define a pkg.config.ts
in the root of your package and add the following.
import { defineConfig } from "@pkg-tools/config";
export default defineConfig({
build: {
entries: ["src/index"],
sourcemap: true,
extensions: "compatible",
rollup: {
inlineDependencies: true,
emitCJS: true,
esbuild: {
target: ["node16"],
minify: true,
},
},
declaration: "compatible",
},
});