Skip to content

Commit 21a11ec

Browse files
committed
feat: add expo managed tester app
1 parent 2847e11 commit 21a11ec

File tree

13 files changed

+1345
-87
lines changed

13 files changed

+1345
-87
lines changed

.changeset/full-nails-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@callstack/repack-plugin-expo": minor
3+
---
4+
5+
Add Expo Managed tester application

apps/tester-expo-app/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Build artifacts
2+
.expo
3+
build
4+
5+
# Native directories
6+
/android
7+
/ios

apps/tester-expo-app/app.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "tester-expo-app",
3+
"slug": "tester-expo-app",
4+
"scheme": "testerexpoapp",
5+
"version": "0.0.1",
6+
"android": {
7+
"package": "com.testerexpoapp"
8+
},
9+
"ios": {
10+
"bundleIdentifier": "com.testerexpoapp"
11+
},
12+
"plugins": [
13+
["expo-router", { "root": "./src/screens" }],
14+
"@callstack/repack-plugin-expo/plugin"
15+
]
16+
}

apps/tester-expo-app/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { AppRegistry } from 'react-native';
2+
import Application from './src/App.tsx';
3+
4+
AppRegistry.registerComponent('main', () => Application);

apps/tester-expo-app/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "tester-expo-app",
3+
"version": "0.0.1",
4+
"private": true,
5+
"main": "./index.js",
6+
"scripts": {
7+
"start": "react-native start",
8+
"ios": "react-native run-ios --no-packager",
9+
"android": "react-native run-android --no-packager",
10+
"prebuild": "expo prebuild"
11+
},
12+
"dependencies": {
13+
"expo": "^53.0.22",
14+
"expo-linking": "~7.1.7",
15+
"expo-router": "~5.1.5",
16+
"react": "19.0.0",
17+
"react-native": "0.79.5",
18+
"react-native-safe-area-context": "5.4.0",
19+
"react-native-screens": "~4.11.1"
20+
},
21+
"devDependencies": {
22+
"@babel/core": "^7.25.2",
23+
"@callstack/repack": "workspace:*",
24+
"@callstack/repack-plugin-expo": "workspace:*",
25+
"@react-native-community/cli": "catalog:testers",
26+
"@react-native-community/cli-platform-android": "catalog:testers",
27+
"@react-native-community/cli-platform-ios": "catalog:testers",
28+
"@react-native/babel-preset": "catalog:testers",
29+
"@react-native/typescript-config": "catalog:testers",
30+
"@rspack/core": "catalog:",
31+
"@swc/core": "^1.13.3",
32+
"@swc/helpers": "catalog:",
33+
"@types/react": "catalog:testers",
34+
"react-native-test-app": "catalog:testers",
35+
"typescript": "catalog:"
36+
}
37+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { configureProjects } = require('react-native-test-app');
2+
3+
const useWebpack = Boolean(process.env.USE_WEBPACK);
4+
5+
module.exports = {
6+
project: configureProjects({
7+
android: {
8+
sourceDir: 'android',
9+
},
10+
ios: {
11+
sourceDir: 'ios',
12+
},
13+
}),
14+
commands: useWebpack
15+
? require('@callstack/repack/commands/webpack')
16+
: require('@callstack/repack/commands/rspack'),
17+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { createRequire } from 'node:module';
2+
import { dirname, resolve } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
import * as Repack from '@callstack/repack';
6+
import { ExpoPlugin } from '@callstack/repack-plugin-expo';
7+
import { IgnorePlugin } from '@rspack/core';
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = dirname(__filename);
11+
12+
const require = createRequire(import.meta.url);
13+
14+
export default Repack.defineRspackConfig({
15+
context: __dirname,
16+
entry: './index.js',
17+
resolve: {
18+
...Repack.getResolveOptions({ enablePackageExports: true }),
19+
alias: {
20+
// Alias both react and react-native to ensure that we don't end up with multiple versions
21+
// of these libraries in the bundle.
22+
//
23+
// This is needed in these monorepo setups where there are multiple copies of react
24+
// and react-native in the node_modules.
25+
react: require.resolve('react'),
26+
'react-native': require.resolve('react-native'),
27+
},
28+
},
29+
module: {
30+
rules: [
31+
...Repack.getJsTransformRules(),
32+
...Repack.getAssetTransformRules(),
33+
],
34+
},
35+
plugins: [
36+
new Repack.RepackPlugin(),
37+
new ExpoPlugin({
38+
router: {
39+
root: resolve('./src/screens'),
40+
},
41+
}),
42+
43+
// Ignore @react-native-masked-view warnings
44+
new IgnorePlugin({ resourceRegExp: /^@react-native-masked-view/ }),
45+
],
46+
});

apps/tester-expo-app/src/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ExpoRoot } from 'expo-router';
2+
import { ctx } from 'expo-router/_ctx';
3+
4+
console.log(ctx.keys());
5+
6+
export default function Application() {
7+
return <ExpoRoot context={ctx} />;
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Stack } from 'expo-router';
2+
3+
export default function RootLayout() {
4+
return (
5+
<Stack>
6+
<Stack.Screen name="index" options={{ headerTitle: 'Home' }} />
7+
<Stack.Screen name="about" options={{ headerTitle: 'About' }} />
8+
</Stack>
9+
);
10+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useRouter } from 'expo-router';
2+
import { Button, ScrollView } from 'react-native';
3+
4+
export default function AboutScreen() {
5+
const router = useRouter();
6+
7+
return (
8+
<ScrollView
9+
contentContainerStyle={{
10+
flex: 1,
11+
justifyContent: 'center',
12+
alignItems: 'center',
13+
}}
14+
>
15+
<Button title="Go back" onPress={router.back} />
16+
</ScrollView>
17+
);
18+
}

0 commit comments

Comments
 (0)