Coder Social home page Coder Social logo

pkg-tools

An opinionated TS package build toolchain w/ typed configuration.

Github Actions

Usage

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,
    },
  },
});

πŸ‘€ Examples

Check out the examples to see pkg-tools usage.

πŸ”¬ Background

🚩 Problem

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.

🎯Goal

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)

πŸ› οΈ Tools

Below is the family of tools the comprise pkg-tools.

Package CLI(s) Library Status Version Downloads
@pkg-tools/build build unbuild 🟒 @pkg-tools/build::version @pkg-tools/build::downloads
@pkg-tools/clean clean shelljs 🟒 @pkg-tools/clean::version @pkg-tools/clean::downloads
@pkg-tools/format format prettier 🟒 @pkg-tools/format::version @pkg-tools/format::downloads
@pkg-tools/lint lint eslint 🟒 @pkg-tools/lint::version @pkg-tools/lint::downloads
@pkg-tools/sync sync oktokit 🟑 @pkg-tools/sync::version @pkg-tools/sync::downloads
@pkg-tools/sort sort oranize-imports / sort-package-json πŸ”΄ @pkg-tools/sync::version @pkg-tools/sync::downloads

Development

  • Clone this repository
  • Run fnm or nvm in the monorepo root
  • Install dependencies using pnpm install
  • Build the monorepo pnpm run build

License

MIT

pkg-tools's Projects

pkg-tools icon pkg-tools

An opinionated build toolchain with typed configuration. A project by @dopt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.