A modern, battery-included template for creating JavaScript/TypeScript libraries. This project is configured with best practices for development, testing, linting, and building.
- 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
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Initialize Git hooks:
npm run prepare
Start the development server (using Vite):
npm run devBuild the project for production (ESM, CJS, IIFE):
npm run buildOutput files will be generated in the dist directory.
| 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 |
src/: Source code of the librarydist/: Compiled code (generated after build)test/: Unit tests
This project uses Conventional Commits. When you commit, commitlint will check your commit message.
Format: <type>(<scope>): <subject>
Examples:
feat: add new graph algorithmfix: resolve crash on startupchore: update dependencies
MIT