react-native-yarn-workspace v0.0.3
react-native-yarn-workspace
React Native support for Yarn Workspaces.
Note
This package only run on macOs
and Linux
and haven't tested on ios
.
To use this package you have to create the react native project using npx react-native init
. If you are using expo
, use expo-yarn-workspaces instead.
Inspired by expo-yarn-workspaces. The inner working of this package is same as expo-yarn-workspaces
, check it for more details. This package is specifically tweaked to work with bare react-native
project.
Installation
Install the package as a dev dependency.
foo@bar:~$ yarn add -D react-native-yarn-workspace
or
foo@bar:~$ npm i --save-dev react-native-yarn-workspace
Usage
Add a postinstall
script to package.json
Add "postinstall": "react-native-yarn-workspace"
under the script object in the app's package.json
.
Modify metro.config.js
.
If the file does not exist, create it.
const {
extraNodeModules,
watchFolders
} = require('react-native-yarn-workspace').default(__dirname);
module.exports = {
watchFolders,
resolver: {
extraNodeModules
},
// Generated by `react-native`.
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false
}
})
}
// end
};
This will tell the metro bundler
to look for packages on the yarn workspaces
' root node_modules
directory and resolve all the symlink
to their real path.