Use Yarn Workspaces to Share Code with CRA and create-react-native-app in a Monorepo

InstructorJason Brown

Share this video with your friends

Send Tweet

In this lesson we'll use yarn and yarn workspaces to create a monorepo that includes a web creat-react-app, a react-native app, and shared code. We'll use react-app-rewired and react-app-rewire-babel-loader to rewire the create-react-app configuration to allow babel to process the shared code from workspace. We'll also use crna-make-symlinks-for-yarn-workspaces and metro-bundler-config-yarn-workspaces to configure the react-native app to be able to find the shared code in the workspaces.

Amit Sengupta
~ 6 years ago

Is there any way to do the same for react/ react-native cli (without expo)?

Jason Browninstructor
~ 6 years ago

Is there any way to do the same for react/ react-native cli (without expo)?

Yeah you should be able to. The CRNA linking stuff that gets setup is just adding projectRoots since the metro bundler doesn't support symlinks. So you would likely just need to create and modify an rn-cli.config.js for normal React.

Thilo Maier
~ 6 years ago

Can you point me to any source that explains how to do versions and tags in workspaces/monorepo right? It's not clear to me if its better to keep versions (the versions in the package.json files in each workspace) in sync or manage them independently and in the latter case how to create meaningful tags in a Git repo.

Tanner Semerad
~ 6 years ago

At 01:09, how is the native folder being created? I'm assuming that's with create-react-native-app, but in the video it appears that running create-react-app web created both the web and native folders.

Jason Browninstructor
~ 6 years ago

Yes, this uses CRNA