This is a comprehensive TypeScript library template designed to jumpstart your npm package development with modern tooling, best practices, and production-ready configurations.
- 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
- 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
- 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
- pnpm - Fast, disk space efficient package manager
- Node.js 20+ - Modern Node.js runtime support
- ESM/CJS dual exports - Support for both module systems
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
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 URLsREADME.md
- Title, badges, and linksSECURITY.md
- Security policy referencesCONTRIBUTING.md
- Clone command.github/workflows/reusable-test.yml
- Codecov slug
pnpm install
Create a src
directory and start building your library:
mkdir src
echo "export const hello = () => 'Hello, World!';" > src/index.ts
# Run tests
pnpm test
# Build your library
pnpm build
# Lint and format
pnpm lint:fix
pnpm format:fix
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.
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 |
- Strict mode enabled
- ESNext target and module
- Declaration files generated
- Source maps included
- CommonJS (
dist/index.js
) - ES Modules (
dist/index.mjs
) - TypeScript declarations (
dist/index.d.ts
) - Minified for production
- Global test environment
- Node.js environment
- Coverage thresholds configured
- HTML and LCOV reports
The template includes automated publishing workflows:
- Manual publish - Trigger releases manually
- Version management - Automated version bumping
- NPM publishing - Secure token-based publishing
- GitHub releases - Automatic release notes
- β 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
See the CONTRIBUTING.md document.
- I want to say thank you to the best woman in the world, my wife Diana for her love, daily support, motivation and inspiration.
If you are enjoying this work and feel extra appreciative, you could buy me a book π or 3 πππ.