Skip to content

Opinionated CLI to scaffold modern TypeScript libraries with tsup and vitest

License

Notifications You must be signed in to change notification settings

qgave/create-pkg-bone

Repository files navigation

create-pkg-bone

I was sick of copy-pasting tsconfig.json and package.json scripts from old projects every time I started a new TypeScript library.

I built create-pkg-bone to automate the boring setup part of creating modern TypeScript libraries. It sets you up with a sensible configuration for bundling, testing, and publishing, so you can actually start writing code.

What you get

It's pretty opinionated, but works for 99% of the libs I write:

  • tsup: For bundling. If you haven't used it, it's fast, zero-config, and handles .d.ts generation perfectly.
  • TypeScript: Obvs. Configured with strict adjustments depending on if you target Node or the Browser.
  • Vitest (Optional): Because Jest is too slow these days.
  • ESM & CJS: Sets up the exports field in package.json correctly so your package works everywhere.

Usage

You'll need Node.js 18 or higher. Just run:

npm create pkg-bone@latest

It'll ask you a few things to get started:

  1. Name: What are we calling this?
  2. Target: Node.js, Browser, or Isomorphic (both).
  3. Vitest: Want tests? (Say yes).
  4. Environment: If you chose Browser/Isomorphic, do you want jsdom or happy-dom?
  5. Meta: Description, Author, and License (MIT, Apache, etc).
  6. Git: Initialize a repo?
  7. Access: Should the package be public on npm?

Once it's done, it'll even ask which package manager you want to use (npm, pnpm, yarn, or bun) and install everything for you.

CLI Flags

If you want to skip the chat:

# Create a node library with vitest and git init
npm create pkg-bone@latest my-lib --target node --vitest --git

# Set public access (adds publishConfig to package.json)
npm create pkg-bone@latest my-lib --public

# Force overwrite existing folder
npm create pkg-bone@latest my-lib -f

License

MIT

About

Opinionated CLI to scaffold modern TypeScript libraries with tsup and vitest

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published