Use case
We are using patch-package to fix some nasty dependency issues, it works great during development. But it sometimes causes CircleCI failures when a partially patched node_modules folder is cached by CI.
The issue
- Install
patch-package and add it as prepare script, as instructed by README.
- Patch module
foo-bar using patch-package foo-bar. Commit the resulted patches/foo-bar+X.X.X.patch to repo.
- When CI is run, CircleCI installs and patches the
node_modules folder and saves the result to cache.
- Modify module
foo-bar and regenerate patch file.
- CircleCI restores the previous cached
node_modules folder (which has incorporated previous version of the patch).
- CircleCI fails when applying new patch to
node_modules:
**ERROR** Failed to apply patch for package foo-bar
This error was caused because Git cannot apply the following patch file:
patches/foo-bar+X.X.X.patch
This is usually caused by inconsistent whitespace in the patch file.
Proposed solutions
-
Add a checksum file for the patches folder so we can easily check if patches has been changed before restoring cache from CI.
-
Or, add a operation that can revert applied patches, such as patch-package revert. So we can revert the patches and save the clean node_modules folder to cache.
Use case
We are using
patch-packageto fix some nasty dependency issues, it works great during development. But it sometimes causes CircleCI failures when a partially patchednode_modulesfolder is cached by CI.The issue
patch-packageand add it aspreparescript, as instructed by README.foo-barusingpatch-package foo-bar. Commit the resultedpatches/foo-bar+X.X.X.patchto repo.node_modulesfolder and saves the result to cache.foo-barand regenerate patch file.node_modulesfolder (which has incorporated previous version of the patch).node_modules:Proposed solutions
Add a checksum file for the
patchesfolder so we can easily check if patches has been changed before restoring cache from CI.Or, add a operation that can revert applied patches, such as
patch-package revert. So we can revert the patches and save the cleannode_modulesfolder to cache.