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

[apps] Enforce 'util' version to fix errors on import #15698

Merged
merged 1 commit into from Dec 27, 2021

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Dec 23, 2021

Why

the js import error: Error: Requiring module "../../packages/expo-notifications/build/index.js", which threw an exception: TypeError: Cannot read property 'isPromise' of undefined, js engine: hermes will show in red box and break detox testing.

the dependency: updateDevicePushTokenAsync.ts -> @ide/backoff -> require('assert') -> require('util') and util.types.isPromise.

util.types.isPromise is added after util@0.12, but the old util be hoisted to workspace:

=> Found "util@0.10.4"
info Reasons this module exists
   - "_project_#native-component-list#path" depends on it
   - Hoisted from "_project_#native-component-list#path#util"
info Disk size without dependencies: "68KB"
info Disk size with unique dependencies: "88KB"
info Disk size with transitive dependencies: "88KB"
info Number of shared dependencies: 1
=> Found "assert#util@0.12.4"
info This module exists because "_project_#expo-notifications#assert" depends on it.
info Disk size without dependencies: "56KB"
info Disk size with unique dependencies: "376KB"
info Disk size with transitive dependencies: "7.28MB"
info Number of shared dependencies: 23
=> Found "node-libs-browser#util@0.11.1"
info This module exists because "_project_#expo-yarn-workspaces#@expo#webpack-config#webpack#node-libs-browser" depends on it.
info Disk size without dependencies: "48KB"
info Disk size with unique dependencies: "68KB"
info Disk size with transitive dependencies: "68KB"
info Number of shared dependencies: 1
=> Found "node-libs-browser#assert#util@0.10.3"
info This module exists because "_project_#expo-yarn-workspaces#@expo#webpack-config#webpack#node-libs-browser#assert" depends on it.
info Disk size without dependencies: "96KB"
info Disk size with unique dependencies: "116KB"
info Disk size with transitive dependencies: "116KB"
info Number of shared dependencies: 1

in theory, from assert to import util, it should import the nested one. so it should not be a big problem even the old util be hoisted to workspace.

however, in #15621, the new @expo/metro-config@~0.3.7, we added nodeModulesPaths to metro config. the old metro resolver will prepend nodeModulesPaths before all resolution path. this will make assert to import the old util from workspace. this issue is fixed in the latest metro version: facebook/metro#738.

How

have a workaround to force util@~0.12.4 for all dependencies

Test Plan

test-suite ci green

Checklist

  • n/a Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
  • This diff will work correctly for expo build (eg: updated @expo/xdl).
  • This diff will work correctly for expo prebuild & EAS Build (eg: updated a module plugin).

@expo-bot expo-bot added the bot: passed checks ExpoBot has nothing to complain about label Dec 23, 2021
@Kudo Kudo changed the title [android] Fix bare-expo js import error [bare-expo] Fix CI broken from js import error Dec 23, 2021
@Kudo Kudo marked this pull request as ready for review December 23, 2021 15:26
@Kudo Kudo requested a review from EvanBacon December 23, 2021 15:26
@tsapeta tsapeta changed the title [bare-expo] Fix CI broken from js import error [apps] Enforce 'util' version to fix errors on import Dec 27, 2021
@tsapeta tsapeta merged commit 03e40ce into master Dec 27, 2021
@tsapeta tsapeta deleted the @kudo/fix-util-resolution branch December 27, 2021 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants