A minimal TypeScript library template powered by tsdown.
Build TypeScript libraries with dual ESM/CJS output, typed declarations, and a ready-to-use quality toolchain.
English | 简体中文
- Node.js
>=18 - pnpm
10
pnpm iinstalls dependenciespnpm buildcreates a local development build with sourcemapspnpm build:watchrebuilds the library on source changespnpm build:publishcreates a minified publish build without sourcemapspnpm teststarts Vitest in watch modepnpm test:runruns the Vitest suite oncepnpm lintruns ESLint over the repositorypnpm lint:fixapplies safe ESLint fixespnpm formatchecks formatting with Prettierpnpm format:fixformats supported files with Prettierpnpm typecheckruns TypeScript project references withtsc -bpnpm checkruns lint, format check, typecheck, and testspnpm check:fixruns lint and format fixespnpm pack:checkverifies npm package contents with a dry-runpnpm release:checkruns all release validation, including package dry-run
- Create a new repository from this template.
- Update
package.jsonmetadata for your package. - Run
pnpm i. - Use
pnpm buildduring development. - Verify changes with
pnpm check.
Before publishing a real npm package:
- Remove
private: truefrompackage.jsonor set it tofalse. - Update
name,version,description,author,repository,bugs, andhomepage. - Run
pnpm release:checkto verify linting, formatting, types, tests, the publish build, and npm package contents. - Run
npm publishwhen the dry-run output looks correct.
npm publish automatically runs prepublishOnly, which executes pnpm release:check. Release artifacts are produced by build:publish; prepare is only for Husky hook setup.
The package publishes files from dist/ only and exposes both ESM and CJS entry points.