Keep a nested copy from shadowing the package it is nested under - #9
Merged
Merged
Conversation
A dependency that finds the wrong version above it gets a nested copy, and the resolver put that copy in the shallowest scope on the way up with nothing of that name in it. Free is not the same as usable: a copy placed in a scope is what every package below it resolves the name to, so the slot has to be clear for them too, not just empty. jest 30.5 is where this stopped being theoretical. glob 13 sits at the top and wants minimatch 10, so minimatch 10 sits at the top. test-exclude wants glob 10, which nests, and minimatch 10, which it finds at the top. The nested glob 10 wants minimatch 9. The first empty slot for that 9 is test-exclude's own node_modules, and a copy there is the one test-exclude itself now resolves minimatch to, which breaks it. npm puts the 9 one level down, inside glob, and the resolver now does the same: a scope is skipped when a package at or below it asks for the name, currently reaches a copy further up, and would reach this one instead without being satisfied by it. Two things follow. The version has to be known before the scope is chosen, so the registry is asked first. And the scopes worth considering stop at the copy in the way: anything above it is no use to the dependent, which would still find that copy first. That was true before by accident, because a nested copy could only ever exist below a taken slot. Now that an empty slot can be skipped, it has to be said. Two tests pin the shape on a registry served from memory, so they say what the graph is rather than depend on what npm holds today. The live jest test that caught this passes again, as do the other real graphs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Keep a nested copy from shadowing the package it is nested under
A dependency that finds the wrong version above it gets a nested copy, and the resolver put that copy in the shallowest scope on the way up with nothing of that name in it. Free is not the same as usable: a copy placed in a scope is what every package below it resolves the name to, so the slot has to be clear for them too, not just empty.
jest 30.5 is where this stopped being theoretical. glob 13 sits at the top and wants minimatch 10, so minimatch 10 sits at the top. test-exclude wants glob 10, which nests, and minimatch 10, which it finds at the top. The nested glob 10 wants minimatch 9. The first empty slot for that 9 is test-exclude's own node_modules, and a copy there is the one test-exclude itself now resolves minimatch to, which breaks it. npm puts the 9 one level down, inside glob, and the resolver now does the same: a scope is skipped when a package at or below it asks for the name, currently reaches a copy further up, and would reach this one instead without being satisfied by it.
Two things follow. The version has to be known before the scope is chosen, so the registry is asked first. And the scopes worth considering stop at the copy in the way: anything above it is no use to the dependent, which would still find that copy first. That was true before by accident, because a nested copy could only ever exist below a taken slot. Now that an empty slot can be skipped, it has to be said.
Two tests pin the shape on a registry served from memory, so they say what the graph is rather than depend on what npm holds today. The live jest test that caught this passes again, as do the other real graphs.