Skip to content

[Feature Request] Support for Yarn 2 "workspace ranges" #598

@heejongahn

Description

@heejongahn

Affected Packages

@changesets/cli

Problem

First off, thanks for the great tool!

Yarn 2 introduces a feature called workspace ranges.

With workspace ranges, you can specify the intent of "depend on the current version of local workspace package, whatever the actual published version it may be". If you think about the workflow you're simutaneously modifying multiple packages, this can be extremely useful.

The transformation of workspace:... version to actual versions that npm can understand is handled by yarn at publish time.

When a workspace is packed into an archive (whether it's through yarn pack or one of the publish commands like yarn npm publish), we dynamically replace any workspace: dependency by:

  • The corresponding version in the target workspace (if you use * or a project-relative path)
  • The associated semver range (for any other range type)

However, as current changeset publish command only supports either npm or pnpm as publish client, this transformation cannot take place, and changeset publish aborts with:

🦋  error TypeError: Invalid comparator: packages/my-package
🦋  error     at Comparator.parse (/home/runner/work/npm-packages/npm-packages/.yarn/cache/semver-npm-5.7.1-40bcea106b-06ff0ed753.zip/node_modules/semver/semver.js:754:11)
🦋  error     at new Comparator (/home/runner/work/npm-packages/npm-packages/.yarn/cache/semver-npm-5.7.1-40bcea106b-06ff0ed753.zip/node_modules/semver/semver.js:737:8)
🦋  error     at Range.<anonymous> (/home/runner/work/npm-packages/npm-packages/.yarn/cache/semver-npm-5.7.1-40bcea106b-06ff0ed753.zip/node_modules/semver/semver.js:925:12)
🦋  error     at Array.map (<anonymous>)
🦋  error     at Range.parseRange (/home/runner/work/npm-packages/npm-packages/.yarn/cache/semver-npm-5.7.1-40bcea106b-06ff0ed753.zip/node_modules/semver/semver.js:924:13)
🦋  error     at Range.<anonymous> (/home/runner/work/npm-packages/npm-packages/.yarn/cache/semver-npm-5.7.1-40bcea106b-06ff0ed753.zip/node_modules/semver/semver.js:867:17)
🦋  error     at Array.map (<anonymous>)
🦋  error     at new Range (/home/runner/work/npm-packages/npm-packages/.yarn/cache/semver-npm-5.7.1-40bcea106b-06ff0ed753.zip/node_modules/semver/semver.js:866:40)
🦋  error     at versionPackage (/home/runner/work/npm-packages/npm-packages/.yarn/cache/@changesets-apply-release-plan-npm-5.0.0-19ff54c5d1-d43561e831.zip/node_modules/@changesets/apply-release-plan/dist/apply-release-plan.cjs.dev.js:160:9)
🦋  error     at /home/runner/work/npm-packages/npm-packages/.yarn/cache/@changesets-apply-release-plan-npm-5.0.0-19ff54c5d1-d43561e831.zip/node_modules/@changesets/apply-release-plan/dist/apply-release-plan.cjs.dev.js:312:12

Proposed solution

If either

It would be awesome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions