-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for workspace:^
in peerDependencies
#3386
Conversation
cc @gaetanmaisse since you wanted this in storybookjs/storybook#15413 (comment) |
% This rule enforces that all workspaces must depend on other workspaces using `workspace:^` in peerDependencies | ||
gen_enforced_dependency(WorkspaceCwd, DependencyIdent, 'workspace:^', 'peerDependencies') :- | ||
workspace_has_dependency(WorkspaceCwd, DependencyIdent, _, 'peerDependencies'), | ||
% Only consider those that target something that could be a workspace | ||
workspace_ident(DependencyCwd, DependencyIdent). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not strictly required to fulfil the goal of this PR but we should be able to remove the two constraints above this and make this one target all dependency types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I didn't want to make the diff too large, but I'll do it as soon as it gets merged.
Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>
What's the problem this PR addresses?
It's currently impossible to use the pack-time workspace version management to let Yarn inject the right version number for inter-workspaces peer dependencies when publishing a package. As a result, merging release branches lead to painful merge conflicts.
How did you fix it?
The
peerDependencies
field now accepts theworkspace:
specifier (only with a semver range; relative workspace paths aren't supported unlike other dependency types). When found, Yarn will check that the inherited peer dependency is a workspace, and that it matches the specified range.Additionally, the
workspace:^
,workspace:~
, andworkspace:*
specifiers are now supported as well and will be replaced at publish time by respectively^1.0.0
,~1.0.0
, and1.0.0
(assuming the target workspace is version1.0.0
).One option I initially considered was to just accept
^
and~
as aliases for*
. However I eventually decided against it since it would depart from the syntax used in dependencies/peer dependencies. Still, to be completely clear, this improvement doesn't change that peer dependencies don't/cannot enforce the source of a peer dependency in any general term (for example, you can't enforce that the peer dependency must be filled via afile:
dependency). Workspaces are quite special to many aspects, and this is one of them - it doesn't change the general rule.Checklist