This repository provides a robust starter template for building TypeScript libraries, featuring a comprehensive development setup for building, testing, linting, and documentation. It leverages a monorepo structure for efficient management of multiple packages.
- TypeScript: Strongly typed JavaScript for enhanced code quality and maintainability.
- Unbuild: A powerful and flexible build system for TypeScript libraries, configured for clean builds and declaration generation.
- Vitest: A fast and modern testing framework with built-in coverage reporting.
- Ultracite & Biome: Integrated for lightning-fast formatting and linting, ensuring consistent code quality and adherence to best practices.
- Moon: A high-performance monorepo management tool that orchestrates builds, tests, and other tasks across workspaces.
- Astro + Starlight: A modern static site generator for creating beautiful, performant, and accessible documentation.
- Clone the repository:
pnpx giget gh:DanSnow/typescript-library-starter cd typescript-library-starter - Install dependencies using pnpm:
pnpm install
This project uses moon to manage tasks across the monorepo.
To build the core library:
pnpm build # or moon run buildThis command uses unbuild to compile the TypeScript source code into dist/ directory.
To run tests for the library:
pnpm test # or moon run testThis command uses vitest to execute tests and generate coverage reports.
This project uses Biome with Ultracite rules for code formatting and linting.
To check for linting issues and format the code:
pnpm biome check --write --unsafeThe documentation site is built with Astro and Starlight.
-
To start the local development server for the documentation:
cd docs pnpm devThe documentation will be available at
http://localhost:4321. -
Documentation files are located in
docs/src/content/docs/. You can add new.mdor.mdxfiles here.
.
├── docs/ # Astro + Starlight documentation site
├── src/ # Core library source code
│ ├── __tests__/ # Vitest test files
│ └── index.ts # Main entry point for the library
├── biome.jsonc # Biome configuration, extending Ultracite rules
├── build.confg.ts # Unbuild configuration for library compilation
├── moon.yml # Moon monorepo task runner configuration
├── package.json # Root package.json with project metadata and scripts
├── pnpm-lock.yaml # pnpm lockfile
├── pnpm-workspace.yaml # pnpm workspace configuration for monorepo
├── tsconfig.json # TypeScript configuration for the root project
└── vitest.config.ts # Vitest configuration for testing
This project is licensed under the MIT License.