Fix custom port listening configuration through metro.config.js#44957
Fix custom port listening configuration through metro.config.js#44957afonsograca wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Is the = 8081 here necessary? metroConfig should be fully hydrated at this point and populated with the upstream Metro defaults from metro-config.
There was a problem hiding this comment.
I don't think so, but I don't have the context as to why the coalescing was added in the first place so I wanted to make sure we had a failsafe. Happy to remove it if you don't think it's necessary. the less the better.
There was a problem hiding this comment.
Ah, that might be because Metro's default used to be 8080 whereas RN's was 8081 - CC @huntie who might recall the context there.
Now that Metro and RN are aligned you're right IMO - the less repetition of this value, the better - let's remove it.
There was a problem hiding this comment.
it seems something failed, but I don't have permissions to see what it is. could you let me know?
|
This is a great catch @afonsograca - many thanks! |
|
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
This pull request was successfully merged by @afonsograca in 0950916. When will my fix make it into a release? | How to file a pick request? |
Summary:
After updating my project to 0.73.2 I noticed that even though I had a specific port set in my
metro.config.js, every time I'd start my project, it was running on port 8081. Passing the--portargument would allow me to change the port, but the config from metro did not. I checked if the metro config was being properly applied, using--verboseand it was.So I dug a bit, trying to figure out what had changed and noticed the coalescing of the value, whenever the argument
--portis not present. That seemed odd since it meant that there's always a port defined for theoptionsofloadMetroConfig, which would always be used in theloadConfigstep.To confirm I was on the right track I went to the cli-plugin-metro repo, to the last release before the move here, and noticed that there was no coalescing in the same method.
In this PR, I remove the coalescing of the port from
runServer.jsfrom thecommunity-cli-plugin, to allow the port configuration throughmetro.config.js.Changelog:
[INTERNAL] [FIXED] - Fix server port configuration via
metro.config.jsTest Plan:
Running
yarn startand verifying that:8081if no argument nor a custom port was set inmetro.config.js8082if that one was defined inmetro.config.js8083if that port was passed as an argument to the command (i.e.yarn start --port 8083even though port 8082 was defined inmetro.config.js