fix(core): emit shadowed deep duplicates and avoid over-elevation in …#35573
Open
xavier-dfns wants to merge 1 commit intonrwl:masterfrom
Open
fix(core): emit shadowed deep duplicates and avoid over-elevation in …#35573xavier-dfns wants to merge 1 commit intonrwl:masterfrom
xavier-dfns wants to merge 1 commit intonrwl:masterfrom
Conversation
…stringifyNpmLockfile Two cases produced lockfiles `npm ci` rejects when the root tree contains intermediate-version shadowing: 1. The project graph dedups by `(packageName, version)`, so when the same version appears at multiple lockfile paths in root because an intermediate sibling holds a different version, only one path is emitted. The deep copy is missing and walk-up from the consumer hits the wrong-version sibling. 2. `elevateNestedPaths` hoisted nested entries into any empty ancestor slot. That invented intermediate-level entries that didn't exist in root and shadowed walk-up resolution for any deeper consumer of a different version. Add `emitRootDuplicates` (after `mapSnapshots`) and `wouldShadowDescendant` (gating empty-slot elevation). The two updated `__fixtures__` files encoded the pre-fix layouts: the npm-hoisting fixture was missing required deep copies of `picomatch@2.3.1`, the auxiliary-packages fixture had over-elevated entries.
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Heavily vibe coded fix for #29593. I will forgive you if you close it but I hope it can bring some attention to it.
Bugs
stringifyNpmLockfileproduces dist lockfiles thatnpm cirejects when the root tree contains intermediate-version shadowing:(packageName, version), so when the same version exists at multiple paths in root because an intermediate sibling holds a different version, only one path is emitted. The deep copy is missing and walk-up from the consumer hits the wrong-version sibling.elevateNestedPathshoisted nested entries into any empty ancestor slot, inventing intermediate-level entries that didn't exist in root and shadowing walk-up resolution for any deeper consumer of a different version.Standalone POC reproducing both against
nx@22.7.0below.Fixes
emitRootDuplicates(aftermapSnapshots) re-emits root paths whose(name, version)matches a graph node and whose parent is reachable in the dist tree, iterated to a fixpoint.wouldShadowDescendantgates empty-slot elevation inelevateNestedPaths— only elevate if no descendant of the slot's parent declares a different version of the same package.Tests
New shadowing and over-elevation regressions suite covers each bug with a synthetic lockfile (both verified to fail without the fix).
Two
__fixtures__/lockfiles updated; both encoded the buggy output (npm-hoisting was missing required deeppicomatch@2.3.1copies,auxiliary-packageshad over-elevated entries).POC
repro.js: