Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extract web example #2333

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions web-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules/
.expo/
dist/
npm-debug.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
*.orig.*
web-build/

# macOS
.DS_Store

3 changes: 3 additions & 0 deletions web-example/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import App from '../apps/examples';

export default App;
13 changes: 13 additions & 0 deletions web-example/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"expo": {
"name": "web-example",
"slug": "web-example",
"version": "1.0.0",
"web": {
"favicon": "./assets/favicon.png"
},
"plugins": [
"expo-asset"
]
}
}
Binary file added web-example/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions web-example/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
};
10 changes: 10 additions & 0 deletions web-example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import '@expo/metro-runtime';

import { registerRootComponent } from 'expo';

import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
30 changes: 30 additions & 0 deletions web-example/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');

const config = getDefaultConfig(__dirname);

// npm v7+ will install ../node_modules/react-native because of peerDependencies.
// To prevent the incompatible react-native bewtween ./node_modules/react-native and ../node_modules/react-native,
// excludes the one from the parent folder when bundling.
config.resolver.blockList = [
...Array.from(config.resolver.blockList ?? []),
new RegExp(path.resolve('..', 'node_modules', 'react-native')),
new RegExp(path.resolve('..', 'node_modules', 'react')),
];

config.resolver.nodeModulesPaths = [
path.resolve(__dirname, './node_modules'),
path.resolve(__dirname, '../node_modules'),
];

config.watchFolders = [path.resolve(__dirname, '..')];

config.transformer.getTransformOptions = async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
});

module.exports = config;
40 changes: 40 additions & 0 deletions web-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "web-example",
"main": "index.js",
"version": "0.0.1",
"scripts": {
"start": "expo start --web",
"reset-project": "node ./scripts/reset-project.js",
"test": "jest --watchAll",
"lint": "expo lint"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@react-navigation/native": "^6.0.2",
"expo": "~51.0.2",
"expo-asset": "~10.0.10",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.0",
"react-native-reanimated": "3.9.0-nightly-20240421-474f6983d",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we bump reanimated to the newest version in all apps as a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WoLewicki Can I do it in the next PR based on this one?

"react-native-svg": "link:../",
"react-native-svg-transformer": "^1.4.0",
"react-native-web": "0.19.11"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@expo/metro-runtime": "~3.2.1",
"@react-native/metro-config": "^0.74.85",
"@types/jest": "^29.5.12",
"@types/react": "~18.2.45",
"@types/react-test-renderer": "^18.0.7",
"jest": "^29.2.1",
"jest-expo": "~51.0.3",
"react-test-renderer": "18.2.0",
"typescript": "~5.3.3"
},
"private": true
}
Loading
Loading