A modern, minimal, runtime-agnostic TypeScript library template
This is my personal template, crafted to kickstart TypeScript libraries with best-in-class tooling, continuos integration, and a focus on developer experience.
- ⚡ tsdown — Super fast TypeScript build system with modern output
- 🧹 Biome — Next-gen and fast code formatter & linter
- 🔬 Vitest — Next-gen unit testing framework
- 📦 pnpm — Performant, disk-efficient package manager
- 🛡️ CI — Automated build and tests for Node.js & Bun
- 🚀 Auto publishing - Safe and automated releases with npm provenance support
- Click "Use this template"
- or clone manually:
git clone https://github.com/arobsn/tslib-template.git your-lib-name
cd your-lib-name
pnpm install- Edit
package.json(name,description,author, etc.) - Update
LICENSEandREADME.mdas needed
- Source files go in
src/. - Export your main API from
src/index.ts.
- Make sure that
publishConfig&repositoryare set accordingly inpackage.json - Ensure
NPM_TOKENis set in repository secrets (see instruction on how to create anAutomationnpm token and how to set it as a repository secret) - Create a release on GitHub to trigger publish workflow
| Script | Description |
|---|---|
pnpm build |
Build the library using tsdown |
pnpm build:watch |
Watch & rebuild on changes |
pnpm lint:check |
Lint code with Biome |
pnpm lint:fix |
Auto-fix lint issues |
pnpm format:check |
Check formatting with Biome |
pnpm format:fix |
Format code with Biome |
pnpm test |
Run unit tests with Vitest |
pnpm test:watch |
Watch mode for tests |
pnpm test:coverage |
Test with coverage report |
| Script | Description |
|---|---|
.github/workflows/ci.yml |
Test all pushes/PRs on Node.js & Bun |
.github/workflows/publish.yml |
Publish the package to the NPM every time a new Github release is created |
This template supports npm provenance for secure and transparent releases. Provenance allows users to verify that the published npm package was built from the source in your repository.
For provenance to work properly, you must:
- Use a public GitHub repository (provenance only works for public repos)
- Ensure your
package.jsoncontains:"publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }(✅ already set in this template)- A correct
"repository"field (GitHub HTTPS or git+https URL matching your repository name) - A
"license"field (e.g.,"MIT") (✅ already set, but you must choose yours)
- Publish using GitHub Actions with OIDC and the
--provenanceflag (✅ already set) - Use npm CLI v9.6.0+ for publishing (✅ already set)
- Set your
NPM_TOKENsecret in the repo settings
If you do not want provenance statements when publishing to npm (e.g., if you encounter issues or your workflow doesn't require it), you can disable it:
- Edit
.github/workflows/publish.yml - Remove the
--provenanceflag from bothnpm publishcommands.
- run: npm publish --provenance
+ run: npm publish
- run: npm publish --tag beta --provenance
+ run: npm publish --tag beta- Save and commit the changes.
Without the --provenance flag, npm will not attempt to attach provenance statements to your package.
