-
-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch may be applied multiple times #238
Comments
A similar problem happens on Vercel which caches |
Btw a quick trick to prevent duplication is to make the patch idempotent, i.e. the original code no longer matches the patch after applying the change. For example, in my case, I changed from: diff --git a/node_modules/react-native-web/dist/index.js b/node_modules/react-native-web/dist/index.js
index debd306..ca206ec 100644
--- a/node_modules/react-native-web/dist/index.js
+++ b/node_modules/react-native-web/dist/index.js
@@ -71,3 +71,5 @@ export { default as DeviceEventEmitter } from './exports/DeviceEventEmitter'; //
export { default as useColorScheme } from './exports/useColorScheme';
export { default as useWindowDimensions } from './exports/useWindowDimensions';
+
+export const ViewPropTypes = { style: null } to diff --git a/node_modules/react-native-web/dist/index.js b/node_modules/react-native-web/dist/index.js
index debd306..af22832 100644
--- a/node_modules/react-native-web/dist/index.js
+++ b/node_modules/react-native-web/dist/index.js
@@ -70,4 +70,5 @@ export { default as TVEventHandler } from './exports/TVEventHandler'; // plugins
export { default as DeviceEventEmitter } from './exports/DeviceEventEmitter'; // hooks
export { default as useColorScheme } from './exports/useColorScheme';
+export const ViewPropTypes = { style: null }
export { default as useWindowDimensions } from './exports/useWindowDimensions'; Since it's now an insertion instead of an addition, the patch sees the insertion points have changed and doesn't get applied again. |
Any ideas for a workaround if I can't make it an insertion instead of an addition? In my case the file is only 2 lines & I can't figure out a way to insert my bit in the middle. diff --git a/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__ b/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
index ed2d24f..4808e94 100644
--- a/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
+++ b/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
@@ -1,2 +1,4 @@
+import 'array-flat-polyfill';
<% if (setupFile === 'angular') { %>import 'jest-preset-angular';
<% } else if (setupFile === 'web-components') { %>import 'document-register-element';<% } %>
+import 'jsdom-polyfills'; |
You can slightly modify one of the existing lines, e.g. by adding a space, as part of the patch. I think that should do the trick. |
Yeah, a comment in the middle did the trick, thanks! diff --git a/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__ b/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
index ed2d24f..4808e94 100644
--- a/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
+++ b/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
@@ -1,2 +1,5 @@
+import 'array-flat-polyfill';
<% if (setupFile === 'angular') { %>import 'jest-preset-angular';
+// matching patch hack
<% } else if (setupFile === 'web-components') { %>import 'document-register-element';<% } %>
+import 'jsdom-polyfills'; |
Reduced test case: https://github.com/OliverJAsh/patch-package-multple-patches-bug
If you clone this test case and run
yarn
multiple times, you'll find that the patch which addsStreamApiError
applies each timeyarn
is ran, resulting in corrupt code.patch-package 6.2.2 (latest at time of writing)
The text was updated successfully, but these errors were encountered: