An open API service indexing awesome lists of open source software.

https://github.com/runespoor-engineering/ts-lib-template

A modern TypeScript library template with production-ready tooling and best practices.
https://github.com/runespoor-engineering/ts-lib-template

biomejs library package template tsup typescript vitest

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

          


@runespoorstack/{lib-name}


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




Buy Me A Coffee



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:

```bash
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**

```bash
pnpm install
```

### 4. **Create your library**

Create a `src` directory and start building your library:

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

### 5. **Start developing**

```bash
# 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](https://github.com/runespoor-engineering/runespoorstack/blob/main/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](https://bmc.link/borisshulyak)
๐Ÿ“– or 3 ๐Ÿ“–๐Ÿ“–๐Ÿ“–.