Skip to content

Conversation

@tido64
Copy link
Member

@tido64 tido64 commented Jun 16, 2023

Description

Fix compatibility with react-native 0.72

Resolves #2466.

Test plan

n/a

@tido64 tido64 requested a review from acoates-ms June 16, 2023 15:00
@tido64 tido64 requested review from JasonVMo and kelset as code owners June 16, 2023 15:00
@github-actions github-actions bot added the feature: metro This is related to Metro label Jun 16, 2023
@acoates-ms acoates-ms self-requested a review June 16, 2023 17:29
@acoates-ms
Copy link
Contributor

error Invalid platform "windows" selected.
info Available platforms are: "android", "ios". If you are trying to bundle for an out-of-tree platform, it may not be installed.

I get the following error due to the new default config not picking up the remaining part of the metro-config which was previously in the getDefaultConfig from the CLI. https://github.com/react-native-community/cli/blob/1796cdd794979dcf37ba5c7ec4303154bb71d56c/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts#LL44C5-L44C5 -- I'm sure we need the other parts of this config too.

Copy link
Contributor

@kelset kelset left a comment

Choose a reason for hiding this comment

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

LGTM; let's also do what Andrew says in the profile (which I think you might have already done by now)

@tido64
Copy link
Member Author

tido64 commented Jun 19, 2023

LGTM; let's also do what Andrew says in the profile (which I think you might have already done by now)

I've added a new capability:
image

Still looking into the invalid platform windows error. I get no complaints in react-native-test-app. But it fails in rnx-kit.

@tido64 tido64 force-pushed the tido/metro-service-0.72 branch from 743e0cd to f86eaf8 Compare June 19, 2023 13:12
@tido64
Copy link
Member Author

tido64 commented Jun 19, 2023

@acoates-ms: My testing was flawed, so I didn't repro the issue correctly. The issue was that @rnx-kit/metro-config overrides resolver.platforms regardless of what we set earlier. Anyway, with the new changes, we should no longer call getDefaultConfig from metro-service. We should instead expect a full config from the user. This means that we have to fix @rnx-kit/metro-config so that it correctly handles out-of-tree platforms.

This also means that @react-native/metro-config as is will break react-native-macos/-windows. Any suggestions for how we should approach here? Fixing upstream seems like the right thing to do, but it adds complexity as you can see in this PR. Actually, I don't think this is correct. CLI seems to be appending stuff after the fact, which is technically no longer correct.

@tido64
Copy link
Member Author

tido64 commented Jun 19, 2023

@acoates-ms: In any case, I think this is as correct as I can make it. Can you verify on your side that it works?

@tido64 tido64 changed the title fix(metro-service): fix compatibility with react-native 0.72 fix(metro-config): fix out-of-tree platforms not being included on react-native 0.72 Jun 19, 2023
@acoates-ms
Copy link
Contributor

@acoates-ms: In any case, I think this is as correct as I can make it. Can you verify on your side that it works?

Yup, I was able to bundle with these changes.

@tido64 tido64 merged commit 2d8fab9 into main Jun 19, 2023
@tido64 tido64 deleted the tido/metro-service-0.72 branch June 19, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: metro This is related to Metro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update needed for RN 0.72

4 participants