Best practices for using ReasonML in a monorepo


Hi all! I’m working on a ReasonML app where we’re using react-native + react-native-web to build some universal components that we intend to use in both web and native (iOS/Android) apps. We’ve set up a monorepo (using lerna) with the intention of having a package for our UI components that can then be utilized in both the web and native apps.

I’ve got the web app set up to use the UI components package as bs-dependency. But, I’m starting to wonder if I’m working against the build system by doing it this way. For instance, I get a bunch of “Duplicated Package” warnings because of two copies of ReasonReact and bs-platform, and I think I may actually have an issue with an other lib I’m using that’s being caused by it being used in two different instances.

That got me wondering if anyone’s got any tips for using Reason in a setup like this. It seems to me that I could just include the directory containing my UI components in the web app’s sources array, as well as the native app’s, and they’d both treat the components as source code instead of a dependency… though I’d lose the namespacing and the theoretical ability to run a different version of a component in different apps, I suppose.

I’d love to hear if anyone else has set something up like this and has any tips or ideas to share. Thanks!


I would suggest you use yarn workspace feature to hoist all packages to top level node modules. I’m doing this in my project and it works great for me