Skip to content

Conversation

@fortmarek
Copy link
Contributor

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 the metro.config.js due to react-native being one level higher in the file hierarchy than expected.

Therefore, I have added --metro-config option that will allow users to specify the location of metro config when running run-android. Under the hood, I am creating a new launch packager script that will invoke launchPackager.command defined in react-native module - but, importantly - with --metro-config xyz if it was specified. launchPackager.command then runs packager.sh which then runs "$NODE_BINARY" "$REACT_NATIVE_ROOT/cli.js" start "$@". Fortunately, it passes arguments by default, so our --metro-config xyz gets 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.command as 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 getting Error: Unable to resolve module @babel/runtime/helpers/interopRequireDefault but 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.

@fortmarek
Copy link
Contributor Author

Also, unit-tests seem to be failing here but that seems unrelated to my changes - any idea how can I fix it? 🤔

@fortmarek
Copy link
Contributor Author

fortmarek commented Aug 24, 2021

Would you have time to look at this in the foreseeable future, @grabbou? 🙂

@grabbou
Copy link
Member

grabbou commented Oct 4, 2021

Closing as per my comment in #1371. Thank you for your work! Looking forward to the next PR!

@grabbou grabbou closed this Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass custom-placed metro.config.js through --config to run-android and run-ios commands

2 participants