A modern TypeScript module template with comprehensive tooling for development, building, and publishing.
- 🚀 TypeScript - Full TypeScript support with modern ES2024 target
- 📦 Dual Package - Supports both CommonJS and ESM formats
- 🔧 Build System - Fast builds with tsup
- 🎯 Linting - ESLint with TypeScript, Prettier, and JSON/Markdown support
- 🪝 Git Hooks - Automated linting and commit message validation with Husky
- 📋 Conventional Commits - Enforced commit message format
- 🔄 Automated Releases - Scripts for GitHub and NPM releases
- 📝 Changelog Generation - Automatic changelog generation
- 🧪 Testing Ready - Test directory structure included
# Clone the template
git clone https://github.com/vrdons/module-template.git
cd module-template
# Install dependencies
npm install# Build the project
npm run build
# Lint code
npm run lint
# Fix linting issues
npm run lint:fixmodule-template/
├── src/ # Source code
│ └── index.ts # Main entry point
├── dist/ # Built output (generated)
├── tests/ # Test files
├── scripts/ # Build and automation scripts
│ ├── actions/ # GitHub Actions and release scripts
│ ├── husky/ # Git hook scripts
│ └── utils/ # Utility functions
├── .github/ # GitHub workflows
├── .husky/ # Husky git hooks
└── ...config files
| Script | Description |
|---|---|
npm run build |
Build the project with tsup |
npm run lint |
Run ESLint on all files |
npm run lint:fix |
Fix ESLint issues automatically |
npm run changelog |
Generate changelog from commits |
npm run release:git |
Create GitHub release |
npm run release:npm |
Publish to NPM |
The project uses modern TypeScript configuration with:
- Target: ES2024
- Module: NodeNext with full ESM/CJS interop
- Output: Dual package (ESM + CJS) with type declarations
tsup is configured to:
- Bundle TypeScript source code
- Generate both ESM and CJS formats
- Create type declaration files
- Clean output directory on each build
- Run post-build patches
- ESLint: TypeScript, Prettier, JSON, and Markdown linting
- Prettier: Code formatting with consistent style
- Husky: Pre-commit hooks for linting and commit message validation
- Commitlint: Enforces conventional commit format
The module supports both CommonJS and ESM imports:
// ESM
import { version } from 'module-template';
// CommonJS
const { version } = require('module-template');- Make changes to source code in
src/ - Build with
npm run build - Lint with
npm run lint - Commit using conventional commit format
- Release with automated scripts
This project follows Conventional Commits:
type(scope): description
feat: add new feature
fix: resolve bug
docs: update documentation
style: formatting changes
refactor: code restructuring
test: add tests
chore: maintenance tasks
npm run release:gitnpm run release:npmMIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Follow the commit message format
- Submit a pull request
vrdons - GitHub Profile
This template provides a solid foundation for TypeScript modules with modern tooling and best practices. Customize it according to your project's specific needs.