A GitHub template for starting new ESM-only TypeScript libraries.
-
Click "Use this template" on GitHub to create a new repository from this one.
-
Clone your new repository and run:
pnpm install && pnpm setup:templateYou will be asked for a package name, a description, and an author. The script rewrites
package.json,README.md, andLICENSEaccordingly, fills inrepository,homepage, andbugsfrom youroriginremote, then removes itself.setup:templateruns a TypeScript file directly, so it needs Node 22.18 or newer (Node 24 is what CI uses). The published package itself only requires Node 22.
| Script | Purpose |
|---|---|
typecheck |
Type-check the project with tsc --noEmit. |
test |
Run the test suite once with Vitest. |
test:watch |
Run the test suite in watch mode. |
test:coverage |
Run the test suite with coverage reporting. |
bench |
Run the benchmark suite with Vitest bench. |
build |
Build the package with tsdown. |
check:package |
Check the built package with publint and attw. |
lint |
Check formatting and lint rules with Biome. |
lint:fix |
Apply Biome's automatic fixes. |
verify |
Run typecheck, lint, test, build, and check:package in sequence. |
prepare |
Install git hooks via Husky. |
changeset |
Record a changeset for the next release. |
version-packages |
Apply pending changesets and bump the version. |
release |
Build and publish the package via Changesets. |
Releases are automated with Changesets, and the release workflow publishes
via npm's trusted publishing
(OIDC) rather than a long-lived token, so there is no NPM_TOKEN secret to
manage.
Trusted publishing can only be configured for a package that already exists on npm, so the very first release needs a one-time manual bootstrap:
- Run
pnpm setup:template, thennpm loginandnpm publish --access public --no-provenance(or--access restrictedfor a scoped private package) locally, once, to reserve the name.--no-provenanceis required here:publishConfig.provenance: trueotherwise forces provenance generation, which only works from a supported CI provider (GitHub Actions, GitLab CI, ...) and errors out locally withAutomatic provenance generation not supported for provider: null. This one bootstrap release just won't carry a provenance attestation; every release after it publishes from CI and gets one automatically. - On the package's npm page, open Settings > Trusted Publisher, choose
GitHub Actions, and fill in your GitHub org/user, the repository name,
the workflow filename
release.yml, and "npm publish" as the allowed action. Leave "Environment name" blank unless the workflow is gated behind a GitHub environment. - From then on, every release goes through CI: merge a changeset to
main, the release workflow opens a "Version Packages" pull request, and merging that pull request publishes the package to npm.
Under Settings > Actions > General, "Allow GitHub Actions to create and approve pull requests" must be enabled, or the version pull request cannot be opened.
changeset publish runs pnpm publish under the hood, which in turn shells
out to npm publish - trusted publishing is npm CLI's feature, not pnpm's,
so the workflow installs the latest npm before publishing to guarantee the
=11.5.1 it requires. Provenance is generated automatically by trusted publishing for a public repository publishing a public package; the
publishConfig.provenance: truefield inpackage.jsonis kept for documentation but isn't what triggers it anymore. Provenance still requiresrepository.urlinpackage.jsonto match the repository the release is published from, so double-check it if the remote ever changes.
src/greet.ts, test/greet.test.ts, and bench/greet.bench.ts are
placeholders that exist to keep the test, build, and bench scripts runnable
out of the box. Replace them with your own code as your first commit rather
than just deleting them: pnpm test fails once no file matches
test/**/*.test.ts, so swap in your own test instead of leaving the
directory empty.