A comprehensive demonstration of pnpm workspaces featuring shared packages, TypeScript configuration, and modern development tools.
├── apps/
│ ├── web-app/ # React frontend with Vite & Tailwind
│ └── api-server/ # Express.js API server
├── packages/
│ ├── utils/ # Shared utility functions
│ ├── ui-components/ # React component library
│ └── api-client/ # HTTP client for API communication
├── tools/
│ └── eslint-config/ # Shared ESLint configuration
├── pnpm-workspace.yaml # Workspace configuration
└── package.json # Root package configuration
-
Install dependencies:
pnpm install
-
Build all packages:
pnpm build
-
Start development servers:
# Terminal 1: Start API server pnpm dev:api # Terminal 2: Start web app pnpm dev:web
-
Open your browser:
- Web App: http://localhost:3000
- API Server: http://localhost:3001
Shared utility functions including:
- Currency formatting
- Debounce function
- String slugification
- Logger class
- API response types
React component library with:
- Button component (multiple variants)
- Card component
- TypeScript definitions
- Tailwind CSS styling
HTTP client for API communication:
- Axios-based client with interceptors
- UserService with CRUD operations
- Error handling and logging
- TypeScript interfaces
pnpm install- Install all dependenciespnpm build- Build all packagespnpm dev:web- Start web app in development modepnpm dev:api- Start API server in development modepnpm lint- Lint all packagespnpm type-check- Type check all packagespnpm clean- Clean all build outputs
# Build specific package
pnpm --filter @monorepo/utils build
# Run tests for specific package
pnpm --filter @monorepo/ui-components test
# Add dependency to specific package
pnpm --filter @monorepo/web-app add lodash- Make changes to any package
- Build dependencies if needed:
pnpm build - Start development servers to see changes
- Lint and type-check:
pnpm lint && pnpm type-check
- TypeScript: Full TypeScript support with shared configuration
- Hot Reloading: Fast development with Vite and tsx
- Shared Dependencies: Efficient dependency management with pnpm
- Modern Tooling: ESLint, Tailwind CSS, tsup bundling
- Workspace Protocol: Inter-package dependencies using
workspace:* - Monorepo Scripts: Coordinated build and development scripts
This project demonstrates the concepts covered in the blog post: "Mastering pnpm Workspaces: A Complete Guide to Monorepo Management"
Key concepts showcased:
- Workspace configuration
- Package interdependencies
- Shared tooling configuration
- Development workflow optimisation
- TypeScript path mapping
- Build coordination
- Fork the repository
- Create a feature branch
- Make your changes
- Run
pnpm lint && pnpm type-check - Submit a pull request