-
Notifications
You must be signed in to change notification settings - Fork 932
Fix metro config when running from source #56
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
Conversation
| * | ||
| * See "react-native/metro.config.js" | ||
| */ | ||
| if (!config.resolver.hasteImplModulePath) { |
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.
The idea is when React Native provides its "defaults" in "metro.config.js", this code will not execute and hence, not cause an error.
I was a bit confused coming up with a good documentation for that code (lines 135-145) - if anyone feels like this can be described in a better way, please comment.
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.
Couldn't find the react-native/metro.config.js file you're talking about, can you link to it?
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.
It's not there yet. I am assuming in this PR that it will be created afterwards. See the contents of the file I have included in the first comment for details.
|
Removed custom code to overwrite config with |
|
Applied some minor changes - the code is ready to go. |
|
Thanks @grabbou, hope to release a new version of local-cli. |
Metro depends on some private React Native files when starting the server. We are using "require.resolve", which does not work when we actually run CLI from within React Native master (there's no "react-native" package in "node_modules").
I wanted to avoid hacking around "require.resolve" and paths to support that particular use-case. Doing that might become brittle in the future when we add PnP support etc., where "node_modules" awareness might become a problem.
I consider this a temporary hack and hopefully we can do better in the future, e.g. by creating a special package, such as: "react-native-bundler-compat", so that other bundles, such as Webpack can also use these files.
To make this working in React Native, the following "metro.config.js" has to be created:
to overwrite the default paths.
Also, fixes #68 as we don't overwrite config ourselves but pass it straight to Metro.