Skip to content

fix(yarn): parse grouped lockfile keys resolving to one version - #60

Merged
ai merged 3 commits into
ai:mainfrom
ymandrikov:ym/fix/issue-55-berry-grouped-keys
Jul 18, 2026
Merged

ai merged 3 commits into
ai:mainfrom
ymandrikov:ym/fix/issue-55-berry-grouped-keys

Conversation

@ymandrikov

@ymandrikov ymandrikov commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Yarn writes several descriptors that resolve to the same package as one comma-separated lockfile entry:

"caniuse-lite@npm:^1.0.30001702, caniuse-lite@npm:^1.0.30001746": <------------ this
      version: 1.0.30001750
      resolution: "caniuse-lite@npm:1.0.30001750"

Loader gives this whole string to splitPackage. It looks for last @, but does not know about comma, so it cuts in wrong place and returns caniuse-lite@^1.0.30001702, caniuse-lite. This is not real package so registry returns an error.

Fix is to read the name from the package that was actually installed.

  • Berry: use the resolution locator, not the key.
  • yarn classic: no locator, so use the first descriptor; the group shares one ident.

Read more at #55.

Fixes #55

Grouped Berry keys like
"caniuse-lite@npm:^1.0.30001702, caniuse-lite@npm:^1.0.30001746"
were passed to splitPackage, whose last-@ search crossed the descriptor
boundary and produced a malformed name that 404'd on npm download.

Derive the name from the entry's resolution locator instead, which
always holds the single resolved package.

Closes ai#55
Grouped Yarn 1 keys like
"@scope/pkg@^1.0.0", "@scope/pkg@^2.0.0"
were passed whole to splitPackage, whose last-@ search crossed the
descriptor boundary and produced a malformed name that 404'd on npm
download.

Yarn 1 has no resolution locator, so derive the name from the first
grouped descriptor; every descriptor in a group shares one package ident.

Refs ai#55
@ai
ai merged commit 3bb4ec4 into ai:main Jul 18, 2026
3 checks passed
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.

yarn.lock (berry) files are not properly parsed when multiple dependencies were resolved to a single version

2 participants