Skip to content

Should we upgrade Yarn to latest version? (Analysis & Decision) #2088

@justin808

Description

@justin808

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

  1. react-on-rails (packages/react-on-rails)
  2. react-on-rails-pro (packages/react-on-rails-pro)
  3. react-on-rails-pro-node-renderer (react_on_rails_pro/ root)

Test Environments Using yalc Links

  • spec/dummy/ → uses react-on-rails
  • react_on_rails_pro/spec/dummy/ → uses react-on-rails-pro + react-on-rails-pro-node-renderer
  • react_on_rails_pro/spec/execjs-compatible-dummy/ → uses react-on-rails

Yalc Compatibility with Yarn Modern (2/3/4)

Key Findings

  1. Basic compatibility: Yalc can work with Yarn 2/3/4, but with caveats
  2. Critical limitation: Yalc requires node_modules to work (it creates symlinks and file: dependencies)
  3. PnP incompatibility: Yarn Berry's default Plug'n'Play (PnP) mode is incompatible with yalc
  4. Workaround required: To use yalc with Yarn Modern, you'd need to set nodeLinker: node-modules in .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

  1. Already on latest Yarn Classic (1.22.22) - no version bump to gain
  2. yalc is critical to our workflow - extensively used for local development
  3. Yarn Modern would lose PnP benefits anyway - since we'd need nodeLinker: node-modules for yalc
  4. No urgent need - Yarn Classic 1.22.22 is stable, maintained, and works perfectly
  5. Risk vs reward - significant migration effort for minimal tangible benefit
  6. 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-modules anyway
  • ❌ 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions