-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using CRNA with Lerna and Yarn workspaces #408
Comments
I agree this would be good to support. However, in order to be friendly to beginners, we want to limit the amount of code in the entry point that they have to understand in order to make changes to their project. So, we "hide" the entry point that the packager sees inside I'm not entirely sure what the best approach to supporting this is, but I think it'll require some upstream work on metro-bundler. |
In case anyone is stuck with this and until the different issues are fixed, I made a little guide on how to use yarn workspaces with Create React App and Create React Native App (Expo) to share common code across. Hope you find it handy! |
Hi @dariocravero, I followed the instructions as per your link but still no luck :( is it possible something changed in CRNA? |
Sorry to hear that @hassankhan. Let's move the conversation to viewstools/yarn-workspaces-cra-crna#1 not to clutter this thread |
Description
Currently CRNA includes
App.js
throughcrna-entry.js
using a relative import https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/src/bin/crna-entry.js#L2Problem is that, when using a monorepo approach with Lerna and Yarn workspaces, the node_modules get installed on the root of the project which breaks the relative import for
App.js
Expected Behavior
CRNA should ideally support a monorepo configuration and import
App.js
relative to the CRNA project root.I've tried to change crna-entry.js to use
__dirname
instead but that fails once the code is loaded on the device as__dirname
is not defined. I've looked into usingbabel-plugin-transform-dirname-filename
to replace it by a string but obviously babel won't transpile node_modules folder by default.Observed Behavior
What actually happened when you performed the above actions?
CRNA fails to load App.js
Environment
npm ls react-native-scripts
: 1.3.1npm ls react-native
: 0.47.2npm ls expo
: 20.1.3node -v
: 8.4.0npm -v
: 4.6.1yarn --version
: 1.0.2watchman version
: 4.9.0Reproducible Demo
I've created this example project outlining the problem:
https://github.com/jribeiro/crna-monorepo/tree/app-import-error
Additional Info
I've managed to workaround this by creating an
App.js
file on the root of the monorepo project that exports the CRNA projectApp.js
. I think it would still be better to have a smother experience though.The "patched" project can be found here:
https://github.com/jribeiro/crna-monorepo/tree/master
Let me know you're thoughts. Happy to help out as much as I can.
The text was updated successfully, but these errors were encountered: