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.
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.tsgeneration 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
exportsfield inpackage.jsoncorrectly so your package works everywhere.
You'll need Node.js 18 or higher. Just run:
npm create pkg-bone@latestIt'll ask you a few things to get started:
- Name: What are we calling this?
- Target: Node.js, Browser, or Isomorphic (both).
- Vitest: Want tests? (Say yes).
- Environment: If you chose Browser/Isomorphic, do you want
jsdomorhappy-dom? - Meta: Description, Author, and License (MIT, Apache, etc).
- Git: Initialize a repo?
- 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.
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 -fMIT