-
-
Notifications
You must be signed in to change notification settings - Fork 638
Description
Question
Should we update Yarn to the latest version? Does yalc work with latest Yarn? What are the pros and cons? Is now the right time to do this?
Current Status
- Current version: Yarn 1.22.22 (Yarn Classic) - Already the latest Yarn Classic version
- Latest Yarn Modern: Yarn 4.x (Berry)
- Monorepo structure: 3 publishable npm packages + multiple test environments using yalc
Our 3 Publishable Packages
react-on-rails(packages/react-on-rails)react-on-rails-pro(packages/react-on-rails-pro)react-on-rails-pro-node-renderer(react_on_rails_pro/ root)
Test Environments Using yalc Links
spec/dummy/→ usesreact-on-railsreact_on_rails_pro/spec/dummy/→ usesreact-on-rails-pro+react-on-rails-pro-node-rendererreact_on_rails_pro/spec/execjs-compatible-dummy/→ usesreact-on-rails
Yalc Compatibility with Yarn Modern (2/3/4)
Key Findings
- Basic compatibility: Yalc can work with Yarn 2/3/4, but with caveats
- Critical limitation: Yalc requires
node_modulesto work (it creates symlinks and file: dependencies) - PnP incompatibility: Yarn Berry's default Plug'n'Play (PnP) mode is incompatible with yalc
- Workaround required: To use yalc with Yarn Modern, you'd need to set
nodeLinker: node-modulesin.yarnrc.yml, effectively disabling PnP
Pros of Upgrading to Yarn Modern (4.x)
✅ Performance: Faster installs and better caching
✅ Workspaces: Enhanced monorepo features
✅ Constraints: Better dependency management
✅ Modern standards: Better TypeScript support, ESM handling
✅ Security: Better audit tools
Cons of Upgrading to Yarn Modern (4.x)
❌ Breaking change: Requires significant migration effort
❌ yalc incompatibility: Would need to use nodeLinker: node-modules, losing PnP benefits
❌ Ecosystem friction: Some tools still have better Yarn Classic support
❌ Learning curve: New commands, new config format (.yarnrc.yml)
❌ Project impact: Our docs explicitly say "Only use yarn as the JS package manager, never npm"
❌ CI/CD updates: Would need to update GitHub Actions workflows
❌ Documentation updates: Extensive docs updates needed
Decision: Stay with Yarn Classic 1.22.22
Reasons
- Already on latest Yarn Classic (1.22.22) - no version bump to gain
- yalc is critical to our workflow - extensively used for local development
- Yarn Modern would lose PnP benefits anyway - since we'd need
nodeLinker: node-modulesfor yalc - No urgent need - Yarn Classic 1.22.22 is stable, maintained, and works perfectly
- Risk vs reward - significant migration effort for minimal tangible benefit
- Team disruption - would require retraining, updating docs, breaking contributor workflows
Why Our Current Setup is Optimal
Yarn Workspaces (already configured) + yalc is the best solution:
✅ Yarn Workspaces handles internal dependencies
✅ Shared devDependencies hoisted to root
✅ Single yarn install for entire monorepo
✅ yalc handles test environment linking perfectly
✅ Works with built packages (not TypeScript source)
✅ Proven stable setup that works today
✅ Zero migration cost
When Would Be the Right Time to Upgrade?
Consider upgrading when:
- Yarn Classic becomes unmaintained or has security issues
- We find a yalc alternative that works with Yarn PnP
- A specific feature in Yarn Modern becomes critical to our workflow
- We're doing a major version bump and can justify the breaking change
- The ecosystem has matured enough that Yarn Modern is the clear standard
Alternatives Considered and Rejected
Yarn Modern (Berry):
- ❌ PnP incompatible with yalc
- ❌ Would need
nodeLinker: node-modulesanyway - ❌ Migration effort not justified
npm workspaces:
- ❌ Would violate our "never use npm" policy
- ❌ Not significantly better than Yarn workspaces
pnpm:
- ❌ Different linking strategy might break yalc
- ❌ Not worth the risk for marginal gains
Lerna/Nx/Turborepo:
- ❌ Overkill for 3 packages
- ❌ Yarn workspaces + yalc is simpler and sufficient
Conclusion
Stay with Yarn Classic 1.22.22 + Yarn Workspaces + yalc. This is the optimal solution for our monorepo with 3 packages and multiple interrelated test environments. No changes needed.
References: