Skip to content

Commit 9aca455

Browse files
authored
fix: correct package.json exports, update to 0.76 (#257)
BREAKING CHANGE: new setup instructions, fixed package.json exports
1 parent aa9e43d commit 9aca455

28 files changed

+27019
-18562
lines changed

.github/actions/setup/action.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,8 @@ runs:
99
with:
1010
node-version: 'lts/*'
1111

12-
- name: Get yarn cache directory path
13-
id: yarn-cache-dir-path
14-
shell: bash
15-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
16-
17-
- uses: actions/cache@v3
18-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
19-
with:
20-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
21-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock', '**/package.json') }}
22-
restore-keys: |
23-
${{ runner.os }}-yarn-
24-
2512
- name: Install dependencies
2613
run: |
27-
yarn install --cwd example --frozen-lockfile
28-
yarn install --frozen-lockfile
14+
yarn --cwd example install --immutable
15+
yarn install --immutable
2916
shell: bash

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ android/keystores/debug.keystore
6868

6969
# generated by bob
7070
lib/
71+
72+
# https://github.com/yarnpkg/berry/issues/454#issuecomment-530312089
73+
.yarn/*
74+
!.yarn/releases
75+
!.yarn/plugins
76+
!.yarn/patches

.watchmanconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

.yarn/releases/yarn-4.5.2.cjs

Lines changed: 934 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-4.5.2.cjs

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Remember to add tests for your change if possible. Run the unit tests by:
5959
yarn test
6060
```
6161

62-
6362
### Commit message convention
6463

6564
We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:

INSTALL.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
# Installation & Setup
22

3-
Version >= 12 requires React Native 0.73 / Expo 50 or newer (because of `unstable_enablePackageExports`). Use version 11 if you're on older version of RN / Expo.
3+
Version >= 12 requires React Native 0.73 / Expo 50 or newer (because of [`unstable_enablePackageExports`](https://metrobundler.dev/docs/configuration/#unstable_enablepackageexports-experimental)). Use version 11 if you're on older version of RN / Expo.
44

55
Version >= 11 requires React Native 0.71 / Expo 48 or newer. Use version 10 if you're on older version of RN / Expo.
66

7-
1. In your `tsconfig.json`, make sure you have [`"moduleResolution": "NodeNext"`](https://www.typescriptlang.org/tsconfig#moduleResolution) set. This is required for TS to see the typings exported via [package.json `exports`](https://reactnative.dev/blog/2023/06/21/package-exports-support).
7+
1. In your `tsconfig.json`, make sure you set up `module` and `moduleResolution` like this:
8+
9+
```
10+
"module": "ESNext",
11+
"moduleResolution": "Bundler",
12+
```
13+
14+
[source 1](https://twitter.com/mattpocockuk/status/1724462050288587123), [source 2](https://callstack.github.io/react-native-builder-bob/esm). This is required for TS to see the typings exported via [package.json `exports`](https://reactnative.dev/blog/2023/06/21/package-exports-support).
815

916
2. add [`unstable_enablePackageExports`](https://metrobundler.dev/docs/configuration/#unstable_enablepackageexports-experimental) to your metro config (in `metro.config.js`). This field will default to `true` in a future version of RN so don't need to worry about it. This allows us to do some bundle size savings.
1017

11-
```js
12-
// if you use Expo:
13-
const config = getDefaultConfig(__dirname);
14-
// unstable_enablePackageExports: true,
15-
config.resolver.unstable_enablePackageExports = true;
16-
module.exports = config;
17-
18-
// if you use bare React Native:
19-
const config = {
20-
resolver: {
21-
unstable_enablePackageExports: true,
22-
},
23-
};
24-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
25-
```
18+
```js
19+
// if you use Expo:
20+
const config = getDefaultConfig(__dirname);
21+
// unstable_enablePackageExports: true,
22+
config.resolver.unstable_enablePackageExports = true;
23+
module.exports = config;
24+
25+
// if you use bare React Native:
26+
const config = {
27+
resolver: {
28+
unstable_enablePackageExports: true,
29+
},
30+
};
31+
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
32+
```
2633

2734
3. `yarn add react-navigation-header-buttons`
2835

example/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ yarn-error.log
7373
# generated by tests
7474
requires-android.txt
7575
requires-ios.txt
76+
77+
# prebuild
78+
android/
79+
ios/

example/.yarn/install-state.gz

1.26 MB
Binary file not shown.

example/.yarn/releases/yarn-4.5.2.cjs

Lines changed: 934 additions & 0 deletions
Large diffs are not rendered by default.

example/.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarnPath: .yarn/releases/yarn-4.5.2.cjs

example/app.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
"resizeMode": "contain",
1212
"backgroundColor": "#ffffff"
1313
},
14-
"assetBundlePatterns": [
15-
"**/*"
16-
],
14+
"assetBundlePatterns": ["**/*"],
1715
"ios": {
1816
"supportsTablet": true,
1917
"bundleIdentifier": "com.vonovak.navbar-buttons-demo"

example/package.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,36 @@
77
"ios": "expo run:ios",
88
"web": "expo start --web",
99
"fix-deps": "npx expo install --check",
10-
"requires-ios": "yarn metro get-dependencies --entry-file App.js --platform ios --output requires-ios.txt",
11-
"requires-android": "yarn metro get-dependencies --entry-file App.js --platform android --output requires-android.txt"
10+
"requires-ios": "npx metro get-dependencies --entry-file App.js --platform ios --output requires-ios.txt",
11+
"requires-android": "npx metro get-dependencies --entry-file App.js --platform android --output requires-android.txt"
1212
},
1313
"dependencies": {
14-
"@expo/react-native-action-sheet": "^4.0.1",
15-
"@react-native-menu/menu": "^0.9.1",
16-
"@react-navigation/bottom-tabs": "^6.5.9",
17-
"@react-navigation/native": "^6.1.6",
18-
"@react-navigation/native-stack": "^6.9.12",
19-
"@react-navigation/stack": "^6.3.16",
20-
"expo": "~50.0.17",
21-
"expo-splash-screen": "~0.26.4",
22-
"expo-status-bar": "~1.11.1",
23-
"react": "18.2.0",
24-
"react-dom": "18.2.0",
25-
"react-native": "0.73.6",
26-
"react-native-gesture-handler": "~2.14.0",
27-
"react-native-safe-area-context": "4.8.2",
28-
"react-native-screens": "~3.29.0",
29-
"react-native-web": "~0.19.6"
14+
"@expo/react-native-action-sheet": "^4.1.0",
15+
"@react-native-menu/menu": "^1.1.6",
16+
"@react-navigation/bottom-tabs": "^7.0.7",
17+
"@react-navigation/native": "^7.0.4",
18+
"@react-navigation/native-stack": "^7.1.1",
19+
"@react-navigation/stack": "^7.0.6",
20+
"expo": "~52.0.11",
21+
"expo-splash-screen": "~0.29.13",
22+
"expo-status-bar": "~2.0.0",
23+
"react": "18.3.1",
24+
"react-dom": "18.3.1",
25+
"react-error-boundary": "^4.1.2",
26+
"react-native": "0.76.3",
27+
"react-native-gesture-handler": "~2.20.2",
28+
"react-native-safe-area-context": "4.12.0",
29+
"react-native-screens": "~4.1.0",
30+
"react-native-web": "~0.19.13"
3031
},
3132
"resolutions": {
3233
"@types/react": "18.2.79"
3334
},
3435
"devDependencies": {
35-
"@babel/core": "^7.20.0",
36+
"@babel/core": "^7.25.2",
3637
"@expo/webpack-config": "~19.0.1",
3738
"babel-loader": "^8.1.0"
3839
},
39-
"private": true
40+
"private": true,
41+
"packageManager": "yarn@4.5.2"
4042
}

example/src/App.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useContext } from 'react';
22
import { NavigationContainer } from '@react-navigation/native';
33
import { HeaderButtonsProvider } from 'react-navigation-header-buttons/HeaderButtonsProvider';
4+
// import { HeaderButtonsProviderDropdownMenu } from 'react-navigation-header-buttons/HeaderButtonsProviderDropdownMenu';
45
// just for custom overflow menu onPress action
56
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
67
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
@@ -10,6 +11,10 @@ import { screens } from './NavTypes';
1011
import { TabScreenWithButtons } from './screens/TabScreenWithButtons';
1112
import { createNativeStackNavigator as createStackNavigator } from '@react-navigation/native-stack';
1213
const stackType = 'native';
14+
import { ErrorBoundary } from 'react-error-boundary';
15+
import { View, Text } from 'react-native';
16+
import { SafeAreaProvider } from 'react-native-safe-area-context';
17+
1318
// import { createStackNavigator } from '@react-navigation/stack';
1419
// const stackType = 'js';
1520

@@ -62,20 +67,32 @@ const ThemedApp = () => {
6267
const { theme } = useContext(ThemeContext);
6368
return (
6469
<NavigationContainer theme={theme}>
65-
<StatusBar style="light" backgroundColor="darkgreen" />
66-
<ActionSheetProvider>
67-
<HeaderButtonsProvider stackType={stackType}>
68-
<TabbedApp />
69-
</HeaderButtonsProvider>
70-
</ActionSheetProvider>
70+
<SafeAreaProvider>
71+
<StatusBar style="light" backgroundColor="darkgreen" />
72+
<ActionSheetProvider>
73+
<HeaderButtonsProvider stackType={stackType}>
74+
<TabbedApp />
75+
</HeaderButtonsProvider>
76+
</ActionSheetProvider>
77+
</SafeAreaProvider>
7178
</NavigationContainer>
7279
);
7380
};
7481

7582
export default function App() {
7683
return (
77-
<ThemeProvider>
78-
<ThemedApp />
79-
</ThemeProvider>
84+
<ErrorBoundary FallbackComponent={Fallback}>
85+
<ThemeProvider>
86+
<ThemedApp />
87+
</ThemeProvider>
88+
</ErrorBoundary>
89+
);
90+
}
91+
function Fallback({ error }: { error: Error }) {
92+
return (
93+
<View>
94+
<Text>Something went wrong:</Text>
95+
<Text style={{ color: 'red' }}>{error?.message}</Text>
96+
</View>
8097
);
8198
}

0 commit comments

Comments
 (0)