No results found

Adding or Changing a Package

This monorepo uses PNPM Workspaces, TypeScript Project References, and Vite to manage dependencies and build processes. When adding a new local package (e.g., in the libs/ directory) or changing how packages depend on each other, several configuration files need updates.

1. Root tsconfig.json

The root tsconfig.json file defines base TypeScript settings and path aliases.

2. Package tsconfig.json

Each local package needs its own tsconfig.json.

3. Package Dependencies (package.json)

In the package.json of any package that needs to use another local package:

4. Vite Configuration (apps/docs/vite.config.ts)

The Vite configuration for the consuming application (apps/docs) is critical for development, especially for Hot Module Replacement (HMR).

Maintaining the resolve.alias in apps/docs/vite.config.ts is the key step to ensure HMR works correctly when editing files within the libs/* packages during development.

5. Vitest Configuration (apps/docs/vitest.config.ts)

For testing with Vitest, we need to ensure proper path resolution for local packages:

This ensures that tests can properly resolve imports from local packages in the monorepo.

Further Learning