Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1371
Summary:
Hi 👋
As explained in the attached issue this PR should resolve, when starting the metro bundler after running
run-android, it cannot find themetro.config.jsdue toreact-nativebeing one level higher in the file hierarchy than expected.Therefore, I have added
--metro-configoption that will allow users to specify the location of metro config when runningrun-android. Under the hood, I am creating a new launch packager script that will invokelaunchPackager.commanddefined inreact-nativemodule - but, importantly - with--metro-config xyzif it was specified.launchPackager.commandthen runspackager.shwhich then runs"$NODE_BINARY" "$REACT_NATIVE_ROOT/cli.js" start "$@". Fortunately, it passes arguments by default, so our--metro-config xyzgets passed as well. cli is then run with the metro config specified and it doesn't fail to find it.I don't like the fact that I have to create a temporary script to be actually able to pass commands to
launchPackager.commandas it's not possible to do that directly, so if you have ideas how to make this cleaner, I'd love to know!Test Plan:
I have tested that when I run
react-native run-android --metro-config path-to-metro.config.js, it gets passed to the CLI when invoked from the launch packager scripts and is subsequently used. (when trying to load the bundle, I am gettingError: Unable to resolve module @babel/runtime/helpers/interopRequireDefaultbut that is IMHO unrelated to my changes and is rather tied to my local setup - if you know how to resolve this when contributing to this repo, do let me know, I'll continue investigating this further in the meantime)If this PR is in the right direction, I should also probably add some unit tests.