Skip to content

Commit 529822d

Browse files
committed
feat(web): make example start in web mode
1 parent 8a963c9 commit 529822d

8 files changed

+53
-34
lines changed

CONTRIBUTING.md

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Some notes about example app:
2929
```
3030
On android change `newArchEnabled=true` in `example/android/gralde.properties`
3131

32+
### Running example app for Web
33+
34+
```
35+
npx expo start -c --web
36+
```
37+
3238

3339
## Best practices for PR's
3440
- If you plan to work on a bigger feature, please open a discussion, to discuss the best way to address it

example/app.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2-
"name": "RNMapboxGLExample",
3-
"displayName": "RNMapboxGLExample"
2+
"expo": {
3+
"name": "RNMapboxGLExample",
4+
"displayName": "RNMapboxGLExample",
5+
"web": {
6+
"bundler": "metro",
7+
"output": "single"
8+
}
9+
}
410
}

example/babel.config.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
3-
plugins: [['@babel/plugin-transform-private-methods', { loose: true }]],
1+
const path = require('path');
2+
3+
const pak = require('../package.json');
4+
5+
module.exports = function (api) {
6+
api.cache(true);
7+
8+
return {
9+
presets: ['babel-preset-expo'],
10+
plugins: [
11+
[
12+
'module-resolver',
13+
{
14+
extensions: ['.tsx', '.ts', '.js', '.json'],
15+
alias: {
16+
// For development, we want to alias the library to the source
17+
[pak.name]: path.join(__dirname, '..', pak.source),
18+
},
19+
},
20+
],
21+
],
22+
};
423
};

example/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { AppRegistry } from 'react-native';
22

33
import App from './src/App';
4-
import { name as appName } from './app.json';
4+
import appConfig from './app.json';
5+
6+
const {
7+
expo: { name: appName },
8+
} = appConfig;
59

610
AppRegistry.registerComponent(appName, () => App);

example/package.json

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"name": "RNMapboxGLExample",
3+
"main": "expo/AppEntry.js",
34
"version": "1.0.0",
45
"private": true,
56
"scripts": {
67
"android": "yarn react-native run-android",
78
"ios": "yarn react-native run-ios --simulator=\"iPhone SE (3rd generation)\"",
9+
"web": "expo start -c --web",
810
"pod:install": "cd ios && pod install",
911
"start": "yarn react-native start",
1012
"postinstall": "node ./scripts/set_access_token.js",
@@ -35,37 +37,37 @@
3537
"moment": "^2.24.0",
3638
"prop-types": "^15.7.2",
3739
"react": "18.2.0",
38-
"react-native": "0.74.0",
40+
"react-native": "0.74.1",
3941
"react-native-safe-area-context": "4.10.1",
4042
"react-native-screens": "3.31.1",
4143
"react-native-vector-icons": "9.2.0",
4244
"@rnmapbox/maps": "link:../"
4345
},
4446
"optionalDependencies": {
45-
"@expo/webpack-config": "^0.17.2",
47+
"@expo/metro-runtime": "3.2.1",
4648
"@types/responselike": "1.0.0",
47-
"expo": "46.0.0",
48-
"mapbox-gl": "^2.9.2",
49-
"react-dom": "^18.2.0",
50-
"react-native-web": "0.18.7"
49+
"expo": "~51.0.1",
50+
"mapbox-gl": "^3.3.0",
51+
"react-dom": "18.2.0",
52+
"react-native-web": "~0.19.10"
5153
},
5254
"devDependencies": {
53-
"@babel/core": "^7.20.0",
55+
"@babel/core": "^7.24.0",
5456
"@babel/plugin-transform-private-methods": "^7.23.3",
5557
"@babel/preset-env": "^7.20.0",
5658
"@babel/runtime": "^7.20.0",
5759
"@react-native/babel-preset": "^0.74.2",
5860
"@react-native/eslint-config": "^0.74.1",
5961
"@react-native/metro-config": "^0.74.2",
6062
"@react-native/typescript-config": "^0.74.1",
61-
"@types/react": "^18.2.6",
63+
"@types/react": "^18.2.45",
6264
"@types/react-test-renderer": "^18.0.0",
6365
"babel-jest": "^29.6.3",
6466
"eslint": "^8.19.0",
6567
"jest": "^29.6.3",
6668
"prettier": "^2.8.8",
6769
"react-test-renderer": "18.2.0",
68-
"typescript": "^5.0.4",
70+
"typescript": "^5.3.3",
6971
"detox": "^20.12.1",
7072
"glob-to-regexp": "^0.4.0",
7173
"babel-plugin-module-resolver": "^5.0.0",

example/tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"baseUrl": ".",
77
"paths": {
88
"@rnmapbox/maps": ["../src"],
9-
"react": ["./node_modules/@types/react"],
109
}
1110
},
1211
"include": ["global.d.ts", "index.js", "./__tests__/dumpExamplesJson.ts", "jest.config.ts", "jest.setup.ts"]

example/webpack.config.js

-17
This file was deleted.

rnmapbox-maps.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def $RNMapboxMaps.pre_install(installer)
193193
end
194194

195195
## RNMapboxMapsDownloadToken
196-
# expo does not supports `.netrc`, so we need to patch curl commend used by cocoapods to pass the credentials
196+
# expo does not support `.netrc`, so we need to patch curl command used by cocoapods to pass the credentials
197197

198198
if $RNMapboxMapsDownloadToken
199199
module AddCredentialsToCurlWhenDownloadingMapbox

0 commit comments

Comments
 (0)