Skip to content

canbax/ts-library-template

Repository files navigation

TypeScript Library Template

A modern, battery-included template for creating JavaScript/TypeScript libraries. This project is configured with best practices for development, testing, linting, and building.

Features

  • Language: TypeScript (~5.8.3)
  • Module Bundler: tsup (Builds ESM, CJS, and IIFE formats)
  • Testing: Vitest
  • Linter: Oxlint (Extremely fast linter)
  • Formatter: Prettier
  • Git Hooks: Husky + lint-staged
  • Commit Convention: Commitlint (Enforces Conventional Commits)
  • Changelog: Automated with conventional-changelog

Getting Started

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
  2. Install dependencies:

    npm install
  3. Initialize Git hooks:

    npm run prepare

Usage

Development server

Start the development server (using Vite):

npm run dev

Building the library

Build the project for production (ESM, CJS, IIFE):

npm run build

Output files will be generated in the dist directory.

Available Scripts

Script Description
npm run dev Starts the dev server
npm run build Builds the library using tsup
npm run test Runs tests once using vitest
npm run test-watch Runs tests in watch mode
npm run lint Lints the codebase using oxlint
npm run format Formats the codebase using prettier
npm run checks Runs format, lint, and test scripts sequentially
npm run changelog Generates a changelog based on conventional commits
npm run prepare Installs Husky git hooks

Project Structure

  • src/: Source code of the library
  • dist/: Compiled code (generated after build)
  • test/: Unit tests

Committing

This project uses Conventional Commits. When you commit, commitlint will check your commit message. Format: <type>(<scope>): <subject>

Examples:

  • feat: add new graph algorithm
  • fix: resolve crash on startup
  • chore: update dependencies

License

MIT

About

A template for creating Typescript libraries using vite, tsup, vitest, oxlint, renovate, husky, conventional commits, conventional change log and lint-staged

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors