Skip to content

RingoTangs/tsdown-template

Repository files navigation

tsdown-template

A minimal TypeScript library template powered by tsdown.

TypeScript Node.js pnpm tsdown Vitest ESLint Prettier

Build TypeScript libraries with dual ESM/CJS output, typed declarations, and a ready-to-use quality toolchain.

English | 简体中文

Requirements

  • Node.js >=18
  • pnpm 10

Commands

  • pnpm i installs dependencies
  • pnpm build creates a local development build with sourcemaps
  • pnpm build:watch rebuilds the library on source changes
  • pnpm build:publish creates a minified publish build without sourcemaps
  • pnpm test starts Vitest in watch mode
  • pnpm test:run runs the Vitest suite once
  • pnpm lint runs ESLint over the repository
  • pnpm lint:fix applies safe ESLint fixes
  • pnpm format checks formatting with Prettier
  • pnpm format:fix formats supported files with Prettier
  • pnpm typecheck runs TypeScript project references with tsc -b
  • pnpm check runs lint, format check, typecheck, and tests
  • pnpm check:fix runs lint and format fixes
  • pnpm pack:check verifies npm package contents with a dry-run
  • pnpm release:check runs all release validation, including package dry-run

Usage

  1. Create a new repository from this template.
  2. Update package.json metadata for your package.
  3. Run pnpm i.
  4. Use pnpm build during development.
  5. Verify changes with pnpm check.

Publishing

Before publishing a real npm package:

  1. Remove private: true from package.json or set it to false.
  2. Update name, version, description, author, repository, bugs, and homepage.
  3. Run pnpm release:check to verify linting, formatting, types, tests, the publish build, and npm package contents.
  4. Run npm publish when 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.

Output

The package publishes files from dist/ only and exposes both ESM and CJS entry points.

About

A TypeScript npm library template powered by tsdown

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors