From 7c6997df83a7cf9cf060c3fed747f49ee755e46e Mon Sep 17 00:00:00 2001 From: Jacob Spizziri Date: Mon, 18 Sep 2023 09:51:06 -0400 Subject: [PATCH] chore(example): update the web build to work with the upgraded example code --- example/craco.config.js | 38 ++++++++++++++++----- example/package.json | 14 ++++---- example/src/components/ActionSheet.tsx | 7 ++-- example/src/components/OptionSheet.tsx | 7 ++-- example/src/index.ts | 26 ++++++++++++++ example/yarn.lock | 47 ++++++++++++++++++++++---- 6 files changed, 111 insertions(+), 28 deletions(-) diff --git a/example/craco.config.js b/example/craco.config.js index bbe394954..dadd8624b 100644 --- a/example/craco.config.js +++ b/example/craco.config.js @@ -2,6 +2,8 @@ const path = require('path'); const {CracoAliasPlugin} = require('react-app-alias-ex'); const babelInclude = require('@dealmore/craco-plugin-babel-include'); const webpack = require('webpack'); +const { loaderByName, addBeforeLoader } = require('@craco/craco'); + module.exports = { webpack: { @@ -12,20 +14,40 @@ module.exports = { 'react': path.resolve(__dirname, './node_modules/react'), }, plugins: { - add: [ - new webpack.EnvironmentPlugin({ JEST_WORKER_ID: null }), - new webpack.DefinePlugin({ - process: { env: {} }, - __DEV__: true, - }) - ], - }, + add: [ + new webpack.EnvironmentPlugin({ JEST_WORKER_ID: null }), + new webpack.DefinePlugin({ + process: { env: {} }, + __DEV__: true, + }) + ], + }, + configure: (config) => { + // BEGIN: resolve react-native-vector-icons font files + config.resolve.extensions.push('.ttf'); + addBeforeLoader( + config, + loaderByName('url-loader'), + { + test: /\.ttf$/, + loader: 'url-loader', // or directly file-loader + include: path.resolve(__dirname, 'node_modules/react-native-vector-icons'), + }, + ); + // END: resolve react-native-vector-icons font files + + return config; + }, }, babel: { presets: [ '@babel/preset-react', '@babel/preset-typescript', ], + plugins: [ + '@babel/plugin-proposal-export-namespace-from', + 'react-native-reanimated/plugin', + ], }, plugins: [ { diff --git a/example/package.json b/example/package.json index 8fc04d4e8..5cfda22e0 100644 --- a/example/package.json +++ b/example/package.json @@ -28,19 +28,20 @@ "@react-native-community/slider": "^4.4.2", "@react-native-segmented-control/segmented-control": "^2.4.2", "mux.js": "^6.2.0", + "react": "18.2.0", "react-dom": "^18.0.2", - "react-native-gesture-handler": "^2.12.1", - "react-native-reanimated": "^3.4.1", + "react-native": "0.71.12", + "react-native-gesture-handler": "2.12.1", + "react-native-reanimated": "3.3.0", "react-native-track-player": "link:../", "react-native-vector-icons": "^10.0.0", "react-native-web": "^0.18.10", "react-native-windows": "^0.65.0-0", - "react-native": "0.71.12", - "react-scripts": "5.0.1", - "react": "18.2.0" + "react-scripts": "5.0.1" }, "devDependencies": { "@babel/core": "^7.20.0", + "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@craco/craco": "^7.0.0", @@ -51,6 +52,7 @@ "@types/react": "^18.0.24", "@types/react-dom": "^18.2.0", "@types/react-native": "^0.64.5", + "@types/react-native-vector-icons": "^6.4.14", "@types/react-test-renderer": "^18.0.0", "@typescript-eslint/eslint-plugin": "^5.36.0", "@typescript-eslint/parser": "^5.36.0", @@ -61,8 +63,8 @@ "eslint-plugin-react-hooks": "^4.6.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.73.9", - "react-app-alias-ex": "^2.1.0", "prettier": "^2.4.1", + "react-app-alias-ex": "^2.1.0", "react-native-clean-project": "^4.0.1", "react-test-renderer": "18.2.0", "rimraf": "^3.0.2", diff --git a/example/src/components/ActionSheet.tsx b/example/src/components/ActionSheet.tsx index d6613b3da..610761dde 100644 --- a/example/src/components/ActionSheet.tsx +++ b/example/src/components/ActionSheet.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import { BottomSheetScrollView } from '@gorhom/bottom-sheet'; -import { StyleSheet } from 'react-native'; +import { StyleSheet, ScrollView } from 'react-native'; import { Spacer } from './Spacer'; import { Button } from './Button'; import TrackPlayer from 'react-native-track-player'; @@ -31,7 +30,7 @@ const onReset = async () => { export const ActionSheet: React.FC = () => { return ( - +