-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is an alternate metro bundler fix for multiple out of tree platforms #4576
Conversation
I like the simplicity of this solution! Some questions:
|
|
Thanks. I was planning on waiting until 0.62 for the version I was working on as well so we still have some time to decide. I'll post an update on the main proposal and ask for thoughts from facebook folks to help us decide. #Closed |
Question: What should we do with react-native.config.js? Particularly for the CLI template app, which points it directly at react-native-windows, this would be wrong for other platforms. #Closed |
I think we can actually push this change into the react-native cli, which provides its own metro config defaults that get overriden by the apps. What I'm thinking of is adding another property to the platform object provided by out of tree platforms in the react-native.config.js. This property would be something like platforms: {
windows: {
linkConfig: () => null,
projectConfig: projectConfig.projectConfigWindows,
dependencyConfig: dependencyConfig.dependencyConfigWindows,
metroReactNativePackage: 'react-native-windows'
},
}, (the metroReactNativePackage being the new property) Then the CLI can add the resolveRequest property to the default metro config based on what platforms are installed. Then I think we wont need to modify the metro.config at all in our template going forward. #Closed |
Thanks. What happens if you build/run a sample app for another platform with this change? It seems like it will use react-native-windows for various properties, particularly assetRegistryPath, which could mess up resolution of assets. When I got this property wrong in my testing, it resulted in the app not rendering any images that were require'd in as assets (like the background React logo image in the CLI template app) In reply to: 613629109 [](ancestors = 613629109) |
When building for other platforms, this should be a no-op change, since the custom resolver will just call the default resolver. Do we have a good test case for an asset that we know is currently working? I can double check its still working. #Closed |
I believe this will be a change for the CLI app when building for android. Previously, we would redirect resolve to react-native-windows, now we will resolve it to react-native. However reactNativePath will still point to react-native-windows. Thus my concern. The template CLI app has an image in the background near the top (the React logo). That should be a good test. In reply to: 613645515 [](ancestors = 613645515) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a note, here is what I think the CLI change could look like: |
…orms (microsoft#4576) * Use a custom resolver wrapper to allow metro to run for multiple platforms at once * Change files * More simplification of metro configs * CI fixes * Fix bundle command on init app to properly use windows platform * More simplification of metro configs * Fix asset loading
Fixes #4081
This solution is much less invasive than the one in #4522 and I think could be easily added to the react-native CLI to avoid any need for any custom metro config. The CLI could change its default metro config to include this resolver and automatically add all the platforms installed to the config.
Microsoft Reviewers: Open in CodeFlow