patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

Is there a way to convert pnpm patches to patch-package patches? Or do they use the same format?

Open matthew-dean opened this issue 2 years ago • 2 comments

While the documentation notes that patch-package is not needed for PNPM, a lot of people in this PNPM thread feel otherwise, for very good reasons. It's simply not as robust as patch-package. Is it possible to convert PNPM patches to patch-package patches and then move forward with just using patch-package?

matthew-dean avatar Dec 19 '23 16:12 matthew-dean

Oh.... patch-package won't work with PNPM whatsoever? 😢

matthew-dean avatar Dec 19 '23 17:12 matthew-dean

pnpm uses links on node_modules, saving both space and time during installation and upgrades, but that also means you can't freely edit files there like you can for yarn and npm. That is why patch-package won't work properly with pnpm, it would globally mess with all your projects and a patch in one project would conflict with patches on another project.

You can convert a patch-package patch into a pnpm patch and vice-versa. You just need to change the prefix of the files. patch-package is relative to the root of your project, so the path is /node_modules/<package_name>/<changed_file>, pnpm is relative to the root of the package being patched, so the path is just /<changed_file>

Fryuni avatar Dec 19 '23 19:12 Fryuni