diff --git a/.yarn/versions/68e485e1.yml b/.yarn/versions/68e485e1.yml new file mode 100644 index 000000000000..2b96cce23620 --- /dev/null +++ b/.yarn/versions/68e485e1.yml @@ -0,0 +1,23 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/plugin-constraints": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@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/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts index 2d395fac0c4a..5fe8d7692f40 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts @@ -107,6 +107,39 @@ describe(`Commands`, () => { await expect(run(`constraints`)).rejects.toThrow(/This should fail/); })); + it(`shouldn't report errors when comparing identical objects`, makeTemporaryEnv({ + foo: { + ok: true, + }, + }, async ({path, run, source}) => { + await run(`install`); + + await writeFile(ppath.join(path, `yarn.config.cjs`), ` + exports.constraints = ({Yarn}) => { + Yarn.workspace().set('foo', {ok: true}); + }; + `); + + await run(`constraints`); + })); + + it(`should report an error when comparing objects with different key ordering`, makeTemporaryEnv({ + foo: { + b: true, + a: true, + }, + }, async ({path, run, source}) => { + await run(`install`); + + await writeFile(ppath.join(path, `yarn.config.cjs`), ` + exports.constraints = ({Yarn}) => { + Yarn.workspace().set('foo', {a: true, b: true}); + }; + `); + + await expect(run(`constraints`)).rejects.toThrow(`Invalid field foo; expected { a: true, b: true }, found { b: true, a: true }`); + })); + for (const [environmentDescription, environment] of Object.entries(environments)) { for (const [scriptDescription, scripts] of Object.entries(constraints)) { for (const [scriptType, script] of Object.entries(scripts)) { diff --git a/packages/plugin-constraints/sources/constraintUtils.ts b/packages/plugin-constraints/sources/constraintUtils.ts index 9feb310a637f..e25067efeb3e 100644 --- a/packages/plugin-constraints/sources/constraintUtils.ts +++ b/packages/plugin-constraints/sources/constraintUtils.ts @@ -203,7 +203,7 @@ export function applyEngineReport(project: Project, {manifestUpdates, reportedEr const [[newValue]] = newValues; const currentValue = get(manifest, fieldPath); - if (currentValue === newValue) + if (JSON.stringify(currentValue) === JSON.stringify(newValue)) continue; if (!fix) {