yarnpkg / yarnpkg/berry

[Feature Request] Forked packages aliasing peerDependencies

Open
#883 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
8.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

  • I'd be willing to implement this feature
  • This feature can already be implemented through a plugin

Describe the user story

A common pattern I have seen is packages will drop out of maintenance, or a feature won't be implemented by the maintainer, so forks are create that address said issues and are published as separate "aliased" packages. The problem arises when another package has a peerDependency on the original package, but you are now using the aliased package. For example semantic-release-plus is a maintained fork of semantic-release but the semantic-release plugins all have peerDependencies for the original. My initial thought to get around this problem was to use "semantic-release": "npm:semantic-release-plus" which I believe would work if the semver versions match up. But in this case the plugins require <18 but semantic-release-plus is at 18 so the following warnings are logged:
image

Describe the solution you'd like

Allow a fork package to provide the original package version it is based on, so semantic-release-plus could provide a field in its package.json file that specifies the alternative package it is trying to alias e.g: "alias": "semantic-release@17"

Describe the drawbacks of your solution

Forked packages providing the wrong aliased version could lead to compatibility issues that are not flagged due to the warning suppression.

Describe alternatives you've considered

I considered a new protocol could solve this problem, where a target version could be specified for the aliased version to satisfy. So in the case described above perhaps it could be alias(17):semantic-release-plus@18. However, this would require the user to know what version of the original package the "aliased" version is compatibly with, so would likely lead to confusion.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by studying Yarn's peerDependency behavior and the proposed package.json alias field, using the semantic-release example as the reference case; done should mean forked packages can declare a compatible original package version without inappropriate peer-dependency warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.