-
Notifications
You must be signed in to change notification settings - Fork 762
Description
Affected Packages
@changesets/cli
Problem
Publishing with yarn should be done via yarn npm publish but @changesets/cli is using npm publish instead. This means some workspaces features that are yarn specific do not work as expected. For instance, when publishing with yarn npm publish yarn replaces inner packages with version workspace:^ with the correct version. While when publishing with npm publish npm ignores packages with version workspace:^. This results in incorrectly published packages because when installing it package managers won't be able to resolve workspace:^.
I believe the above is also the reason why .yarnrc.yml is ignored when publishing via changesets.
This is simple to reproduce:
- In a monorepo managed by yarn create packages "@example/a" and "@example/b".
- The package.json of @example/a contains @example/b as a dependency:
"dependencies": {
"@example/b": "workspace:^"
}
- Create a changeset for @example/a.
- Generate the new versions via
changeset version. - Then publish via
changeset publish. - Now install the new version in a new project and check the package.json in the
node_modulesand also the new info added toyarn.lock. You'll seeworkspace:^hasn't been replaced.
Related issues:
- [CLI]: yarn changeset publish is not attempting to publish with yarn #1411
- Error with GitHub registery #650
Proposed solution
The proposed solution is to use yarn npm publish instead of npm publish. I tested this out in a private monorepo and it works. I also opened a PR for this change here and would like help getting it reviewed and approved.
This issue is pretty urgent for us at my company. Any guidance on how to move this forward would be very much appreciated.