From 97c695f78649994920fe1889541608b5903d54a2 Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Mon, 25 Oct 2021 00:52:23 +0200 Subject: [PATCH] [yarn-workspaces] Upgrade to the bin --- with-yarn-workspaces/.gitignore | 52 --------------- with-yarn-workspaces/README.md | 52 --------------- with-yarn-workspaces/apps/mobile/.gitignore | 13 ---- with-yarn-workspaces/apps/mobile/App.js | 23 ------- with-yarn-workspaces/apps/mobile/app.json | 1 - .../apps/mobile/babel.config.js | 6 -- with-yarn-workspaces/apps/mobile/index.js | 8 --- .../apps/mobile/metro.config.js | 3 - with-yarn-workspaces/apps/mobile/package.json | 66 ------------------- .../apps/mobile/webpack.config.js | 6 -- with-yarn-workspaces/package.json | 14 ---- .../packages/expo-custom/package.json | 25 ------- .../packages/expo-custom/src/index.tsx | 7 -- .../packages/expo-custom/tsconfig.json | 9 --- 14 files changed, 285 deletions(-) delete mode 100644 with-yarn-workspaces/.gitignore delete mode 100644 with-yarn-workspaces/README.md delete mode 100644 with-yarn-workspaces/apps/mobile/.gitignore delete mode 100644 with-yarn-workspaces/apps/mobile/App.js delete mode 100644 with-yarn-workspaces/apps/mobile/app.json delete mode 100644 with-yarn-workspaces/apps/mobile/babel.config.js delete mode 100644 with-yarn-workspaces/apps/mobile/index.js delete mode 100644 with-yarn-workspaces/apps/mobile/metro.config.js delete mode 100644 with-yarn-workspaces/apps/mobile/package.json delete mode 100644 with-yarn-workspaces/apps/mobile/webpack.config.js delete mode 100644 with-yarn-workspaces/package.json delete mode 100644 with-yarn-workspaces/packages/expo-custom/package.json delete mode 100644 with-yarn-workspaces/packages/expo-custom/src/index.tsx delete mode 100644 with-yarn-workspaces/packages/expo-custom/tsconfig.json diff --git a/with-yarn-workspaces/.gitignore b/with-yarn-workspaces/.gitignore deleted file mode 100644 index 36a27f25..00000000 --- a/with-yarn-workspaces/.gitignore +++ /dev/null @@ -1,52 +0,0 @@ -# Expo -.expo -__generated__ -web-build - -# macOS -.DS_Store - -# Node -node_modules -npm-debug.log -yarn-error.log - -# Ruby -.direnv - -# Emacs -*~ - -# Vim -.*.swp -.*.swo -.*.swn -.*.swm - -# Sublime Text -*.sublime-project -*.sublime-workspace - -# Xcode -*.pbxuser -!default.pbxuser -*.xccheckout -*.xcscmblueprint -xcuserdata - -# Android Studio -*.iml -.gradle -.idea/libraries -.idea/workspace.xml -.idea/gradle.xml -.idea/misc.xml -.idea/modules.xml -.idea/vcs.xml - -# Eclipse -.project -.settings - -# VSCode -.history/ diff --git a/with-yarn-workspaces/README.md b/with-yarn-workspaces/README.md deleted file mode 100644 index 63be4a24..00000000 --- a/with-yarn-workspaces/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# Expo Yarn Workspaces Example - -

- - - Supports Expo iOS - - - - Supports Expo Android - - - - Supports Expo Web - -

- -Demonstrates the use of `expo-yarn-workspaces` with Expo. -This example installs a monorepo with two applications, both using two separate custom packages. - -## 🚀 How to use - -- Create a new monorepo with `npx create-react-native-app --template with-yarn-workspaces`. - - Packages will be automatically installed via the `postinstall` script in `package.json` -- Run `yarn app` to start the app. - -### 📁 File Structure - -``` -├── apps -│ └── mobile -│ ├── index.js ➡️ Entry point for the app -│ ├── App.js ➡️ App root component -│ ├── package.json ➡️ contains configuration required by expo-yarn-workspaces -│ └── metro.config.js ➡️ required by expo-yarn-workspaces -├── packages -│ └── expo-custom -│ └── src/index.tsx ➡️ exports a custom message which is imported and displayed in the app -│ └── src/tsconfig.json ➡️ default TypeScript configuration for expo-module-scripts -├── package.json ➡️ contains the `postinstall` script and scripts with yarn commands to run applications -└── babel.config.js ➡️ Babel config (should be using `babel-preset-expo`) -``` - -## 📝 Notes - -This example uses [expo-yarn-workspaces](https://github.com/expo/expo/tree/master/packages/expo-yarn-workspaces) to facilitate running the app inside of a monorepo. It also uses [expo-module-scripts](https://github.com/expo/expo/tree/master/packages/expo-module-scripts) to build the library in `packages/expo-custom`. An alternative to expo-module-scripts is [react-native-builder-bob](https://github.com/callstack/react-native-builder-bob). - -Please note that there are currently a few of quirks with using monorepos with EAS Build and with `expo prebuild` / `expo run:[ios|android]`. This example handles those automatically, but you need to be aware of them. - -1. Expo SDK packages should be added to the `"symlinks"` list in `package.json`. -2. `index.js` is used instead of expo-yarn-workspaces' default `__generated__/AppEntry.js` because React Native's `bundle` command does not respect the `"main"` field in `package.json`, so we can't use it here. -3. `metro.config.js` must extend `expo-yarn-workspaces`'s default configuration. This automatically extends `@expo/metro-config`. [Learn about customizing metro.config.js](https://docs.expo.dev/guides/customizing-metro/). diff --git a/with-yarn-workspaces/apps/mobile/.gitignore b/with-yarn-workspaces/apps/mobile/.gitignore deleted file mode 100644 index 73e9e945..00000000 --- a/with-yarn-workspaces/apps/mobile/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -node_modules/**/* -.expo/* -npm-debug.* -*.jks -*.p8 -*.p12 -*.key -*.mobileprovision -*.orig.* -web-build/ - -# macOS -.DS_Store diff --git a/with-yarn-workspaces/apps/mobile/App.js b/with-yarn-workspaces/apps/mobile/App.js deleted file mode 100644 index aee9d21b..00000000 --- a/with-yarn-workspaces/apps/mobile/App.js +++ /dev/null @@ -1,23 +0,0 @@ -import { StatusBar } from "expo-status-bar"; -import React from "react"; -import { StyleSheet, Text, View } from "react-native"; -import { MyView } from "expo-custom"; - -export default function App() { - return ( - - Hello from the application - - - - ); -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: "#fff", - alignItems: "center", - justifyContent: "center", - }, -}); diff --git a/with-yarn-workspaces/apps/mobile/app.json b/with-yarn-workspaces/apps/mobile/app.json deleted file mode 100644 index 0967ef42..00000000 --- a/with-yarn-workspaces/apps/mobile/app.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/with-yarn-workspaces/apps/mobile/babel.config.js b/with-yarn-workspaces/apps/mobile/babel.config.js deleted file mode 100644 index 2900afe9..00000000 --- a/with-yarn-workspaces/apps/mobile/babel.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = function(api) { - api.cache(true); - return { - presets: ['babel-preset-expo'], - }; -}; diff --git a/with-yarn-workspaces/apps/mobile/index.js b/with-yarn-workspaces/apps/mobile/index.js deleted file mode 100644 index 1d6e981e..00000000 --- a/with-yarn-workspaces/apps/mobile/index.js +++ /dev/null @@ -1,8 +0,0 @@ -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); diff --git a/with-yarn-workspaces/apps/mobile/metro.config.js b/with-yarn-workspaces/apps/mobile/metro.config.js deleted file mode 100644 index 4cbce8fb..00000000 --- a/with-yarn-workspaces/apps/mobile/metro.config.js +++ /dev/null @@ -1,3 +0,0 @@ -const { createMetroConfiguration } = require('expo-yarn-workspaces'); - -module.exports = createMetroConfiguration(__dirname); diff --git a/with-yarn-workspaces/apps/mobile/package.json b/with-yarn-workspaces/apps/mobile/package.json deleted file mode 100644 index 801de002..00000000 --- a/with-yarn-workspaces/apps/mobile/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "mobile", - "version": "1.0.0", - "private": true, - "scripts": { - "start": "expo start", - "android": "expo start --android", - "ios": "expo start --ios", - "web": "expo start --web", - "eject": "expo eject", - "build": "echo 'Nothing to build'", - "postinstall": "expo-yarn-workspaces postinstall" - }, - "dependencies": { - "expo": "~42.0.0", - "expo-status-bar": "~1.0.4", - "expo-custom": "*", - "react": "16.13.1", - "react-dom": "16.13.1", - "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz", - "react-native-web": "~0.13.12" - }, - "devDependencies": { - "@babel/core": "~7.9.0" - }, - "expo-yarn-workspaces": { - "symlinks": [ - "@unimodules/core", - "@unimodules/react-native-adapter", - "expo-application", - "expo-asset", - "expo-constants", - "expo-error-recovery", - "expo-file-system", - "expo-font", - "expo-image-loader", - "expo-keep-awake", - "expo-modules-core", - "expo-splash-screen", - "expo-structured-headers", - "expo-updates-interface", - "expo-updates", - "unimodules-app-loader", - "unimodules-task-manager-interface" - ] - }, - "react-native-unimodules": { - "android": { - "modulesPaths": [ - "../../../../", - "../../../../packages" - ], - "configuration": "api", - "target": "react-native" - }, - "ios": { - "modules_paths": [ - "../../../", - "../../../packages" - ], - "flags": { - "inhibit_warnings": false - } - } - } -} diff --git a/with-yarn-workspaces/apps/mobile/webpack.config.js b/with-yarn-workspaces/apps/mobile/webpack.config.js deleted file mode 100644 index 5ec5905e..00000000 --- a/with-yarn-workspaces/apps/mobile/webpack.config.js +++ /dev/null @@ -1,6 +0,0 @@ -const { createWebpackConfigAsync } = require('expo-yarn-workspaces/webpack'); - -module.exports = async function(env, argv) { - const config = await createWebpackConfigAsync(env, argv); - return config; -}; diff --git a/with-yarn-workspaces/package.json b/with-yarn-workspaces/package.json deleted file mode 100644 index 0e48314b..00000000 --- a/with-yarn-workspaces/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "private": true, - "scripts": { - "postinstall": "expo-yarn-workspaces check-workspace-dependencies && yarn workspaces run build", - "app": "yarn workspace @expo/app expo start" - }, - "workspaces": [ - "apps/*", - "packages/*" - ], - "devDependencies": { - "expo-yarn-workspaces": "^1.5.0" - } -} diff --git a/with-yarn-workspaces/packages/expo-custom/package.json b/with-yarn-workspaces/packages/expo-custom/package.json deleted file mode 100644 index 75b9e460..00000000 --- a/with-yarn-workspaces/packages/expo-custom/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "expo-custom", - "version": "1.0.0", - "description": "", - "main": "build/index.js", - "types": "build/index.d.ts", - "sideEffects": false, - "scripts": { - "build": "expo-module build", - "clean": "expo-module clean", - "lint": "expo-module lint", - "test": "expo-module test", - "prepare": "expo-module prepare", - "prepublishOnly": "expo-module prepublishOnly", - "expo-module": "expo-module" - }, - "jest": { - "preset": "expo-module-scripts" - }, - "dependencies": { - }, - "devDependencies": { - "expo-module-scripts": "^2.0.0" - } -} \ No newline at end of file diff --git a/with-yarn-workspaces/packages/expo-custom/src/index.tsx b/with-yarn-workspaces/packages/expo-custom/src/index.tsx deleted file mode 100644 index 09a43def..00000000 --- a/with-yarn-workspaces/packages/expo-custom/src/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import * as React from 'react'; -// @ts-ignore -import { Text } from 'react-native'; - -export function MyView() { - return Hello from the first package; -} diff --git a/with-yarn-workspaces/packages/expo-custom/tsconfig.json b/with-yarn-workspaces/packages/expo-custom/tsconfig.json deleted file mode 100644 index a24ec0ff..00000000 --- a/with-yarn-workspaces/packages/expo-custom/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -// @generated by expo-module-scripts -{ - "extends": "expo-module-scripts/tsconfig.base", - "compilerOptions": { - "outDir": "./build" - }, - "include": ["./src"], - "exclude": ["**/__mocks__/*", "**/__tests__/*"] -}