Skip to content

feat: narrow supported Yarn Berry lockfile changes - #245

Closed
KingEmma7 wants to merge 1 commit into
DiffCI:mainfrom
KingEmma7:feat/yarn-berry-node-modules
Closed

KingEmma7 wants to merge 1 commit into
DiffCI:mainfrom
KingEmma7:feat/yarn-berry-node-modules

Conversation

@KingEmma7

Copy link
Copy Markdown
Contributor

Closes #66.

Adds conservative selection for Yarn Berry lockfile formats 4, 6 and 8 with plain npm dependencies. Both revisions and the current checkout must explicitly use nodeLinker: node-modules. A supported semantic change considers every old/new direct dependency potentially affected and reuses the existing Yarn checks for tooling, undeclared imports and lockfile readers.

The parser indexes every descriptor in a grouped YAML key, so transitive edges can resolve through later descriptors. It validates exact manifest requests, all dependency edges and the singleton project record Yarn generates as workspace:.. Workspace dependencies remain unsupported.

Missing or ambiguous linker settings, runtime YARN_* variables, inherited/nested Yarn configuration, environment injection, extra settings, peer/optional metadata, unsupported protocols, malformed input and incomplete graphs retain full validation. Tracked YAML/shell setup mentioning YARN_* also blocks narrowing. Analysis must run in the tests' checkout and environment; this does not execute arbitrary scripts to discover dynamically constructed overrides.

Validation on main at 446181d: 1,215 Core tests passed, including 54 new Berry cases. Three selection regressions fail on untouched main and pass with the patch. Typecheck, build, release-boundary audit, agent packaging and benchmark passed. Disposable real installs with Yarn 2.4.3, 3.8.7 and 4.9.2 selected the test that caught a deliberate dependency-version failure; the full suite caught the same failure and the unrelated test passed. The final compiled public API was exercised with Yarn 4.9.2 on this base. The certified patch also applies cleanly to current main 40aa308; 217 focused Yarn/configuration tests, typecheck and boundary audit pass on that combined tree. Hosted Linux/Windows checks have not run for this patch.

@adityankale190895 adityankale190895 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @KingEmma7, this is careful work, and it covers every fixture #66 asked for, including the grouped key and the missing-descriptor edge.

I merged it into current main locally: typecheck, audit:boundary and the 187 Yarn and fallback tests all pass, and hosted CI is green on Linux and Windows. I read the parser and gating line by line, and everything I could find falls back to the full suite when it can't be proven: unknown fields, protocols and formats, missing edges, metadata changes, and the linker proof across both revisions and the working copy, plus the YARN_* environment and inherited config checks.

Needed before merge

  • release-files.json now conflicts with main. Both sides added entries to the same list, so keeping both (tests/repo/test-script-programs.test.ts and tests/repo/yarn-berry-lockfile.test.ts) resolves it.

Not blocking, for here or a follow-up

  1. Real-world reach. Any entry with peerDependencies, dependenciesMeta or conditions makes the whole lockfile unsupported. Most real Berry lockfiles have these (React libraries record peers; esbuild and fsevents record conditions), so this will rarely narrow in practice yet. That's fine as the first step #66 described. Peer and optional metadata would be the natural next PR if you'd like it.
  2. Cost of the YARN_ setup scan. berrySetupSupported runs one git show per matching file, up to 500 per revision, so up to 1,000 git processes, which is slow on Windows. A single git grep -I -i -l -e yarn_ <sha> -- <patterns> per revision would do the same check in one call. The .yarnrc path check can stay on the ls-tree listing.

Happy to merge once the conflict is resolved.

adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
Root Yarn Berry lockfiles in formats 4, 6 and 8 can be narrowed for
plain npm dependencies when both revisions and the current checkout
use an explicit nodeLinker: node-modules. A semantic change widens to
every direct dependency, with the same tooling, undeclared-import and
lockfile-reader checks as Classic. Unknown settings, protocols, fields,
YARN_* overrides and incomplete graphs keep full validation. Closes #66.

Signed-off-by: Emmanuel Mawulolo Tagbor <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

Merged to main as 881c4a4 (squashed, authorship kept). The only conflict was release-files.json, where I added your two entries next to main's. Thanks for keeping this so careful about falling back!

adityankale190895 added a commit that referenced this pull request Nov 18, 2026
A pull request GitHub could not merge (a conflict, a branch the
maintainer cannot push to) is squashed onto main by hand and closed,
so it has no merged_at and its author was never credited in the README.
Count a closed pull request as merged when a main commit titled
"... (#N)" was written by the pull request's own author. Credit
Yarn Berry support (#245) next to it in the release boundary docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

Thank you, @KingEmma7! Yarn Berry support (#66) is on main as 881c4a4, after Yarn Classic in #63, #67 and #70. The care that went into failing closed made this an easy review: linker proof on both revisions and the checkout, YARN_* and inherited config checks, and an exact workspace:. record.

It's credited in the README, on diffci.com/contributors, next to the feature in docs/release-boundary.md, and it will be in the next release notes.

If you'd like a follow-up: Yarn adds a built-in patch: entry for typescript (and resolve, fsevents), so most TypeScript repositories still fall back to the full suite today. Treating those built-in compat patches as their npm package would let Berry narrowing apply to far more real repositories. No pressure, and thanks again.

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 v2+): report which dependencies changed

2 participants