A minimal, well‑opinionated starter template for TypeScript Node packages. It includes:
- TypeScript for authoring the package
- Unbuild for producing ESM/CJS builds and types
- Vitest for testing and coverage (V8)
- ESLint and Prettier for linting & formatting
This repository is intended as a template you can copy when starting a new npm package.
- Node.js: Latest LTS version (v18 or higher recommended)
- Package manager: PNPM (v8 or higher)
- Operating System: Cross-platform (Windows, macOS, Linux)
Clone the template, install dependencies, and run the default tasks:
- Install dependencies
pnpm install- Run tests
pnpm test- Build the package
pnpm build- Update dependencies
pnpm deps:check- Verify the updated dependencies (if any)
pnpm deps:verifyThe template exposes a set of convenient npm scripts (see package.json):
pnpm build— Build withunbuild(outputs CJS/ESM and type declarations intodist).pnpm clean— Clean untracked/build artifacts usinggit clean.pnpm deps:check- Interactively update dependencies.pnpm deps:verify- Run this after installing the updated dependencies.pnpm test— Run tests once with Vitest.pnpm test:watch— Run Vitest in watch mode for TDD.pnpm coverage— Run tests and produce coverage reports (seereports/coverage).pnpm lint— Run ESLint and auto‑fix fixable issues.pnpm format— Run Prettier to format the repository.pnpm typecheck— Run TypeScript type checks (no emit).pnpm validate— Runs all validations on your code, linting, formatting, typecheck and tests.
- Create a feature branch from
main. - Run
pnpm test:watchto run tests in watch mode. - Implement your feature in
src/and add tests intests/. - Run
pnpm validateto check your code. - Build with
pnpm buildand check thedist/output if meant for publishing.
Vitest is configured for fast unit tests. Run pnpm coverage to generate coverage output. Open reports/coverage/index.html in your browser for the human‑readable report.
- ESLint is installed and wired to the
lintscript. It includes recommended rules and sonarjs plugin. - Prettier is used for consistent formatting and a Prettier import‑sorting plugin is included.
Before committing run:
pnpm validateThis template uses unbuild to generate distributable outputs in dist/. The exports field in package.json is set up to provide both ESM and CommonJS entry points and separate type files for each format.
Before publishing, ensure:
- Tests pass and coverage is acceptable.
- Type checking (
pnpm validate) passes. - The
dist/contents look correct afterpnpm build.
If you publish to npm, follow these steps as a checklist:
- Bump the package version in
package.json. - Run
pnpm build. - Verify
dist/contains the expected entry files. - Publish using
npm publish --access public(or your preferred publish command).
Tip: use a release workflow or np to automate versioning and publishing.
You will find the project configuration in these files:
tsconfig.json— TypeScript configurationeslint.config.js— ESLint configurationprettier.config.js— Prettier configurationvitest.config.ts— Vitest configurationbuild.config.ts— unbuild configuration
- Node.js: v18+ recommended
- Vitest: v3.x (configured in the template)
Contributions are welcome. Please open issues and PRs against the repository you copied this template from.
MIT © Johan Meester