Monorepo Structure
The WooCommerce monorepo contains:- Backend: PHP in
plugins/woocommerce/(PSR-4, WordPress standards) - Admin Client: React/TypeScript in
client/admin/ - JavaScript Packages: Reusable packages in
packages/js/* - PHP Packages: Composer packages in
packages/php/* - Development Tools: Build and automation tools in
tools/*
Workspace Configuration
The monorepo uses pnpm workspaces defined inpnpm-workspace.yaml:
pnpm-workspace.yaml
Root Package Configuration
The rootpackage.json defines monorepo-wide scripts and dependencies:
package.json
The monorepo uses pnpm 9.15.0 as the package manager. Make sure you have the correct version installed.
PNPM Workspaces
PNPM workspaces enable efficient dependency management across all packages.Filtering Packages
Use the--filter flag to run commands on specific packages:
Workspace Dependencies
Packages can depend on other workspace packages:The
workspace:* protocol ensures packages use local versions during development and resolves to actual versions when published.Build System
The monorepo uses multiple build tools depending on the package type.JavaScript Build Tools
JavaScript packages use a combination of:- Webpack: For bundling client applications
- TypeScript: For type-safe JavaScript
- Wireit: For incremental builds and caching
- Babel: For JavaScript transpilation
PHP Build Tools
PHP packages use:- Composer: For PHP dependencies
- PHPStan: For static analysis
- PHPCS: For code style checking
- PHPUnit: For testing
Build Commands
- Build All
- Build Specific Package
- Clean Build
Package Dependencies
The monorepo manages dependencies at multiple levels.Dependency Resolution
PNPM creates a singlenode_modules structure with symlinks:
Shared Dependencies
Common dependencies are hoisted to the root to save disk space:package.json
Version Synchronization
The monorepo uses syncpack to keep dependencies aligned:Development Scripts
Common development tasks have dedicated scripts.Testing Scripts
Linting Scripts
Changelog Scripts
Development Tools
Thetools/ directory contains utilities for monorepo development.
Monorepo Utils
Command-line tools for common tasks:Code Analyzer
Analyze code changes and dependencies:Cherry Pick Tool
Backport changes between branches:Common Workflows
1
Clone and Install
2
Build Everything
3
Start Development Environment
4
Make Changes and Test
5
Create Changelog
Package Organization
JavaScript Packages (packages/js/)
@woocommerce/components: Reusable React components@woocommerce/data: Data stores and API client@woocommerce/navigation: Navigation utilities@woocommerce/date: Date manipulation utilities@woocommerce/currency: Currency formatting- And many more…
PHP Packages (packages/php/)
@woocommerce/blueprint: Blueprint specifications@woocommerce/email-editor: Email customization@woocommerce/remote-specs-validation: Remote spec validation
Plugins
@woocommerce/plugin-woocommerce: WooCommerce Core@woocommerce/woocommerce-beta-tester: Beta testing plugin
Performance Optimization
Incremental Builds
Wireit enables incremental builds:Parallel Execution
PNPM runs independent tasks in parallel:Build Caching
Wireit caches build outputs to skip unchanged packages:Build caches are stored in
.wireit directories. These are automatically cleaned by pnpm clean.Troubleshooting
Clean Installation
If you encounter dependency issues:Lock File Issues
If pnpm-lock.yaml gets out of sync:Build Failures
If builds fail after pulling changes:Next Steps
Architecture
Understand WooCommerce’s overall architecture
Modern vs Legacy
Learn about code organization patterns