-
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
Expo support #13534
Comments
@shirakaba ty for this. |
@shirakaba Thank you for this. With the clear upstream guidance of "just use expo" I'm actually preparing an internal presentation on the current state of expo to present to the RNW team so we can maybe fill some gaps. I'm not sure how expo prebuild actually works under the covers, but perhaps similar to what you did with Part of a potential todo list would be to create an "expo (prebuild) friendly" template (either new or if possible by fixing the existing ones). I would love to see an example of "here's a new expo project that got at least some parts of windows working (esp wrt. metro)". |
Sounds exciting!
Ah yes, I've used that. Could you show me where the template lives?
I'm fairly familiar with Expo Prebuild now as I've been contributing some things to it to advance support for There are some obstacles to out-of-tree platform support of
Support for other features of the Expo CLI (like the Will see if I can create that strawman template soon to advance discussions. |
@shirakaba since these days the When you say When you say "like the |
@wodin For sure, I can fork to my heart's content – just a bit of a harder sell when it comes to putting it into other people's hands. Every step with asterisks increases friction in usage, and we don't want to make people have to commit to using a forked CLI that I might give up on maintaining one day.
I'm referring to create-expo, sorry, yeah.
Ah yep, I meant |
FYI, as of 1.3.16, const { getDefaultConfig } = require("@expo/metro-config");
const { makeMetroConfig } = require("@rnx-kit/metro-config");
const config = getDefaultConfig(__dirname);
module.exports = makeMetroConfig(config); |
Summary
Being an out-of-tree platform, Expo doesn't officially support React Native Windows yet, so l'd like to track what's missing and document the workarounds I'm using for now. FYI @Saadnajmi @tido64 @acoates-ms @EvanBacon.
Motivation
Meta now officially recommend using React Native via a framework such as Expo. A pain-point to adopting out-of-tree platforms (with or without Expo) is setting up all the boilerplate, and Expo has an excellent template system for taming all of that, furthermore enabling easy updates simply by bumping the version of the SDK and running what they call a "prebuild" again to regenerate project files.
Basic Example
No response
Open Questions
I'll knowledge-share how I got
react-native-windows
working alongsidereact-native-macos
andreact-native
(all v73) on Expo SDK 50. It lacks config plugins and prebuild, but you can at least use the same Expo CLI to start and bundle apps.Sorry for the lack of concrete details in some places, as I'm working on a closed-source project, so there's a limit to what I can share; but I'm happy to point to prior art. Will try to help get it all upstreamed.
package.json
Although we're not launching the Windows app using the Expo CLI (i.e.
expo start --windows
, which doesn't exist), we are nonetheless starting a common packager withexpo start
, calling Expo'sregisterRootComponent
as an entrypoint for our app, and using the Expo Babel preset.babel.config.js
We use
babel-preset-expo
instead ofmodule:@react-native/babel-preset
. I was seeing errors about bundling Expo SDK modules without it.metro.config.js
I merged an older metro.config.js from RNTA with this metro.config.js from Expo Orbit, repeating what they did to handle
react-native-macos
to handlereact-native-windows
.For some reason, the
@rnx-kit/metro-config
recommended default config didn't work out-of-the-box for me (microsoft/rnx-kit#3257) so I'd love to simplify this.react-native.config.js
You can omit the
windows
key fromreact-native.config.js
if you want to avoid the Expo CLI trying to autolink and instead take autolinking into your own hands (a trick I learned from here) withreact-native autolink-windows
.I ended up doing this for one reason or another (it's all a bit of a blur). I assume Expo CLI doesn't implement autolinking for Windows, anyway.
index.js
Expo projects do the following:
This does a little more than just calling
AppRegistry.registerComponent()
. From the implementation, you can see that it imports a file for side-effects,Expo.fx
:Expo.fx
accessesexpo-asset
andexpo-font
(which expect to find native classes, e.g.requireNativeModule('ExpoFontLoader')
) without any platform guards for Windows. At runtime, those native modules are missing and thus things break downstream that prevent startup.Note that, even if a Windows implementation of
expo-font
andexpo-asset
were implemented, the React Native Community CLI would fail to autolink it in this case because it only autolinks top-level dependencies, while these are subdependencies of theexpo
npm package. The Expo CLI autolinks even subdependencies.It also hard-codes the appKey as "main" when calling
AppRegistry.runApplication
, so if you've configured yourapp.json
to use an explicit name other than"main"
, then the app will fail to start up.Prior art
Related issues
The text was updated successfully, but these errors were encountered: