A modern TypeScript monorepo starter template with best practices for scalable projects.
- 📦 PNPM for fast, disk-efficient package management
- 🏎️ Turborepo for high-performance build system
- 📦 tsup for fast, zero-config bundling with TypeScript support
- 🔍 Biome for fast linting and formatting
- ⚙️ TypeScript configured with modern Node LTS settings
- 🧪 Vitest for unit testing
- ⚡ Volta for Node.js and package manager version management
- 📝 Commitlint with Conventional Commits
- 🔄 Changesets for versioning and changelogs
- 🚀 GitHub Actions for CI/CD with npm publishing
- 🪝 Husky for Git hooks
ts-monorepo/
├── .changeset/ # Changesets configuration
├── .github/ # GitHub Actions workflows
├── .husky/ # Git hooks
├── packages/ # All packages
│ ├── core/ # Core package
│ ├── utils/ # Utilities package
│ └── feature-a/ # Feature package
├── biome.json # Biome configuration
├── commitlint.config.js # Commitlint configuration
├── package.json # Root package.json
├── pnpm-workspace.yaml # PNPM workspace config
├── tsconfig.json # Base TypeScript config
├── tsup.config.ts # tsup build configuration
├── turbo.json # Turborepo config
└── vitest.config.ts # Vitest config
- Volta for Node.js and pnpm version management (recommended)
-
Clone this repository
git clone https://github.com/yourusername/ts-monorepo.git cd ts-monorepo -
Install Node.js and pnpm (if using Volta, this happens automatically)
# With Volta (recommended) volta install [email protected] [email protected] # Or install manually # Install Node.js 24+ from https://nodejs.org # Install pnpm: npm install -g pnpm
-
Install dependencies
pnpm install
-
Build all packages
pnpm build
# Run all tests
pnpm test
# Run tests in watch mode
pnpm -F "@monorepo/core" test:watch# Lint all packages
pnpm lint
# Format all packages
pnpm formatThis template uses tsup for fast, zero-config bundling with TypeScript support. All packages are built as ESM modules.
# Build all packages
pnpm build
# Build a specific package
pnpm -F "@monorepo/core" build
# Watch mode for development
pnpm -F "@monorepo/core" devBuild Configuration:
- Output: ESM modules (
dist/index.js) - Types: Generated automatically (
dist/index.d.ts) - Source maps: Included for debugging
- Tree shaking: Enabled for optimal bundle size
-
Create a new branch
git checkout -b feature/my-feature
-
Make your changes
-
Commit your changes using conventional commits
git commit -m "feat: add new feature" -
Add a changeset to document your changes
pnpm changeset
-
Push your branch and create a pull request
Releasing is handled automatically through GitHub Actions when changes are merged to the main branch:
- The workflow runs tests, type checking, and builds to ensure quality
- Changesets creates a PR to bump versions and update changelogs
- When the PR is merged, packages are published to npm
By default, all packages are marked as "private": true to prevent accidental publishing. To publish packages to npm:
- In the package's
package.json, change"private": trueto"private": false - Add a
publishConfigsection:"publishConfig": { "access": "public" }
- Generate an npm access token with publish permissions from npmjs.com
- Add the token as a repository secret named
NPM_TOKENin GitHub (Settings → Secrets and variables → Actions) - Ensure your package names are unique in the npm registry or use a scoped package name
Note: The release workflow only runs after the CI workflow succeeds on the main branch.
- Create a new folder in the
packagesdirectory - Add a
package.jsonwith appropriate dependencies - Add a
tsconfig.jsonthat extends from the root - Update root
tsconfig.jsonwith path mappings for the new package
Packages can depend on each other using the workspace protocol:
"dependencies": {
"@monorepo/core": "workspace:*"
}This template follows Semantic Versioning at the repository level:
- Git tags:
v1.0.0,v1.1.0,v2.0.0(for template releases) - Package versions: Remain at
0.1.0by default (customize after cloning)
Version bumps:
- MAJOR: Breaking changes to template structure or tooling
- MINOR: New features, examples, or improvements
- PATCH: Bug fixes, documentation updates
See AGENTS.md for detailed versioning strategy.