Skip to content

Commit 1e31449

Browse files
committed
fix: fix web support in expo example
1 parent fc87440 commit 1e31449

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

.github/workflows/build-templates.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ jobs:
168168
run: |
169169
yarn test
170170
171+
- name: Build example (Web)
172+
working-directory: ${{ env.work_dir }}
173+
if: matrix.language == 'js'
174+
run: |
175+
yarn example expo export:web
176+
171177
- name: Install JDK
172178
if: env.android_build == 1
173179
uses: actions/setup-java@v3

packages/create-react-native-library/src/utils/generateExampleApp.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,20 @@ const PACKAGES_TO_REMOVE = [
3232
'typescript',
3333
];
3434

35-
const PACKAGES_TO_ADD = {
35+
const PACKAGES_TO_ADD_DEV = {
3636
'babel-plugin-module-resolver': '^4.1.0',
3737
};
3838

39+
const PACKAGES_TO_ADD_WEB = {
40+
'react-dom': '18.1.0',
41+
'react-native-web': '~0.18.9',
42+
};
43+
44+
const PACKAGES_TO_ADD_WEB_DEV = {
45+
'@expo/webpack-config': '^0.17.2',
46+
'babel-loader': '^8.1.0',
47+
};
48+
3949
export default async function generateExampleApp({
4050
type,
4151
dest,
@@ -101,7 +111,7 @@ export default async function generateExampleApp({
101111
// Remove Jest config for now
102112
delete pkg.jest;
103113

104-
const { scripts, devDependencies } = pkg;
114+
const { scripts, dependencies, devDependencies } = pkg;
105115

106116
delete scripts.test;
107117
delete scripts.lint;
@@ -115,7 +125,12 @@ export default async function generateExampleApp({
115125
delete devDependencies[pkg];
116126
});
117127

118-
Object.assign(devDependencies, PACKAGES_TO_ADD);
128+
Object.assign(devDependencies, PACKAGES_TO_ADD_DEV);
129+
130+
if (type === 'expo') {
131+
Object.assign(dependencies, PACKAGES_TO_ADD_WEB);
132+
Object.assign(devDependencies, PACKAGES_TO_ADD_WEB_DEV);
133+
}
119134

120135
await fs.writeFile(
121136
path.join(directory, 'package.json'),

packages/create-react-native-library/templates/common/$package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"example": "yarn --cwd example",
3636
<% if (example === 'native' && turborepo) { -%>
3737
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
38-
"build:ios": "cd example/ios && xcodebuild -workspace <%- project.name %>Example.xcworkspace -scheme <%- project.name %>Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf GCC_OPTIMIZATION_LEVEL=fast GCC_PRECOMPILE_PREFIX_HEADER=YES GCC_UNROLL_LOOPS=YES COMPILER_INDEX_STORE_ENABLE=NO",
38+
"build:ios": "cd example/ios && xcodebuild -workspace <%- project.name %>Example.xcworkspace -scheme <%- project.name %>Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
3939
<% } -%>
4040
<% if (example === 'native') { -%>
4141
"bootstrap": "yarn example && yarn install && yarn example pods",

packages/create-react-native-library/templates/native-common/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def resolveReactNativeDirectory() {
5151

5252
throw new Exception(
5353
"${project.name}: Failed to resolve 'react-native' in the project. " +
54-
"Altenatively, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
54+
"If you have a non-standard project structure, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
5555
)
5656
}
5757

0 commit comments

Comments
 (0)