This document outlines the successful migration from Yarn to Pnpm for the native-widgets monorepo.
- Performance: Pnpm is generally faster than Yarn, especially for large monorepos
- Disk Space: Pnpm uses hard links and symlinks to save disk space
- Strict Dependencies: Better peer dependency handling
- Active Development: Pnpm has active development and regular updates
-
Removed Yarn-specific files:
.yarn/directory and contentsyarn.lock.yarnrc.yml
-
Created pnpm configuration files:
pnpm-workspace.yaml- Defines workspace structure- Updated
.npmrcwith pnpm-specific settings
-
Updated
package.json:- Changed
packageManagerfromyarn@4.5.1topnpm@9.15.0 - Replaced
resolutionswithpnpm.overrides - Updated
workspacesformat for pnpm compatibility - Converted all Yarn workspace commands to pnpm equivalents
- Changed
Root package.json scripts converted from Yarn to Pnpm:
yarn workspaces foreach→pnpm -ryarn cache clean→pnpm store prunepatch-package --use-yarn→patch-package- Various other script command updates
Updated JavaScript files:
scripts/validation/validate-versions-staged-files.jsscripts/widget/buildWidgets.jsscripts/test/e2e-native.js
GitHub Actions workflows updated:
.github/workflows/UnitTests.yml.github/workflows/Build.yml.github/workflows/Release.yml.github/workflows/MarketplaceRelease.yml.github/workflows/NativePipeline.yml
Key changes in workflows:
- Removed Yarn-specific setup and caching
- Added pnpm action setup with version 10.13.1
- Updated cache keys to use
pnpm-lock.yaml - Replaced Yarn workspace commands with pnpm equivalents
Updated files:
README.md- Installation and usage instructionsCONTRIBUTING.md- Development setup instructions
.npmrc updated with pnpm-specific settings:
strict-peer-dependencies=falseshamefully-hoist=true- Hoist patterns for eslint, prettier, and @types
- Workspace linking preferences
| Operation | Yarn | Pnpm |
|---|---|---|
| Install dependencies | yarn or yarn install |
pnpm install |
| Run script in all workspaces | yarn workspaces foreach --all run <script> |
pnpm -r run <script> |
| Run script with filtering | yarn workspaces foreach --since run <script> |
pnpm -r run <script> --filter=<pattern> |
| Run script in specific workspace | yarn workspace <name> run <script> |
pnpm --filter=<name> run <script> |
| Clear cache | yarn cache clean |
pnpm store prune |
The migration was tested by:
- Successfully running
pnpm install - Executing
pnpm run lint:srcto verify script functionality - All packages (1666) were installed successfully
- Workspace commands work as expected
- Install pnpm globally:
npm install -g pnpm - Remove local
node_modulesand runpnpm install