Support for Yarn workspaces/monorepos
See original GitHub issueFirst of all, thanks for the awesome work on this package!
I’ve started exploring the new “workspaces”/“monorepos” feature of Yarn (https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/), which enables “hoisting” of all node_modules
from any sub-projects to a single parent repository (so that if you have sub-folders with individual package.json
s, each one would install its deps in the “parent” node_modules
and link them, unless there are version conflicts).
However, patch-package
no longer automatically applies patches to sub-project packages in its default configuration (i.e. when I run yarn
in the parent folder, it only applies patches/
from the “parent” folder). I had to move all patches from sub-projects into the “parent” patches/
to make it work, however that sort of “pollutes” the “global” patch space with patches from sub-projects.
Are you familiar with this feature, and are there any other (better) solutions to enable automatic patching of sub-projects (I know it’s a lot to ask, was just hoping to hear your thoughts)?
Thanks again!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:25
- Comments:19 (5 by maintainers)
Top GitHub Comments
As of version 6.1.0 patch-package now works with yarn workspaces 🎉
The setup instructions are exactly the same, but you might need to set it up for sub packages in addition to the repo root package if you want to patch node_modules which were not hoisted.
I was also having trouble generating the patch on a yarn workspace, getting the error
Error: ENOENT: no such file or directory, unlink
(same as @vieira posted above).Here’s my current workaround:
yarn add package-name -W
(Install the package on the root package.json)yarn patch-package package-name
(Generate the patch)yarn remove package-name -W
(Remove the package from the root package.json)This way the patch will be successfully created. I didn’t face issues applying the patch.