Skip to content

feat(patch): support npm: registry aliases in npm patch - #10007

Open
manzoorwanijk wants to merge 3 commits into
npm:latestfrom
manzoorwanijk:feat/patch-add-npm-alias
Open

manzoorwanijk wants to merge 3 commits into
npm:latestfrom
manzoorwanijk:feat/patch-add-npm-alias

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Contributor

npm patch add <alias> for an npm: registry alias looked the alias name up as a real package, so it fetched the wrong tarball or failed. This PR makes add, commit and update fetch the alias target's tarball while keying the selector and patch file on the alias name, which is what the install engine matches.

  • add accepts the alias name (my-lodash) or the full spec (my-lodash@npm:lodash@4.17.21) and resolves the real package from the installed nodes or the declared npm: spec (patch.js).
  • The edit dir gets a .npm-patch-alias.json marker so commit writes my-lodash@<version>. The marker is left out of the diff and checked against the edited package.
  • update rebases the real package's tarballs and keeps the marker through a conflicted rebase.
  • A name installed as two different packages at one version fails with EPATCHAMBIGUOUS, and an explicit alias that disagrees with the installed package fails with EPATCHALIAS.
  • npm patch add lodash suggests the alias name when lodash is installed only through an alias.
  • Documented alias usage in npm-patch.md.

References

Follow-up to #9439

@manzoorwanijk
manzoorwanijk marked this pull request as ready for review September 21, 2026 07:48
@manzoorwanijk
manzoorwanijk requested a review from a team as a code owner September 21, 2026 07:48
@manzoorwanijk

Copy link
Copy Markdown
Contributor Author

CC: @reggi @martinrrm

@manzoorwanijk
manzoorwanijk force-pushed the feat/patch-add-npm-alias branch from 6cb729a to d7b9740 Compare October 5, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant