An opinionated TS package build toolchain w/ typed configuration.
Install:
# pnpm
pnpm add -D @pkg-tools/build @pkg-tools/clean @pkg-tools/config @pkg-tools/format @pkg-tools/lint
# yarn
yarn add -D @pkg-tools/build @pkg-tools/clean @pkg-tools/config @pkg-tools/format @pkg-tools/lint
# npm
npm install -D @pkg-tools/build @pkg-tools/clean @pkg-tools/config @pkg-tools/format @pkg-tools/lint
Use CLIs:
Use the CLIs provided by the packages in your package scripts.
"scripts": {
"build": "build",
"clean": "clean",
"dev": "build -w",
"format": "format",
"lint": "lint"
},
Configure:
Define a pkg.config.ts
in the root of your package and configure your pkg-tools.
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",
},
clean: {
directory: "./dist",
},
format: {
semi: true,
tabWidth: 2,
singleQuote: true,
},
lint: {
rules: {
"no-unused-vars": 0,
},
},
});
Check out the examples to see pkg-tools usage.
The build toolchain necessary to ship TS packages is complicated i.e., the dependencies, configuration, and package scripts necessary do the following.
- build
- dev (build w/ watch)
- lint
- format
- clean
The complexity arises from the growing number of runtimes targeted, the variety of what might be in your package, and the volatility of the JS/TS ecosystem.
Create an opinionated TS package build toolchain to help accomplish the most common tasks. Each tool should do the following.
- Wrap the modern best-of-breed tool for the task
- Be usable as a CLI or programmatically
- Be configurable via a single typed configuration file (
pkg.config.ts
)
Below is the family of tools the comprise pkg-tools.
Package | CLI(s) | Library | Status | Version | Downloads |
---|---|---|---|---|---|
@pkg-tools/build | build |
unbuild | 🟢 | ||
@pkg-tools/clean | clean |
shelljs | 🟢 | ||
@pkg-tools/format | format |
prettier | 🟢 | ||
@pkg-tools/lint | lint |
eslint | 🟢 | ||
@pkg-tools/sync | sync |
oktokit | 🟡 | ||
@pkg-tools/sort | sort |
oranize-imports / sort-package-json | 🔴 |
- Clone this repository
- Run
fnm
ornvm
in the monorepo root - Install dependencies using
pnpm install
- Build the monorepo
pnpm run build