diff --git a/.yarn/versions/a4a640ca.yml b/.yarn/versions/a4a640ca.yml new file mode 100644 index 00000000000..db19e4d46ba --- /dev/null +++ b/.yarn/versions/a4a640ca.yml @@ -0,0 +1,36 @@ +releases: + "@yarnpkg/core": patch + "@yarnpkg/plugin-catalog": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-http" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-jsr" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@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/cli" + - "@yarnpkg/doctor" + - "@yarnpkg/extensions" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks" diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/features/catalogs.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/features/catalogs.test.ts index 1fd90e92c54..5174d6f60b1 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/features/catalogs.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/features/catalogs.test.ts @@ -125,6 +125,9 @@ describe(`Features`, () => { devDependencies: { [`no-deps`]: `catalog:`, }, + peerDependencies: { + [`no-deps`]: `catalog:`, + }, }, async ({path, run}) => { await yarn.writeConfiguration(path, { @@ -336,5 +339,28 @@ describe(`Features`, () => { }, ), ); + + test( + `it should work with catalog references in peer dependencies`, + makeTemporaryEnv( + { + peerDependencies: { + [`no-deps`]: `catalog:`, + }, + }, + async ({path, run}) => { + await yarn.writeConfiguration(path, { + catalog: { + [`no-deps`]: `2.0.0`, + }, + }); + + await run(`install`); + + const manifest = await xfs.readJsonPromise(`${path}/package.json` as PortablePath); + expect(manifest.peerDependencies[`no-deps`]).toBe(`catalog:`); + }, + ), + ); }); }); diff --git a/packages/yarnpkg-core/sources/Manifest.ts b/packages/yarnpkg-core/sources/Manifest.ts index 4123399053e..6f2061b2fae 100644 --- a/packages/yarnpkg-core/sources/Manifest.ts +++ b/packages/yarnpkg-core/sources/Manifest.ts @@ -377,7 +377,7 @@ export class Manifest { continue; } - if (typeof range !== `string` || (!range.startsWith(WorkspaceResolver.protocol) && !semverUtils.validRange(range))) { + if (typeof range !== `string` || (!range.startsWith(WorkspaceResolver.protocol) && !semverUtils.validRange(range)) && !range.startsWith(`catalog:`)) { errors.push(new Error(`Invalid dependency range for '${name}'`)); range = `*`; }