ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
MIT License
10.17k stars 283 forks source link

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

Open matthew-dean opened 6 months ago

matthew-dean commented 6 months ago

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 commented 6 months ago

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

Fryuni commented 6 months ago

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>