A production-ready starter template for creating modern NPM packages with TypeScript, featuring comprehensive tooling for testing, formatting, type-checking, and automated releases.
Give a βοΈ if this project helped you build better NPM packages!
- π¦ TypeScript 5.9+ - Proper TypeScript support
- β‘ tsdown - Rust based Lightning-fast builds
- π Export Validation - Ensure package exports work correctly with @arethetypeswrong/cli
- π Dual Module Format - Full CommonJS and ESM support for maximum compatibility
- π§ͺ Vitest
- π¨ Prettier - Consistent code formatting with all necessary rules
- π§ ESLint - TypeScript-aware linting with type-checked rules
- π size-limit - Monitor and control bundle size
- πͺ Husky + lint-staged - Pre-commit hooks for automatic formatting and linting
- β Commitlint - Enforce conventional commits for better changelogs
- π Changesets - Automated version management and changelog generation
- π€ GitHub Actions - Complete CI/CD pipeline for testing and releases
- π Dependabot - Weekly automated dependency updates with proper grouping
- π TypeDoc - Auto-generated API documentation from JSDoc comments
- π VS Code Integration - Debug configurations and recommended extensions
- π Security Audits - Automated dependency scanning
# Clone this repository
git clone https://github.com/yeasin2002/npm-starter.git
# Navigate to the directory
cd npm-starter
# Install dependencies (supports npm, yarn, pnpm, or bun)
pnpm install# Run tests in watch mode
pnpm run dev
# Build the package
pnpm run build
# Run type checking
pnpm run lint
# Run tests
pnpm run test| Script | Description |
|---|---|
pnpm run dev |
Run tests in watch mode |
pnpm run build |
Build the package (CJS + ESM + types) |
pnpm run clean |
Remove build artifacts and caches |
pnpm run typecheck |
Run TypeScript type checking |
pnpm run typecheck:watch |
Run type checking in watch mode |
| Script | Description |
|---|---|
pnpm run test |
Run all tests once |
pnpm run test:watch |
Run tests in watch mode |
pnpm run test:coverage |
Run tests with coverage report |
| Script | Description |
|---|---|
pnpm run lint |
Run ESLint and TypeScript checks |
pnpm run lint:fix |
Auto-fix linting issues |
pnpm run format:write |
Format code with Prettier |
pnpm run format:check |
Check code formatting |
pnpm knip |
Declutter unused dependencies |
| Script | Description |
|---|---|
pnpm run docs |
Generate API documentation |
pnpm run docs:watch |
Generate docs in watch mode |
| Script | Description |
|---|---|
pnpm run audit |
Run security audit on dependencies |
pnpm run size |
Check bundle size |
pnpm run size:why |
Analyze bundle size with details |
| Script | Description |
|---|---|
pnpm run check-exports |
Validate package exports |
pnpm run ci |
Run full CI pipeline |
pnpm run local-release |
Version and publish locally |
pnpm run release |
Publish to npm (used by CI) |
npm-starter/
βββ .changeset/ # Changeset configuration and pending changes
βββ .github/
β βββ workflows/
β β βββ ci.yml # CI/CD pipeline
β β βββ release.yml # Automated releases
β β βββ security.yml # Security audits
β βββ dependabot.yml # Dependency update configuration
βββ .husky/ # Git hooks (pre-commit, commit-msg)
βββ .kiro/ # Kiro AI assistant configuration
β βββ steering/ # Project-specific AI guidance
βββ .vscode/ # VS Code settings and debug configs
βββ src/
β βββ index.ts # Main entry point (re-exports all public APIs)
β βββ utils.ts # Example utilities
βββ test/
β βββ utils.test.ts # Vitest test files
βββ dist/ # Build output (generated, gitignored)
β βββ index.cjs # CommonJS bundle
β βββ index.js # ESM bundle
β βββ index.d.ts # TypeScript declarations
βββ docs/ # Generated API documentation (gitignored)
βββ coverage/ # Test coverage reports (gitignored)
βββ package.json # Package metadata and scripts
βββ tsconfig.json # TypeScript compiler options
βββ tsdown.config.ts # Build configuration
βββ vitest.config.ts # Test configuration
βββ eslint.config.js # Linting rules
βββ .prettierrc # Code formatting rules
βββ .lintstagedrc.json # Pre-commit hook configuration
βββ commitlint.config.js # Commit message linting
βββ README.md
# 1. Create a changeset
npx changeset
# 2. Version packages
pnpm run local-release
# The package will be automatically published when you push# Build and verify
pnpm run ci
# Publish to npm
pnpm publishNote: The
prepublishOnlyscript ensures all checks pass before publishing.
Edit package.json:
{
"name": "your-package-name",
"version": "0.0.1",
"description": "Your package description",
"keywords": ["keyword1", "keyword2"],
"author": "Your Name <your.email@example.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/username/repo.git"
},
"homepage": "https://github.com/username/repo"
}Build settings (tsdown.config.ts):
- Add/remove output formats
- Configure external dependencies
- Adjust bundling options
TypeScript options (tsconfig.json):
- Change target/lib versions
- Adjust strictness levels
- Modify path mappings
ESLint (eslint.config.js):
- Add custom rules
- Configure type-checking behavior
- Adjust ignore patterns
Prettier (.prettierrc):
- Change formatting preferences
- Adjust line width, quotes, semicolons
# Production dependencies (bundled with your package)
pnpm add package-name
# Development dependencies (build tools, testing)
pnpm add -D package-name
# Peer dependencies (required by consumers)
# Add to peerDependencies in package.json# Clean all build artifacts and caches
pnpm run clean
# Reinstall dependencies
rm -rf node_modules pnpm-lock.yaml
pnpm install# Run type checking with detailed output
pnpm run typecheck
# Check for export issues
pnpm run check-exports# Run tests with verbose output
pnpm run test -- --reporter=verbose
# Run specific test file
pnpm run test- TypeScript Handbook
- Vitest Documentation
- tsdown Documentation
- Changesets Guide
- Conventional Commits
- Total TypeScript - NPM Package Guide
MIT License - see the LICENSE file for details.
Md Kawsar Islam Yeasin
- Email: mdkawsarislam2002@gmail.com
- Website: yeasin2002.vercel.app
- GitHub: @yeasin2002
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
See the issues page for known issues and feature requests.