I am creating a stack using react and react-native and i am planning to share the container(logic) code, alongside i am also creating dumb UIcomponents(functions that return the layout) for both native and web .
I was trying to conditionally import the UIcomponents for different builds . I was able to do that with web using webpack's NormalModuleReplacementPlugin but i couldn't find a way to do the same with the metro bundler as there is no documentation available .
So is there a way to actually configure your setup in such a way that you can conditionally import components for react-native using metro bundler . The import statement in es6 only uses string literals and though you can club variables with require in react , it doesn't work with react-native .
Right now everytime i run the command it triggers a script which reads the file and changes the import statements from
../native/One.component
to
../web/One.component and vice versa for native to web
But this way i won't be able to shoot both the servers for debugging . I want to know is there a cleaner way to do that ?