Skip to content

Commit

Permalink
refact: example apps file structure and ts support (#2174)
Browse files Browse the repository at this point in the history
## Description

This PR intents to simplify example and test example apps file structure
and fix typescript support.

## Changes

- removed package.json inside common dir and adjusted metro config to
work with those dependencies
- relocated app.js file inside test examples common dir to match
examples dir structure
- added submodules paths to the root tsconfig and extended it in the
example dirs

<!--

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before

### After

-->

## Test code and steps to reproduce

- Build and check wether the example and test example app works well on
both paper and fabric architectures.
- Have a look at the imports in any file inside apps/ directory and
enjoy less red marks + full typescript support for linked packages!

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
  • Loading branch information
alduzy committed Jun 11, 2024
1 parent 2151f20 commit 0526879
Show file tree
Hide file tree
Showing 19 changed files with 135 additions and 10,974 deletions.
4 changes: 2 additions & 2 deletions Example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1486,10 +1486,10 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNReanimated: 7ad0f08a845cb60955ee5d461d2156d7b9707118
RNScreens: b32a9ff15bea7fcdbe5dff6477bc503f792b1208
RNScreens: 83bd0cc27e5d22a58e1bdd560d0e1318e1583b41
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: b9a182ab00cf25926e7f79657d08c5d23c2d03b0
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

PODFILE CHECKSUM: 7bffbf744a07be2a9e6cfb9359c3debcc9873875

Expand Down
6 changes: 0 additions & 6 deletions Example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ const config = {
// to various errors. To mitigate this we define below custom request resolver, hijacking requests to conflicting modules and manually
// resolving appropriate files. **Most likely** this can be achieved by proper usage of blockList but I found this method working ¯\_(ツ)_/¯
resolveRequest: (context, moduleName, platform) => {
if (moduleName.startsWith('@react-navigation')) {
// For some reason, react-navigation packages don't want to resolve from
// the project's node_modules, so we need to use standard Metro resolver.
return context.resolveRequest(context, moduleName, platform);
}

if (moduleName === 'react-native-screens') {
return {
filePath: path.join(rnsRoot, 'src', 'index.tsx'),
Expand Down
1 change: 0 additions & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@types/jest": "^29.2.5",
"@types/react": "^18.2.72",
"@types/react-native": "0.72.2",
"@types/react-native-restart": "^0.0.0",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"detox": "^20.17.0",
Expand Down
7 changes: 1 addition & 6 deletions Example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"extends": "../tsconfig.json",
"allowJs": true,
"include": ["**/*"],
"compilerOptions": {
"baseUrl": "."
}
"extends": "../tsconfig.json"
}
8 changes: 0 additions & 8 deletions Example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3090,13 +3090,6 @@ __metadata:
languageName: node
linkType: hard

"@types/react-native-restart@npm:^0.0.0":
version: 0.0.0
resolution: "@types/react-native-restart@npm:0.0.0"
checksum: 10c0/000e6666920edeba9d680b01cf50c9237accc4b12ffe6d577d332260844cf231a0179456219cc5ecd0268d2e0783811e689e6412b664a19be0f532b9b8216723
languageName: node
linkType: hard

"@types/react-native@npm:0.72.2":
version: 0.72.2
resolution: "@types/react-native@npm:0.72.2"
Expand Down Expand Up @@ -3398,7 +3391,6 @@ __metadata:
"@types/jest": "npm:^29.2.5"
"@types/react": "npm:^18.2.72"
"@types/react-native": "npm:0.72.2"
"@types/react-native-restart": "npm:^0.0.0"
"@types/react-test-renderer": "npm:^18.0.0"
babel-jest: "npm:^29.6.3"
detox: "npm:^20.17.0"
Expand Down
6 changes: 3 additions & 3 deletions FabricExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ SPEC CHECKSUMS:
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 16b8530de1b383cdada1476cf52d1b52f0692cbc
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df
RCTDeprecation: efb313d8126259e9294dc4ee0002f44a6f676aba
RCTRequired: f49ea29cece52aee20db633ae7edc4b271435562
RCTTypeSafety: a11979ff0570d230d74de9f604f7d19692157bc4
Expand Down Expand Up @@ -1573,10 +1573,10 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 156548e18203327173a764c6932a3f52e90cb9cd
RNReanimated: 2f33b2f8c79c456ce3858a7cd2e07460eb5f61e0
RNScreens: 63fe8222c172a79f5c30dd1aefaeb369c6eb57b6
RNScreens: 677b8292cba019c77fa6740dfe248c232d819e91
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: b9a182ab00cf25926e7f79657d08c5d23c2d03b0
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

PODFILE CHECKSUM: c270e520a11547ef636f117b51709c3ed2b291f7

Expand Down
1 change: 1 addition & 0 deletions FabricExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@react-navigation/bottom-tabs": "link:../react-navigation/packages/bottom-tabs/",
"@react-navigation/core": "link:../react-navigation/packages/core/",
"@react-navigation/drawer": "link:../react-navigation/packages/drawer/",
"@react-navigation/elements": "link:../react-navigation/packages/elements/",
"@react-navigation/native": "link:../react-navigation/packages/native/",
"@react-navigation/native-stack": "link:../react-navigation/packages/native-stack/",
Expand Down
2 changes: 1 addition & 1 deletion FabricExample/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@react-native/typescript-config/tsconfig.json"
"extends": "../tsconfig.json"
}
7 changes: 7 additions & 0 deletions FabricExample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,12 @@ __metadata:
languageName: node
linkType: soft

"@react-navigation/drawer@link:../react-navigation/packages/drawer/::locator=FabricExample%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@react-navigation/drawer@link:../react-navigation/packages/drawer/::locator=FabricExample%40workspace%3A."
languageName: node
linkType: soft

"@react-navigation/elements@link:../react-navigation/packages/elements/::locator=FabricExample%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@react-navigation/elements@link:../react-navigation/packages/elements/::locator=FabricExample%40workspace%3A."
Expand Down Expand Up @@ -3137,6 +3143,7 @@ __metadata:
"@react-native/typescript-config": "npm:0.74.83"
"@react-navigation/bottom-tabs": "link:../react-navigation/packages/bottom-tabs/"
"@react-navigation/core": "link:../react-navigation/packages/core/"
"@react-navigation/drawer": "link:../react-navigation/packages/drawer/"
"@react-navigation/elements": "link:../react-navigation/packages/elements/"
"@react-navigation/native": "link:../react-navigation/packages/native/"
"@react-navigation/native-stack": "link:../react-navigation/packages/native-stack/"
Expand Down
4 changes: 2 additions & 2 deletions FabricTestExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1562,9 +1562,9 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 156548e18203327173a764c6932a3f52e90cb9cd
RNReanimated: 2f33b2f8c79c456ce3858a7cd2e07460eb5f61e0
RNScreens: 63fe8222c172a79f5c30dd1aefaeb369c6eb57b6
RNScreens: 677b8292cba019c77fa6740dfe248c232d819e91
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: b9a182ab00cf25926e7f79657d08c5d23c2d03b0
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

PODFILE CHECKSUM: 67b3d295da87c29349179e51bb3526b67059b646

Expand Down
2 changes: 1 addition & 1 deletion TestsExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ SPEC CHECKSUMS:
ReactCommon: f42444e384d82ab89184aed5d6f3142748b54768
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNReanimated: 7ad0f08a845cb60955ee5d461d2156d7b9707118
RNScreens: b32a9ff15bea7fcdbe5dff6477bc503f792b1208
RNScreens: 83bd0cc27e5d22a58e1bdd560d0e1318e1583b41
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 348f8b538c3ed4423eb58a8e5730feec50bce372

Expand Down
58 changes: 0 additions & 58 deletions apps/examples/package.json

This file was deleted.

5 changes: 1 addition & 4 deletions apps/examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"extends": "@react-native/typescript-config/tsconfig.json",
"extends": "../../tsconfig.json",
"include": ["**/*.ts", "**/*.tsx", "**/*.js"],
"compilerOptions": {
"baseUrl": "."
}
}
Loading

0 comments on commit 0526879

Please sign in to comment.