Skip to content

feat(yarn-cling): support yarn berry lockfiles using @yarnpkg/parsers#1319

Merged
mrgrain merged 6 commits intomainfrom
mrgrain/feat/yarn-cling/berry-lockfile-support
Apr 7, 2026
Merged

feat(yarn-cling): support yarn berry lockfiles using @yarnpkg/parsers#1319
mrgrain merged 6 commits intomainfrom
mrgrain/feat/yarn-cling/berry-lockfile-support

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Apr 7, 2026

yarn-cling previously only understood yarn classic (v1) lockfiles via the @yarnpkg/lockfile package. Repos that are migrating to yarn berry (v2/v3/v4) use a different lockfile format, which caused shrinkwrap generation to silently produce incomplete output since none of the dependencies were resolved from the lockfile.

This replaces @yarnpkg/lockfile with @yarnpkg/parsers, the official parser package from the yarn berry project. @yarnpkg/parsers handles both v1 and berry lockfile formats, so we no longer need two separate parser dependencies. For berry lockfiles, a conversion step maps the berry-specific fields (resolutionresolved, checksumintegrity) and npm: prefixed descriptor keys to the classic YarnLock interface used by the rest of the pipeline.

Additionally replaces the deprecated fs.exists usage with the existing fileExists helper based on fs.stat.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

… yarn berry (v2+) YAML lockfiles by checking\nfor the __metadata header. Convert berry format keys (npm: prefix),\nchecksum, and resolution fields to the classic YarnLock interface\nso the rest of the shrinkwrap generation pipeline works unchanged.
@aws-cdk-automation aws-cdk-automation requested a review from a team April 7, 2026 10:32
@github-actions github-actions bot added the p2 label Apr 7, 2026
…\n\nUse @yarnpkg/parsers for both v1 and berry lockfiles, removing the\n@yarnpkg/lockfile and @types/yarnpkg__lockfile dependencies entirely.\nRename parseBerryLockfile to convertBerryToClassicLock to reflect that\nit converts already-parsed data. Use Object.create(null) to prevent\nprototype pollution from untrusted lockfile keys.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.20%. Comparing base (3827ae7) to head (b78d1af).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1319   +/-   ##
=======================================
  Coverage   88.20%   88.20%           
=======================================
  Files          73       73           
  Lines       10386    10386           
  Branches     1409     1409           
=======================================
  Hits         9161     9161           
  Misses       1198     1198           
  Partials       27       27           
Flag Coverage Δ
suite.unit 88.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -1,3 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new library uses the header comment to detect v1 lockfiles. I think this is a safe change to make in favor of dropping another dependency. Yarn Classic generated lockfiles will have the header.

mrgrain and others added 2 commits April 7, 2026 13:20
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants