brunolemos/react-native-web-monorepo

separate platform specific libraries

MostafaTaghipour opened this issue · 1 comments

Hi there
I want to know what to do if I want to separate components and libraries for each platform so that the component and the library are not added to the output of other platforms.

To clear this, I give an example
Suppose I want to add a file uploader library for the web and a file uploader library for Native, and use each of them in specific platform.
As far as I know, I need to add both libraries (web and native uploader) to the common repo and create a component with the .web extension and use the web file uploader library and create a new component for native and use the native file uploader library.

But if I do this, the web uploader library will be added to the native output, for example, if I export Android APK, its included the web uploader library that increases the size of the APK and vice versa.

If I'm wrong, please tell me otherwise, what is the proper solution to prevent this?

I haven’t tried this but try adding the platform specific dependencies as “peerDependencies” in the shared package, and then add them as normal dependencies only on the specific platform package.

Let me know if that works!