diff --git a/.yarn/versions/0db9ee49.yml b/.yarn/versions/0db9ee49.yml new file mode 100644 index 000000000000..b9ef967a4a38 --- /dev/null +++ b/.yarn/versions/0db9ee49.yml @@ -0,0 +1,23 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/plugin-essentials": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/core" + - "@yarnpkg/doctor" diff --git a/packages/plugin-essentials/sources/dedupeUtils.ts b/packages/plugin-essentials/sources/dedupeUtils.ts index d29057a2c8d6..5f42254048a5 100644 --- a/packages/plugin-essentials/sources/dedupeUtils.ts +++ b/packages/plugin-essentials/sources/dedupeUtils.ts @@ -32,12 +32,12 @@ export const acceptedStrategies = new Set(Object.values(Strategy)); const DEDUPE_ALGORITHMS: Record = { highest: async (project, patterns, {resolver, fetcher, resolveOptions, fetchOptions}) => { const locatorsByIdent = new Map>(); - for (const [descriptorHash, locatorHash] of project.storedResolutions) { - const descriptor = project.storedDescriptors.get(descriptorHash); - if (typeof descriptor === `undefined`) - throw new Error(`Assertion failed: The descriptor (${descriptorHash}) should have been registered`); + for (const locatorHash of project.storedResolutions.values()) { + const locator = project.originalPackages.get(locatorHash); + if (typeof locator === `undefined`) + throw new Error(`Assertion failed: The locator (${locatorHash}) should have been registered`); - miscUtils.getSetWithDefault(locatorsByIdent, descriptor.identHash).add(locatorHash); + miscUtils.getSetWithDefault(locatorsByIdent, locator.identHash).add(locatorHash); } const deferredMap = new Map>( @@ -91,9 +91,11 @@ const DEDUPE_ALGORITHMS: Record = { if (!resolver.shouldPersistResolution(currentPackage, resolveOptions)) return currentPackage; - const candidateHashes = locatorsByIdent.get(descriptor.identHash); + // As the descriptor may resolve into other ident, (i.e. npm: with package name specified) + // locators should be looked up by the current resolution rather than the descriptor. + const candidateHashes = locatorsByIdent.get(currentPackage.identHash); if (typeof candidateHashes === `undefined`) - throw new Error(`Assertion failed: The resolutions (${descriptor.identHash}) should have been registered`); + throw new Error(`Assertion failed: The resolutions (${currentPackage.identHash}) should have been registered`); // No need to choose when there's only one possibility if (candidateHashes.size === 1)