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

fix(expo-battery): add missing peer dependency references to react #30458

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

byCedric
Copy link
Member

Why

As mentioned in sdk sync, we need correct dependency chains to make different package managers and monorepos more stable. For isolated modules, this is a requirement as the dependency otherwise isn't linked into the isolated folder.

How

Added peer dependency reference to react: *, it's currently imported from:

Note

  • There are imports to expo-modules-core, which need another pass after deciding how to resolve this (e.g. through an expo/modules-core export)

Test Plan

  • $ pnpm add expo-battery
  • $ node --print "require.resolve('react/package.json', { paths: [require.resolve('expo-battery/package.json')] })"
    • This should be resolved to react

Checklist

@byCedric byCedric requested a review from behenate as a code owner July 17, 2024 14:43
@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Jul 17, 2024
byCedric added a commit that referenced this pull request Jul 17, 2024
…ct-native` (#30449)

Note, this is a collection of PRs for each SDK library individually.

<details><summary>All related PRs</summary>

- #30454
- #30455
- #30456
- #30457
- #30458
- #30459
- #30460
- #30461
- #30462
- #30463
- #30464
- #30465
- #30466
- #30467
- #30468
- #30469
- #30470
- #30471
- #30473
- #30474
- #30475
- #30476
- #30477
- #30478
- #30479
- #30480
- #30481
- #30482
- #30483
- #30484
- #30485
- #30486
- #30487
- #30488
- #30489
- #30490

</details>

# Why

As mentioned in sdk sync, we need correct dependency chains to make
different package managers and monorepos more stable. For isolated
modules, this is a requirement as the dependency otherwise isn't linked
into the isolated folder.

# How

Added peer dependency reference to `react: *`, it's currently imported
from:
-
[src/devtools/index.ts](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/devtools/index.ts)
-
[src/environment/DevLoadingView.tsx](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/environment/DevLoadingView.tsx)
-
[src/hooks/useEvent.ts](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/hooks/useEvent.ts)
-
[src/launch/registerRootComponent.tsx](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/launch/registerRootComponent.tsx)
- _type only_
-
[src/launch/withDevTools.ios.tsx](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/launch/withDevTools.ios.tsx)
- _type only_
-
[src/launch/withDevTools.web.tsx](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/launch/withDevTools.web.tsx)
- _type only_

Added peer dependency reference to `react-native: *`, it's currently
imported from:
-
[src/devtools/getConnectionInfo.native.ts](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/devtools/getConnectionInfo.native.ts)
-
[src/environment/DevLoadingView.tsx](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/environment/DevLoadingView.tsx)
-
[src/environment/DevLoadingViewNativeModule.native.ts](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/environment/DevLoadingViewNativeModule.native.ts)
-
[src/environment/getInitialSafeArea.native.ts](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/environment/getInitialSafeArea.native.ts)
-
[src/launch/registerRootComponent.tsx](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/launch/registerRootComponent.tsx)
-
[src/winter/runtime.native.ts](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/src/winter/runtime.native.ts)

# Note

There are more incorrect dependency chains, these can't be resolved by
adding a peer dependency and require another approach.

-
[scripts/compose-source-maps.js](https://github.com/expo/expo/blob/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/scripts/compose-source-maps.js#L15)
- importing `metro-source-map`
-
[react-native.config.js](https://github.com/expo/expo/tree/ebc396fe16b225d616eb7e0919028c59db805a1e/packages/expo/react-native.config.js)
- importing `@react-native-community/cli-tools`

# Test Plan

- `$ pnpm add expo`
- `$ node --print "require.resolve('react/package.json', { paths:
[require.resolve('expo/package.json')] })"`
  - This should be resolved to `react` 
- `$ node --print "require.resolve('react-native/package.json', { paths:
[require.resolve('expo/package.json')] })"`
  - This should be resolved to `react-native` 

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [x] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Jul 17, 2024
@byCedric byCedric merged commit ea44bed into main Jul 17, 2024
17 checks passed
@byCedric byCedric deleted the @bycedric/expo-battery/fix-dependency-chain branch July 17, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants