I’m currently developing a custom Design System (DS) that I plan to use inside my React Native app. One of the dependencies in the DS is react-native-calendars, which has a known issue and an open PR with a fix.
I have locally patched the react-native-calendars dependency in node_modules using patch-package, based on the changes from that PR.
Goal
I want to include these patches in my DS package so that when I import it into my app, the patches are automatically applied.
My Setup
Here are the steps I’m following:
-
In my DS project, I run yarn build which produces a lib folder.
-
My package.json scripts:
"clean-build": "cd lib && find . ! -name 'package.json' ! -name '.' ! -name '..' -exec rm -rf {} + && cd ..",
"build": "yarn clean-build && tsc --project tsconfigBuild.json && cp -a src/assets lib/ && cp -a patches lib/ && patch-package"
-
During the build, the patches folder is copied to the lib directory, which contains my patched files.
-
I added the following to lib/package.json:
"scripts": {
"postinstall": "patch-package"
}
- In my React Native app, I import the DS package from the local file system for testing:
"dependencies": {
"my-design-system": "file:../path/to/my-design-system/lib",
}
Problem
When I import the DS package into my project, the react-native-calendars patches are not applied to the node_modules of the React Native app. It seems like the postinstall script isn’t triggering the patch.
Question
Why are the patches not being applied when I import my DS package?
Is there a better approach to ensure that patches to dependencies like react-native-calendars are applied automatically when my DS is installed in another project?