Comments (8)
Hi peeps. I just published v5.1.0 of patch-package which has a --reverse
option. Thanks for your patience. 🙇
from patch-package.
I just ran into the exact same issue. Unfortunately I don't think --reverse
can help in our case—we don't want to revert the patches because the version of node_modules
at the end of the build will be cached but also it is what will be used to run the application, so the patches need to be applied.
I'm not sure there's any solution to this problem, but at the very least I hope we can improve the error message, so it's clear the patch failed because it's being applied to something that has already been modified. The patch could carry a hash of the original file, and then when the patch is applied, if the hash of the target file doesn't match the original, the patch would fail with an error along the lines of "target has unexpected hash". /cc @ds300
from patch-package.
Here's a snippet of our current CircleCI steps:
- restore_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
- run: yarn install
- run: yarn test # Run tests
- save_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
Note the checksum
part. The cache key includes the checksum of yarn.lock
file. So CI will restore cache from previous builds only when yarn.lock
is unchanged. But there's no easy way to check if the patches have been changed.
In the first proposed solution, we could change the cache key to something like:
node-modules-cache-{{ checksum "yarn.lock" }}-{{ checksum "patches/lock" }}
Then the cache will miss and CI will rebuild node_modules
when patches/lock
file has been changed.
In the second proposed solution, we could simply add a step to revert the patches before saving cache:
- restore_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
- run: yarn install
- run: yarn test # Run tests
- run: yarn patch-package revert # <-- Add this line
- save_cache:
key: node-modules-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
So the cache does not contains patches.
from patch-package.
+1, same issue here with CircleCI. reverse
seems like a neat workaround, although a lockfile would be more natural imo.
from patch-package.
Hey, thanks for the solid issue report! I see the problem, and so far I like the second solution you proposed. Not sure I understand exactly how the first would work, could you detail that for me?
In the second case, would the revert
command be called after everything else in the CI sequence, as a kind of teardown operation? I'm not familiar with how CircleCI does caching.
from patch-package.
Apologies for the delay in getting back to this.
For the checksum thing, I see how that works now and it seems like a good solution to me, but I'm not sure that it makes sense for patch-package to provide as a feature, since it's specifically related to working around expressivity issues with CircleCI's cache configuration. It seems like it should be possible to find a solution within the circle build by generating the lock file before restoring the cache with a command like cat patches/**/*.patch | md5 > patches/lock
If that's not possible for some reason then the second solution is definitely doable. Without patch-package's help you could apply the patches in reverse using the unix patch --reverse
command. I think it makes sense to add this to patch-package's api though. It would be quite cheap to implement, test, and maintain, so if it helps just one or two people out it'll be worth it.
from patch-package.
Thanks for you reply. reverse
would be very helpful.
from patch-package.
Unfortunately I don't think --reverse can help in our case—we don't want to revert the patches because the version of node_modules at the end of the build will be cached but also it is what will be used to run the application, so the patches need to be applied.
I was able to use --reverse
in the end. I just have to re-apply the patches after the build has finished but before the application is started.
from patch-package.
Related Issues (20)
- This error occurs when I execute the command HOT 1
- Add support for yarn v2+ HOT 6
- Patching Git modules without version HOT 3
- Warn when patch exists for old version of package HOT 5
- [Proposal] Reduce `patch-package` installation size HOT 2
- [Discussion] Global patches HOT 1
- New patch parse failed
- Add new dependency to a package
- Does patch-package support node12? HOT 1
- Failed to apply patch for package react-native-agora HOT 1
- Is there a way to convert pnpm patches to patch-package patches? Or do they use the same format? HOT 2
- -
- Uniterpretable Error during makePatch HOT 3
- react-native-otp-verify+1.1.6.patch
- Confusing syntax error message when pointing to a package that does not exist
- Patch not applied after package upgrade
- inflight - Missing Release of Resource after Effective Lifetime HOT 1
- how get the post-install to run when installing cosmos (or storybook and the like)
- Patch cannot be applied when it simultaneously renames and modifies the file HOT 1
- npx patch-package [email protected] error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from patch-package.