Skip to content

fix: Fix loading Metro config from alternative config path - #2043

Merged
thymikee merged 1 commit into
react-native-community:mainfrom
huntie:load-metro-config-fix
Aug 7, 2023
Merged

fix: Fix loading Metro config from alternative config path#2043
thymikee merged 1 commit into
react-native-community:mainfrom
huntie:load-metro-config-fix

Conversation

@huntie

@huntie huntie commented Aug 2, 2023

Copy link
Copy Markdown
Collaborator

Summary

Resolves #2042. Config validation within loadMetroConfig was not passing options.config to Metro's resolveConfig function — where this is done later for loadConfig.

Test Plan

No --config arg (Unchanged)

image

✅ Implicitly loads ./metro.config.js

With --config specified

image

✅ Loads metro.config.js file from alternative file path

With --config specified, file does not exist

image

✅ Throws underlying error from Metro

(Note: This error message could be improved in Metro's source — to keep CLI lean I'm not wrapping this with anything now as the error is just about clear enough, cc @robhogan)

@huntie
huntie force-pushed the load-metro-config-fix branch from 0c95dec to 3878e97 Compare August 2, 2023 15:15
@huntie
huntie force-pushed the load-metro-config-fix branch from 3878e97 to 26c8f64 Compare August 2, 2023 15:20
@huntie
huntie marked this pull request as ready for review August 2, 2023 15:24
@huntie
huntie requested review from adamTrz and thymikee as code owners August 2, 2023 15:24

@szymonrybczak szymonrybczak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 🙌

@szymonrybczak

Copy link
Copy Markdown
Collaborator

We need to release this change and backport to 0.72. cc. @thymikee

@thymikee

thymikee commented Aug 7, 2023

Copy link
Copy Markdown
Member

@huntie mind creating a second PR targeting the 12.x branch please? 🙏🏼

@huntie
huntie deleted the load-metro-config-fix branch August 8, 2023 10:08
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Aug 15, 2023
Summary:
Pull Request resolved: #38944

- Update `cli-commands` package to reflect latest source `react-native-community/cli-plugin-metro` changes.
	- react-native-community/cli#2021
	- react-native-community/cli#2024
	- react-native-community/cli#2043
	- react-native-community/cli#2047

### To do

WARNING: ~~This PR is non-functional until the next CLI alpha is published and bumped in `package.json` — since it depends on corresponding new APIs in `react-native-community/cli-tools` (react-native-community/cli#2021). This package (and the upcoming work which integrates it) has been tested against locally linked copies of latest CLI.~~

- [x] Bump CLI dependencies when next alpha published.
- [x] Ensure Metro bump from `0.77.0` to `0.78.0` is consistently applied with this.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48066179

fbshipit-source-id: b3dc8891cf33e537788f942dcaddff4d2f11a31f
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.

react-native bundle command fails to find metro.config.js

3 participants