Similar to: How to blacklist specific node_modules of my package's dependencies in react-native's packager?
I am trying to exclude react native from metro packager using the blacklist option which needs to return a regexp.
What I need is to return something like:
/\/DYNAMIC_PROJECT_DIRECTORY\/node_modules\/react-native\/.*/,
where I can insert a variable into the DYNAMIC_PROJECT_DIRECTORY as it will change dependant on the yarn workspace path of the other module.
I just have no familiarity with regex!
Thanks
Edit: I tried hard coding in the path into that format and it still didn't work to blacklist, so if someone can point me in the right direction on what works to exclude that folder and everything in it that would be much appreciated!
You can create a regular expression that uses dynamic variables with the RegExp constructor:
new RegExp(`\/${DYNAMIC_PROJECT_DIRECTORY}\/node_modules\/react-native\/.*`);
Note:
DYNAMIC_PROJECT_DIRECTORY
; you could just as well write:new RegExp('\/' + DYNAMIC_PROJECT_DIRECTORY + '\/node_modules\/react-native\/.*');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With