Skip to content
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

Migrate from Unimodules to Expo Modules #5203

Merged
merged 7 commits into from
Jan 28, 2022
Merged

Conversation

chrisbobbe
Copy link
Contributor

@chrisbobbe chrisbobbe commented Jan 25, 2022

Following the plan I sketched out at #5133 (comment).

I kicked the tires on Android and iOS, and everything seemed fine:

  • (No observed behavior changes anywhere when poking around, including in the message list)
  • expo-apple-authentication: iOS native Apple auth worked
  • expo-screen-orientation: nothing odd on rotating the screen
  • expo-web-browser: opening a link in the "in-app browser" on iOS worked fine (and we don't use this on Android)
  • expo-application: The app version on the Diagnostics screen showed up fine

Fixes: #5133

@chrisbobbe chrisbobbe added the dependencies Pull requests that update a dependency file label Jan 25, 2022
@chrisbobbe
Copy link
Contributor Author

chrisbobbe commented Jan 25, 2022

This'll be too long for a commit message, so I'll leave it here. We use five expo-* modules, and they vary in whether they cut a new major version for the breaking change from "Unimodules" to "Expo modules". (Because some of them didn't, I haven't bothered to send one of my easy, catch-all yarn upgrade PRs in a long time. To get it mergeable, I'd have had to spend time figuring out exactly which packages were violating semver and how/where, and exclude them. That seemed annoying.)

Collapsed below are the details of how I plan to upgrade those five modules, in the same commit that switches us over from react-native-unimodules to expo.

`expo-web-browser`

expo-web-browser seemed to make the switch at 9.3.0:

`expo-application`

expo-application seemed to make the switch at 3.3.0:

`expo-apple-authentication`

expo-apple-authentication seemed to make the switch at 4.0.0:

`expo-sqlite`

expo-sqlite seemed to make the switch at 10.0.0:

`expo-screen-orientation`

expo-screen-orientation seemed to make the switch at 4.0.0:

  • Migrated in expo/expo@8285c0328, expo/expo@efd75decd, and expo/expo@6e35719a7.
  • 4.0.0 was likely published from expo/expo@1fffde734.
  • The changelog only notes one breaking change we'd encounter by upgrading to there: iOS 11 support is dropped. We've already done that.
  • The changelog notes a small change to the types ([screen-orientation] add doc comments in source expo/expo#14150): an existing type is exported, and a lot of jsdocs are added. So, follow that.
  • We find that there's a breaking change at 4.1.0 (likely published from expo/expo@df68325f3), so we exclude that from the range. In particular, expo/expo@057488d1a started depending on something called ExpoReactDelegateHandler offered by expo-modules-core, which wasn't available until expo/expo@0f5f192f4 landed in expo-modules-core@0.6.0 (likely also published from expo/expo@df68325f3).
    • expo-screen-orientation@4.1.0 doesn't seem to enforce expo-modules-core@0.6.0 or later with (peer-)dependency requirements; it probably should. (There don't seem to be (peer-)dependency requirements that disallow it, which is good.)

    • I think we're not ready to take expo-modules-core@0.6.0; I suspect (though unverified) that we may need to do a React Native upgrade before that. (EDIT: I think this actually isn't true: see note below.) When I tried to bring that in, I got this failure from pod install:

      Installing ExpoModulesCore 0.6.4 (was 0.4.10)
      [!] The following Swift pods cannot yet be integrated as static libraries:
      
      The Swift pod `ExpoModulesCore` depends upon `ReactCommon`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
      

      ReactCommon is a React Native thing, and the way we declare the dependency is by running a script published by React Native in our Podfile.

      EDIT: Actually, I think Expo overwrites RN's ReactCommon declaration with a hack in expo-modules-autolinking, so that we don't get this error. We just have to take the fix, which we should get in expo-modules-autolinking 0.4.0 (published in expo/expo@9faa58818). That should come automatically when we bump expo to 44.

  • So, upgrade to >=4.0.0 <4.1.0.

@chrisbobbe
Copy link
Contributor Author

chrisbobbe commented Jan 25, 2022

Expo commit When resolved in zulip/zulip-mobile Comment
expo/expo@63b5a92b8 [templates] Remove unnecessary imports N/A We didn't have these imports to begin with.
expo/expo@c44d9daa8 Remove READ_PHONE_STATE permission from default template (#13176) 2cc6a52 Our manifest explicitly says we don't want this permission.
expo/expo@15aa41994 Update AndroidManifest.xml (#13173) N/A Our manifest wasn't requesting android.permission.MODIFY_AUDIO_SETTINGS to begin with.
expo/expo@79ca9839c [expo-constants] Modularized expo-constants without further app setup (#13424) N/A On Android and iOS, this stops pulling in code in node_modules/expo-constants that we weren't pulling in to begin with. The stated reason for the commit is "Try to achieve the goal of expo install expo-constants without any further setup." Well, we haven't run that command, or yarn add expo-constants, because we haven't yet had a reason to depend directly on expo-constants. An unrelated surprise I found right next to the removal on iOS is that the template app pulls in some code from node_modules/expo-updates. We don't depend on expo-updates at all. Looking at expo/expo#7382, which seems to be when this got added, that omission should be fine: "almost all groups of people likely to use these templates […] will want to have expo-updates installed". Well, I guess we're the exception. Its description on NPM: "expo-updates fetches and manages updates to your app stored on a remote server."
expo/expo@b9f2132e7 Remove AppleTVOS12 JavaScriptCore.framework (#13591) 64e5f8c, ed91c3d We've already removed these chunks that are about tvOS.
expo/expo@060fbd4fa Remove xib file (#13590) 78a62b2 We've already updated to the modern .storyboard file for our iOS launch screen.
expo/expo@3ad2d33e8 Added iOS background color support (#13607) 575be42 We decided in 575be42 not to set rootView.backgroundColor at all. This RCTRootViewBackgroundColor seems to be an Expo thing, not a RN thing (there are no search results for it on the RN GitHub). There isn't an obvious reason to approach Expo's way of doing things in this direction.
expo/expo@9e66f3bce [template] Add react-native-safe-area-context to expo-template-bare-minimum (#13840) N/A We already have react-native-safe-area-context in our dependencies.
expo/expo@05f2ed0c7 [autolinking] Use NodeJS to resolve autolinking script location & popularise it among other imports (#13901) PR N/A For the actual headline change of this commit, we could take it or leave it; shrug. (For the benefits, see expo/expo#13901 (comment) .) We end up taking it. In our commit that takes this change, we include bugfixes from expo/expo@d3f983699 and expo/expo@9781212eb. Nope; see #5203 (comment).
expo/expo@f05c8ccb6 [android] Update Gradle to 6.9 (#13929) PR
expo/expo@896103abd [sdk] upgrade typescript to v4.3.5 (#14015) N/A ^7.12.9 is already the version range we specify for @babel/core.
expo/expo@507e608fd [ios][autolinking] Move autolinking scripts from the adapter to expo-modules-core (#14046) N/A This gets moved again later; we'll import it from its final location (node_modules/expo/scripts/autolinking.rb) in the main commit, following expo/expo@9781212eb
expo/expo@d3f983699 [ios] fix autolink error from pod install (#14034) PR We applied relevant parts of this when we handled expo/expo@05f2ed0c7. We decided not to do that; see there.
expo/expo@dbd384b22 [template] React Native Image gif and webp support (#14163) N/A This change would have the template app define and use new "expo"-named variables to conditionally include dependencies that, if included, React Native's Image component would use for GIF and WebP support. I don't think we have a strong reason to add such variables, or any variables, as a way to change how the Image component behaves. We already directly give animated-GIF support without doing adding a variable; see our // For animated GIF support comment. Also, RN's doc for the Image component already talks about GIF and WebP support: https://reactnative.dev/docs/image#gif-and-webp-support-on-android
expo/expo@09e76aae3 [templates] Remove expo forked react-native from managed apps (#14261) N/A This bumps react-native in package.json to 0.64.2, and brings react and react-dom up correspondingly. We're already using react-native@0.64.3.
expo/expo@eb2c86e38 [ios] Fix versioning script and shell app workflows (#14436) da269e9 Looks like this drops support for iOS 11; we've already done that.
expo/expo@505f2066b [expo] Updates splash, adds dist/ to gitignore (#14439) N/A This adds a dist/ directory to the project's gitignore. We don't have a dist/ directory, or a reason for having one.
expo/expo@9781212eb [templates] Update templates for the next SDK (#14409) PR (main commit) (See commit message.)
expo/expo@9886c0aaf [expo-modules][ios] Fix errors from use_frameworks in Podfile (#14523) PR We just make a note of this, since it addresses an issue seen when using use_frameworks!, and we don't use use_frameworks!.
expo/expo@38acbdec4 Update versions in project templates N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P Under dependencies, it updates expo from "~43.0.0-alpha.3" to "~43.0.0-beta.1"; we won't be taking an alpha or beta version. It updates expo-splash-screen and expo-updates, which we don't use. It updates react-native-screens from "~3.7.0" to "~3.8.0"; we're on 2.x because 3 is a breaking change.
expo/expo@d3b29ead0 [templates] Automatically resolve RN path in Xcode build scripts (#14546) N/A Shrug. This looks like more work like expo/expo@05f2ed0c7. As we said for that, we could take it or leave it; see expo/expo#13901 (comment) . Maybe not this time. The string "node_modules" has 6 occurrences that we'd want to address, if doing so, not just the 3 that are in the Expo commit. It'd be fiddly and not great for readability.
expo/expo@c152aa35c Update project templates to expo@43.0.0-beta.2 N/A We won't be using a beta release of expo.
expo/expo@7ba6eeb78 [templates] Update for latest publish packages N/A We won't be using a beta release of expo, and we don't use expo-splash-screen or expo-updates.
expo/expo@f1812e55b [android] Added support for opening https links (#14638) N/A This adds a declaration that the app would like to discover other apps that can open URLs, presumably for the "package visibility filtering" changes when targeting Android 11. We added almost the same declaration, in 30b4d6a; the difference is that we didn't include the <data android:scheme="https" /> part. That should be fine. AIUI, for that to make a difference to the results of the query, there would have to be some browser app that doesn't handle https://-schemed URLs, and think that's very unlikely.
expo/expo@3bb65c866 [template] Use symbol to access reactNativePath rather than string (which does not work) N/A Our Podfile already has this fix.
expo/expo@7946cd428 [template] Update bare template N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P
expo/expo@8e1d7c05b [template] Set PROJECT_ROOT based on xcode project to fix release builds in monorepo N/A Shrug. This looks like a followup in the direction of expo/expo@d3b29ead0, which we didn't take.
expo/expo@3de590bb7 [template] Update bare template N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P It updates expo to another beta version (we won't end up using a beta version), and it updates expo-splash-screen and expo-updates, which we don't use.
expo/expo@c026bda1d [templates] Publish updates for latest package versions N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P
expo/expo@6e90b5214 [templates] Bump some dependencies N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P It updates expo-splash-screen, which we don't use.
expo/expo@ffdcd2a62 [template] Use expo run commands in bare templates N/A We're happy with our scripts in package.json.
expo/expo@d13d80c8f [template] Bump version for expo run changes N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P
expo/expo@5b0c17a32 [templates] Update templates N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P It updates expo to the non-beta version "~43.0.0", but there are later versions than 43.0.0 (we'll probably want the latest 43.x), and it updates expo-updates, which we don't use.
expo/expo@3ab513775 [template] Add back updates manifest embed script N/A This pulls in some code related to expo-updates, which we don't use.
expo/expo@03ad7ee61 Revert "[template] Add back updates manifest embed script" N/A This reverts the template-app change in expo/expo@3ab513775, which we didn't take.
expo/expo@d034a6761 [react-native] Update from 0.64.2 -> 0.64.3 (#15108) bfdf99b
expo/expo@afa47a57b Update template versions N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P It updates expo to "~43.0.2", but there are later versions than 43.0.2 (we'll probably want the latest 43.x), and it updates expo-splash-screen and expo-updates, which we don't use.
expo/expo@231fd1415 [templates] Publish N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P
expo/expo@87a3d02aa [android] Fix building error from outside of project root (#15109) PR
expo/expo@c75c6c417 [template] Fix hermes command not found on monorepo (#15154) PR
expo/expo@2726b3298 [templates] Publish N/A This updates version in package.json. We do that on our own schedule, which looks like it's just never. =P
expo/expo@282f5070b [templates] Add missing react test render and upgrade jest (#14993) N/A We already use jest-expo and react-test-renderer at these versions. We already use the jest-expo preset. We're happy with scripts in our package.json.
expo/expo@6877c1f5c [templates] Bump up expo-updates to 0.10.15 (#15257) N/A We don't use this library. Its description: "expo-updates fetches and manages updates to your app stored on a remote server."

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jan 25, 2022
Done by mostly following the changes to Expo's
templates/expo-template-bare-minimum/ in expo/expo@9781212eb.

Expo's description of the new infrastructure is at
  https://blog.expo.dev/whats-new-in-expo-modules-infrastructure-7a7cdda81ebc .

They gave a migration guide that suggested making changes similar to
these, but it didn't end up helping us understand why they were the
right changes to make or what would happen if we made them. That
guide is at
  https://github.com/expo/fyi/blob/main/expo-modules-migration.md .

We've cleared up some of the mystery; see
  zulip#5203 (comment)
and previous commits in this series.

In this commit:

- (Mostly follow expo/expo@9781212eb, as mentioned)

- Also, upgrade all our `expo-*` direct dependencies so that they
  work with the new system. (We upgrade them minimally, to minimize
  having to think about possible unrelated breaking changes right
  now.) Details at
    zulip#5203 (comment) .

- Remove
  android/app/src/main/java/com/zulipmobile/generated/BasePackageList.java,
  since its only import was removed. (Expo didn't have this file in
  version control, and the migration guide didn't mention the file.)

- The Expo commit assumes that our project has done special setup
  for `expo-updates`, `expo-constants`, and `expo-splash-screen`. It
  makes changes to that setup, which we ignore since we don't use
  any of those. If we need them in the future, we'll just look up
  their current setup instructions at the time.

- Don't add an empty Swift file. The migration guide says, "A blank
  Swift file must be created for native modules with Swift files to
  work correctly." With `find node_modules | grep .swift` in our
  project, I see that expo-modules-core and expo-web-browser have
  many Swift files in them, and I don't have any problems building
  or running the app without an empty Swift file. The template app
  doesn't add one either.

- Don't add a Podfile.properties.json file. Like the changes in
  expo/expo@dbd384b22, this would have us put certain config values
  in some new Expo-branded variables. We're happy keeping them
  inline.

- Update our value for `transformIgnorePatterns` in the Jest config,
  following an error when running Jest.

Fixes: zulip#5133
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jan 25, 2022
Done by mostly following the changes to Expo's
templates/expo-template-bare-minimum/ in expo/expo@9781212eb.

Expo's description of the new infrastructure is at
  https://blog.expo.dev/whats-new-in-expo-modules-infrastructure-7a7cdda81ebc .

They gave a migration guide that suggested making changes similar to
these, but it didn't end up helping us understand why they were the
right changes to make or what would happen if we made them. That
guide is at
  https://github.com/expo/fyi/blob/main/expo-modules-migration.md .

We've cleared up some of the mystery; see
  zulip#5203 (comment)
and previous commits in this series.

In this commit:

- (Mostly follow expo/expo@9781212eb, as mentioned)

- Also, upgrade all our `expo-*` direct dependencies so that they
  work with the new system. (We upgrade them minimally, to minimize
  having to think about possible unrelated breaking changes right
  now.) Details at
    zulip#5203 (comment) .

- Remove
  android/app/src/main/java/com/zulipmobile/generated/BasePackageList.java,
  since its only import was removed. (Expo didn't have this file in
  version control, and the migration guide didn't mention the file.)

- The Expo commit assumes that our project has done special setup
  for `expo-updates`, `expo-constants`, and `expo-splash-screen`. It
  makes changes to that setup, which we ignore since we don't use
  any of those. If we need them in the future, we'll just look up
  their current setup instructions at the time.

- Don't add an empty Swift file. The migration guide says, "A blank
  Swift file must be created for native modules with Swift files to
  work correctly." With `find node_modules | grep .swift` in our
  project, I see that expo-modules-core and expo-web-browser have
  many Swift files in them, and I don't have any problems building
  or running the app without an empty Swift file. The template app
  doesn't add one either.

- Don't add a Podfile.properties.json file. Like the changes in
  expo/expo@dbd384b22, this would have us put certain config values
  in some new Expo-branded variables. We're happy keeping them
  inline.

- Update our value for `transformIgnorePatterns` in the Jest config,
  following an error when running Jest.

- Some sub-dependency looks like it's changing the output of
  `generate-webview-js`. Examine that output (looks OK), and commit.

Fixes: zulip#5133
@chrisbobbe chrisbobbe force-pushed the pr-expo-modules branch 5 times, most recently from 7118abb to 8170e1a Compare January 26, 2022 02:12
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Excellent! Thanks for taking so much care with this. Glad to be unblocked again on keeping things upgraded.

This all looks great, except I'd like to skip those node --print changes. Comments about those below.

Comment on lines 116 to 120
apply from: new File(
["node", "--print", "require.resolve('react-native/package.json')"]
.execute(null, rootDir).text.trim(),
"../react.gradle"
)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'm not a fan of shelling out to node --print all over like this. In particular it's slow, because node is slow to start up:

$ time node --print "require.resolve('react-native/package.json')"
/home/greg/z/mobile/node_modules/react-native/package.json

time: 0.068s wall (0.049s u, 0.021s s)

So doing that eight times in the Android build config will add a big chunk of a second, which is sizable when you just want to run a quick unit test or something.

I believe that's not the worst offense that Expo has committed against decent build times -- IIRC doing anything with Gradle got several seconds slower when we first started using unimodules. Still, I'd rather leave it out if there isn't a pressing problem it solves for us.

(And if we were going to have this behavior, I'd definitely want to at least find a way to write it less messily, like with a little helper function. This version gets hard to read and error-prone.)

Previous discussion here:
#4949 (comment)

Comment on lines 93 to 113
// These three (cliPath, hermesCommand, composeSourceMapsPath) were
// added to templates/template-expo-bare-minimum/android in
// expo/expo@9781212eb, expo/expo@87a3d02aa, and
// expo/expo@c75c6c417. I think they're added to help with monorepo
// support (like expo/expo@05f2ed0c7), which we don't need. In this
// case, Expo's solution was to override some bad defaults in React
// Native:
// https://github.com/facebook/react-native/blob/v0.64.3/react.gradle#L38-L46
// As of 2022-01-24, those defaults are unchanged in `main`.
cliPath : new File(
["node", "--print", "require.resolve('react-native/package.json')"]
.execute(null, rootDir).text.trim(),
).getParentFile().getAbsolutePath() + "/cli.js",
hermesCommand : new File(
["node", "--print", "require.resolve('hermes-engine/package.json')"]
.execute(null, rootDir).text.trim()
).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
composeSourceMapsPath: new File(
["node", "--print", "require.resolve('react-native/package.json')"]
.execute(null, rootDir).text.trim()
).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, what a mess. Let's skip this.

If we ever put our code in a different directory structure where node_modules is a different number of levels up, we can fix all our existing references (like the ones the previous commit is about) with pretty much just perl -i -0pe 's</node_modules></../node_modules>g' -- $(git ls-files). And we can add a few lines that similarly configure these three values with another ../ (or whatever's needed) beyond the defaults.

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Jan 28, 2022
Done by mostly following the changes to Expo's
templates/expo-template-bare-minimum/ in expo/expo@9781212eb.

Expo's description of the new infrastructure is at
  https://blog.expo.dev/whats-new-in-expo-modules-infrastructure-7a7cdda81ebc .

They gave a migration guide that suggested making changes similar to
these, but it didn't end up helping us understand why they were the
right changes to make or what would happen if we made them. That
guide is at
  https://github.com/expo/fyi/blob/main/expo-modules-migration.md .

We've cleared up some of the mystery; see
  zulip#5203 (comment)
and previous commits in this series.

In this commit:

- (Mostly follow expo/expo@9781212eb, as mentioned)

- Also, upgrade all our `expo-*` direct dependencies so that they
  work with the new system. (We upgrade them minimally, to minimize
  having to think about possible unrelated breaking changes right
  now.) Details at
    zulip#5203 (comment) .

- Remove
  android/app/src/main/java/com/zulipmobile/generated/BasePackageList.java,
  since its only import was removed. (Expo didn't have this file in
  version control, and the migration guide didn't mention the file.)

- The Expo commit assumes that our project has done special setup
  for `expo-updates`, `expo-constants`, and `expo-splash-screen`. It
  makes changes to that setup, which we ignore since we don't use
  any of those. If we need them in the future, we'll just look up
  their current setup instructions at the time.

- Don't add an empty Swift file. The migration guide says, "A blank
  Swift file must be created for native modules with Swift files to
  work correctly." With `find node_modules | grep .swift` in our
  project, I see that expo-modules-core and expo-web-browser have
  many Swift files in them, and I don't have any problems building
  or running the app without an empty Swift file of our own. The
  template app doesn't add one either.

- Don't add a Podfile.properties.json file. Like the changes in
  expo/expo@dbd384b22, this would have us put certain config values
  in some new Expo-branded variables. We're happy keeping the values
  inline.

- Update our value for `transformIgnorePatterns` in the Jest config,
  following an error when running Jest.

- Looks like some sub-dependency at its updated version wants to
  cause different output for `generate-webview-js`. Examine that
  output (looks OK), and commit.

Fixes: zulip#5133
@chrisbobbe
Copy link
Contributor Author

Great, thanks for the review! Revision pushed.

Specifically, to match Expo's
templates/expo-template-bare-minimum/ios/Podfile at 05f2ed0c7^ in
the expo/expo repo.
Note: If you get an error with lots of lines like
  Entry name 'assets/fonts/AntDesign.ttf' collided
, try
  cd android && rm -rf .gradle/ && ./gradlew clean
.

Done now to follow the change to
templates/expo-template-bare-minimum in expo/expo@f05c8ccb6.

Done by following our instructions at the top of the changed file.

The second time I ran the command in those instructions, I got this
helpful output:

  Welcome to Gradle 6.9!

  Here are the highlights of this release:
   - This is a small backport release.
   - Java 16 can be used to compile when used with Java toolchains
   - Dynamic versions can be used within plugin declarations
   - Native support for Apple Silicon processors

  For more details see https://docs.gradle.org/6.9/release-notes.html

All of that looks nice and helpful.
Like we did in 196a316.

Changelog:
  https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md#1610

This seems to fix the following error we'd see on running

  `tools/test native --all-files`

after switching from Unimodules to Expo modules (zulip#5133):

```
e:
/Users/chrisbobbe/dev/zulip-mobile/node_modules/expo-sqlite/android/src/main/java/expo/modules/sqlite/SQLiteModule.kt:
(106, 55): Type inference failed: Not enough information to infer
parameter T in fun <reified T> arrayOfNulls(size: Int): Array<T?>
Please specify it explicitly.

FAILURE: Build failed with an exception.
```

Inspired to try this by
  expo/expo#15131 (comment) .
From `yarn why` output, I think the relevant bump might be the one
from 1.21.0 to 1.21.1.
Done by mostly following the changes to Expo's
templates/expo-template-bare-minimum/ in expo/expo@9781212eb.

Expo's description of the new infrastructure is at
  https://blog.expo.dev/whats-new-in-expo-modules-infrastructure-7a7cdda81ebc .

They gave a migration guide that suggested making changes similar to
these, but it didn't end up helping us understand why they were the
right changes to make or what would happen if we made them. That
guide is at
  https://github.com/expo/fyi/blob/main/expo-modules-migration.md .

We've cleared up some of the mystery; see
  zulip#5203 (comment)
and previous commits in this series.

In this commit:

- (Mostly follow expo/expo@9781212eb, as mentioned)

- Also, upgrade all our `expo-*` direct dependencies so that they
  work with the new system. (We upgrade them minimally, to minimize
  having to think about possible unrelated breaking changes right
  now.) Details at
    zulip#5203 (comment) .

- Remove
  android/app/src/main/java/com/zulipmobile/generated/BasePackageList.java,
  since its only import was removed. (Expo didn't have this file in
  version control, and the migration guide didn't mention the file.)

- The Expo commit assumes that our project has done special setup
  for `expo-updates`, `expo-constants`, and `expo-splash-screen`. It
  makes changes to that setup, which we ignore since we don't use
  any of those. If we need them in the future, we'll just look up
  their current setup instructions at the time.

- Don't add an empty Swift file. The migration guide says, "A blank
  Swift file must be created for native modules with Swift files to
  work correctly." With `find node_modules | grep .swift` in our
  project, I see that expo-modules-core and expo-web-browser have
  many Swift files in them, and I don't have any problems building
  or running the app without an empty Swift file of our own. The
  template app doesn't add one either.

- Don't add a Podfile.properties.json file. Like the changes in
  expo/expo@dbd384b22, this would have us put certain config values
  in some new Expo-branded variables. We're happy keeping the values
  inline.

- Update our value for `transformIgnorePatterns` in the Jest config,
  following an error when running Jest.

- Looks like some sub-dependency at its updated version wants to
  cause different output for `generate-webview-js`. Examine that
  output (looks OK), and commit.

Fixes: zulip#5133
Note: On iOS, if the app gets to the "Connecting..." stage and
mostly hangs, not responding when you tap one of the bottom tabs,
try stopping and starting Metro a.k.a. `yarn start`.

- Ask `jest-expo` to resolve `react-test-renderer` to the right
  version for `react`/`react-native`.

- Limit `react-native-reanimated` to <2.3.0. I encountered an error
  like the one reported at
    software-mansion/react-native-reanimated#2702
  . I don't know what's causing it, but there's reportedly some
  interaction with expo@43.x, which we recently added. See
    software-mansion/react-native-reanimated#2702 (comment)
  . We don't need 2.3.0 or later, for now. We can investigate more
  later, when we do need it. At that time, we may be on a later
  version of `expo`.

- For a simple way to make sure we're not affected by CVE-2022-0235,
  we wanted to avoid bringing in node-fetch at one of the affected
  versions. According to
    GHSA-r683-j2x4-v87g
  those are

    >= 3.0.0, < 3.1.1
    < 2.6.7

  Unfortunately, there's still one chain, through `expo`, that's
  bringing in node-fetch@1.7.3; see
    expo/expo#16023 (comment)

- Looks like some sub-dependency at its updated version wants to
  cause different output for `generate-webview-js`. Examine that
  output (looks OK), and commit.
@gnprice
Copy link
Member

gnprice commented Jan 28, 2022

Looks good; merging. Thanks again for taking care of this.

@gnprice gnprice merged commit db7a18f into zulip:main Jan 28, 2022
@chrisbobbe chrisbobbe deleted the pr-expo-modules branch January 28, 2022 17:50
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Sep 26, 2022
Done to follow the template-app change in
facebook/react-native@13107fa3d. (Which it looks like RN actually
intended to make in facebook/react-native@85249cafe but forgot;
that's not important, I think.)

We didn't take facebook/react-native@13107fa3d on the path to the RN
v0.67 upgrade because of a blocker that was resolved with the Expo
44 upgrade in expo/expo@3edc37ae4. For details, expand the
`expo-screen-orientation` block in
  zulip#5203 (comment)
and see the comment on the `Installing ExpoModulesCore 0.6.4` output
from `pod install`.

Done by following the "How to upgrade Gradle" instructions at the
top of gradle-wrapper.properties. The result matched the
template-app commit except for upstream's line endings got messed
with because they didn't have Git set up properly to keep them
consistent:
  zulip#5426 (comment) .
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this pull request Nov 22, 2022
Done to follow the template-app change in
facebook/react-native@13107fa3d. (Which it looks like RN actually
intended to make in facebook/react-native@85249cafe but forgot;
that's not important, I think.)

We didn't take facebook/react-native@13107fa3d on the path to the RN
v0.67 upgrade because of a blocker that was resolved with the Expo
44 upgrade in expo/expo@3edc37ae4. For details, expand the
`expo-screen-orientation` block in
  zulip#5203 (comment)
and see the comment on the `Installing ExpoModulesCore 0.6.4` output
from `pod install`.

Done by following the "How to upgrade Gradle" instructions at the
top of gradle-wrapper.properties. The result matched the
template-app commit except for upstream's line endings got messed
with because they didn't have Git set up properly to keep them
consistent:
  zulip#5426 (comment) .
gnprice pushed a commit to chrisbobbe/zulip-mobile that referenced this pull request Nov 23, 2022
Done to follow the template-app change in
facebook/react-native@13107fa3d. (Which it looks like RN actually
intended to make in facebook/react-native@85249cafe but forgot;
that's not important, I think.)

We didn't take facebook/react-native@13107fa3d on the path to the RN
v0.67 upgrade because of a blocker that was resolved with the Expo
44 upgrade in expo/expo@3edc37ae4. For details, expand the
`expo-screen-orientation` block in
  zulip#5203 (comment)
and see the comment on the `Installing ExpoModulesCore 0.6.4` output
from `pod install`.

Done by following the "How to upgrade Gradle" instructions at the
top of gradle-wrapper.properties. The result matched the
template-app commit except for upstream's line endings got messed
with because they didn't have Git set up properly to keep them
consistent:
  zulip#5426 (comment) .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file P1 high-priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to "Expo modules", from react-native-unimodules
2 participants