Fix custom port listening configuration through metro.config.js (#44957)
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 `--port` argument 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 `--verbose` and it was. So I dug a bit, trying to figure out what had changed and noticed the coalescing of the value, whenever the argument `--port` is not present. That seemed odd since it meant that there's always a port defined for the `options` of `loadMetroConfig`, which would always be used in the `loadConfig` step. To confirm I was on the right track I went to the [cli-plugin-metro](https://github.com/react-native-community/cli/blob/v11.3.10/packages/cli-plugin-metro) repo, to the last release before the move here, and noticed that there was [no coalescing in the same method](https://github.com/react-native-community/cli/blob/v11.3.10/packages/cli-plugin-metro/src/commands/start/runServer.ts#L60). In this PR, I remove the coalescing of the port from `runServer.js` from the `community-cli-plugin`, to allow the port configuration through `metro.config.js`. ## Changelog: [INTERNAL] [FIXED] - Fix server port configuration via `metro.config.js` <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/44957 Test Plan: Running `yarn start` and verifying that: - it would listen to port `8081` if no argument nor a custom port was set in `metro.config.js` - it would listen to port `8082` if that one was defined in `metro.config.js` - it would listend to port `8083` if that port was passed as an argument to the command (i.e. `yarn start --port 8083` even though port 8082 was defined in `metro.config.js` Reviewed By: cortinico Differential Revision: D58605152 Pulled By: robhogan fbshipit-source-id: 9cf7a8b6a0d9de3af1ca4092906b4c648acee373
This commit is contained in:
Родитель
fa8ea481f0
Коммит
0950916846
|
@ -57,7 +57,7 @@ async function runServer(
|
|||
const metroConfig = await loadMetroConfig(ctx, {
|
||||
config: args.config,
|
||||
maxWorkers: args.maxWorkers,
|
||||
port: args.port ?? 8081,
|
||||
port: args.port,
|
||||
resetCache: args.resetCache,
|
||||
watchFolders: args.watchFolders,
|
||||
projectRoot: args.projectRoot,
|
||||
|
|
Загрузка…
Ссылка в новой задаче