Skip to content

A modern TypeScript library template with production-ready tooling and best practices.

License

Notifications You must be signed in to change notification settings

runespoor-engineering/ts-lib-template

@runespoorstack/{lib-name}

A modern TypeScript library template with production-ready tooling and best practices.

GitHub License GitHub issues npm downloads

πŸš€ TS Library Template

This is a comprehensive TypeScript library template designed to jumpstart your npm package development with modern tooling, best practices, and production-ready configurations.

✨ Features

πŸ”§ Modern Build System

  • TypeScript - Full TypeScript support with strict mode and ESNext target
  • tsup - Fast bundler with CommonJS and ESM output formats
  • Declaration files - Automatic .d.ts generation for TypeScript consumers

πŸ§ͺ Testing & Quality

  • Vitest - Lightning-fast unit testing with coverage reporting
  • Biome - Ultra-fast linting, formatting, and import organization
  • Coverage reporting - V8 provider with HTML, LCOV, and JSON outputs
  • Codecov integration - Automated coverage tracking and reporting

πŸ”„ Development Workflow

  • Husky - Git hooks for code quality enforcement
  • lint-staged - Run linters on staged files only
  • GitHub Actions - Complete CI/CD workflows for testing and publishing
  • Changelog management - Automated changelog generation with Runespoor tools

πŸ“¦ Package Management

  • pnpm - Fast, disk space efficient package manager
  • Node.js 20+ - Modern Node.js runtime support
  • ESM/CJS dual exports - Support for both module systems

🏁 Quick Start

1. Use this template

Click "Use this template" button or clone this repository:

git clone https://github.com/runespoor-engineering/ts-lib-template.git my-awesome-lib
cd my-awesome-lib

2. Replace placeholders

Replace the following placeholders throughout the project:

  • {lib-name} - Your library name (e.g., my-awesome-lib)
  • {repo-name} - Your repository name (e.g., my-awesome-lib)

Files to update:

  • package.json - Package name, repository URLs
  • README.md - Title, badges, and links
  • SECURITY.md - Security policy references
  • CONTRIBUTING.md - Clone command
  • .github/workflows/reusable-test.yml - Codecov slug

3. Install dependencies

pnpm install

4. Create your library

Create a src directory and start building your library:

mkdir src
echo "export const hello = () => 'Hello, World!';" > src/index.ts

5. Start developing

# Run tests
pnpm test

# Build your library
pnpm build

# Lint and format
pnpm lint:fix
pnpm format:fix

πŸ“ Project Structure

your-library/
β”œβ”€β”€ src/                     # Your library source code
β”œβ”€β”€ dist/                    # Built output (auto-generated)
β”œβ”€β”€ .github/                 # GitHub workflows and templates
β”‚   β”œβ”€β”€ workflows/           # CI/CD workflows
β”‚   └── ISSUE_TEMPLATE/      # Issue templates
β”œβ”€β”€ .husky/                  # Git hooks
β”œβ”€β”€ package.json             # Package configuration
β”œβ”€β”€ tsconfig.json            # TypeScript configuration
β”œβ”€β”€ tsup.config.ts           # Build configuration
β”œβ”€β”€ vitest.config.mjs        # Test configuration
β”œβ”€β”€ biome.json               # Linting and formatting config
└── Documentation files      # README, CONTRIBUTING, etc.

πŸ› οΈ Available Scripts

Script Description
pnpm build Build the library for production
pnpm test Run all tests
pnpm test --ui Run tests with UI
pnpm lint Check code for linting issues
pnpm lint:fix Fix linting issues automatically
pnpm format Check code formatting
pnpm format:fix Fix formatting issues
pnpm changelog:change Add a new changelog entry
pnpm unimported Find unused dependencies

πŸ”§ Configuration

TypeScript

  • Strict mode enabled
  • ESNext target and module
  • Declaration files generated
  • Source maps included

Build Output

  • CommonJS (dist/index.js)
  • ES Modules (dist/index.mjs)
  • TypeScript declarations (dist/index.d.ts)
  • Minified for production

Testing

  • Global test environment
  • Node.js environment
  • Coverage thresholds configured
  • HTML and LCOV reports

πŸš€ Publishing

The template includes automated publishing workflows:

  1. Manual publish - Trigger releases manually
  2. Version management - Automated version bumping
  3. NPM publishing - Secure token-based publishing
  4. GitHub releases - Automatic release notes

πŸ—οΈ What's Included

  • βœ… TypeScript configuration
  • βœ… Modern build system (tsup)
  • βœ… Testing framework (Vitest)
  • βœ… Code quality tools (Biome)
  • βœ… Git hooks (Husky + lint-staged)
  • βœ… GitHub Actions workflows
  • βœ… Code coverage reporting
  • βœ… Dependency management
  • βœ… Security policies
  • βœ… Contributing guidelines
  • βœ… Issue templates
  • βœ… Funding configuration

πŸ› οΈ Contributing

See the CONTRIBUTING.md document.

πŸ’• Special Thanks

  • I want to say thank you to the best woman in the world, my wife Diana for her love, daily support, motivation and inspiration.

❀️ Support or Donate

If you are enjoying this work and feel extra appreciative, you could buy me a book πŸ“– or 3 πŸ“–πŸ“–πŸ“–.

About

A modern TypeScript library template with production-ready tooling and best practices.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published