berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug]: Yarn doesn't de-dupe patches

Open lukeapage opened this issue 1 year ago • 4 comments

Self-service

  • [x] I'd be willing to implement a fix

Describe the bug

I have a patch on reselect and use that directly as well as redux toolkit and redux toolkit wants a version "^5.0.0" and the patch is on 5.0.1.

yarn does not dedupe that it should use the patched version.

To reproduce

yarn add reselect
yarn add @reduxjs/toolkit
yarn patch reselect

and reselect is present in the root and under @reduxjs/toolkit

Environment

yarn crashes running this command due to another bug.

Its windows 10.

Additional context

No response

lukeapage avatar Jan 03 '24 13:01 lukeapage

Adding a explicit resolution also makes no difference. Editing the yarn.lock file manually and yarn just reverts the change - so looks like the only work-around is to not use yarn patch.

lukeapage avatar Jan 03 '24 13:01 lukeapage

sorry - a explicit resolution does work - I was missing that the resolution needs to be on the root package.json and there were no warnings about using it on a sub-package json.

The work-around to use patch-package isn't available as it does not currently support yarn.

lukeapage avatar Jan 04 '24 10:01 lukeapage

there were no warnings about using it on a sub-package json.

There is a warning when you run an install, you might have missed it.

merceyz avatar Jan 05 '24 12:01 merceyz

@merceyz sorry you are right, I somehow missed it for months :(

lukeapage avatar Jan 05 '24 14:01 lukeapage