-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
WIP: Importing from shared dir #370
Conversation
This might be related expo/expo@1c24b4e |
Do you want that I take a look on this? |
@marcelomorgado Sure, that would be great! Thanks! |
@marcelomorgado This is the clearest reference repo I found, where there's an expo app that uses a shared component https://github.com/MPiwowarski/react-native-adjacent-imports |
I found it here facebook/react-native#12241 (comment) |
@@ -1,6 +1,14 @@ | |||
const path = require("path"); | |||
|
|||
module.exports = { | |||
// Both lines extracted from: https://medium.com/react-native-training/sharing-code-between-react-web-and-react-native-applications-7f451af26378 | |||
// Tech-debt: Use same var for the shared dir (Why using resolve instead of join?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having looked at the path
docs, either resolve
or join
is a perfectly sensible approach to achieve the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by Use same var for the shared dir
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've created var shared = path.join(__dirname, "../shared");
. I've introduced watchFolders: [path.resolve(__dirname, "../shared")],
, I've meant to used shared
variable one watchFolders
too if is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, understood!
Now, we're getting this error (from expo-cli): |
@marcelomorgado Did you do |
@marcelomorgado I'm getting this naming collision for
I know I saw someone handling that in one of the threads I looked at while researching this. I'll look for that. Side note: If there are enough shared deps we might want lerna in this repo too #374 |
Or maybe I spoke too soon:
I'll keep researching how others have done this |
This was the related comment I remembered expo/create-react-native-app#232 (comment) |
|
I think this is the right direction to be headed in, but it hasn't solved the issue of complaining about duplicated |
@marcelomorgado I'm not seeing the babel issue - does running |
I'm getting the same error: [16:09:04] Error: Can't find react-native in package.json dependencies
[16:09:04] Error: React Native is not installed. Please run `npm install` in your project directory.
[16:09:04] Couldn't start project. Please fix the errors and restart the project.
[16:09:04] Set EXPO_DEBUG=true in your env to view the stack trace. |
If I include react-native as a dep in both |
Issue link
#336
Auto-close the issue?
Closes #336
Types of changes
Technical debt (a code change that doesn't fix a bug or add a feature but makes something clearer for devs)
Notes
This seems like it should be working based on comments I found when googling like this one facebook/react-native#12241 (comment), but it isn't working yet.