如何在 Expo 應用示例嵌套文件夾中熱重載開發包? (How to hot reload a development package in an Expo app example nested folder?)


問題描述

如何在 Expo 應用示例嵌套文件夾中熱重載開發包? (How to hot reload a development package in an Expo app example nested folder?)

Expo 應用程序示例是否可以加載位於父文件夾中的模塊並在我重建包時查看示例應用程序中的更改(使用 tsc ‑w 重建任何保存的文件)?我確切地說該模塊尚未在 npm 上發布。

我已經成功地使用帶有 yarn 工作空間和 expo‑yarn‑workspaces 包的 monorepo 架構來做到這一點。但是當你不想像 monorepo 那樣發布你的包的情況下呢?

例如,在這個 repo https://github.com/cuvent/react‑native‑vision‑camera 在裸工作流中有一個示例 RN 應用程序,在其 package.json 中有沒有提到開發的包(意思是它' s 沒有像正常的依賴項一樣安裝)。但是在應用程序 src/App.tsx 中,該包的使用方式如下:

import { Camera, frameRateIncluded, sortFormatsByResolution, filterFormatsByAspectRatio } from 'react‑native‑vision‑camera';

雖然,react‑native‑vision‑camera 的使用就像它已經並且通常與 yarn 或 npm 一起安裝一樣。它是如何工作的?

謝謝。


參考解法

方法 1:

Finally, I've found something that works for me. You can find my config for metro if you want here: https://github.com/grean/react‑native‑metro‑config‑app‑example With it, you can access the parent component from the expo app, modify it and immediately see the hot‑reload changes. Create a file metro.config file in your expo root app directory with that code inside:

let config = require('@grean/react‑native‑metro‑config‑app‑example/index.js');
module.exports = config

For a whole example, you can check this repo out: https://github.com/grean/react‑native‑scale‑text

(by Guillaume RéanGuillaume Réan)

參考文件

  1. How to hot reload a development package in an Expo app example nested folder? (CC BY‑SA 2.5/3.0/4.0)

#yarn-workspaces #monorepo #react-native #npm-package #expo






相關問題

如何使用帶有打字稿和輸出文件夾的紗線工作區? (How to use yarn workspaces with typescript and out folders?)

如何在 Monorepo 中運行多個開發包 (How to run multiple packages in development inside a Monorepo)

帶有許多 npm 腳本的 Monorepo (Monorepo with Many npm-scripts)

使用紗線工作區導出枚舉時出現意外的令牌錯誤 (Unexpected token error exporting enums using yarn workspaces)

如何在 Expo 應用示例嵌套文件夾中熱重載開發包? (How to hot reload a development package in an Expo app example nested folder?)

將 monorepo 包放在包文件夾下是一種約定,還是 yarn 工作區期望這樣? (Is putting monorepo packages under a package folder a convention, or do yarn workspace expect that?)

通過創建具有循環依賴關係的 monorepo 導致錯誤 (Causing an error by creating a monorepo with circular dependencies)

Monorepo – Yarn 工作區 Typescript Node.JS 項目 – 運行 nodemon 時找不到模塊 (Monorepo – Yarn workspaces Typescript Node.JS project – cannot find module when running nodemon)

紗線工作區為每個運行 shell 命令 (Yarn workspaces run shell command for each)

紗線工作區共享包未在 create-react-app 中加載 (yarn workspaces shared package does not load in create-react-app)

如何使用 Yarn 工作區將共享依賴項添加到 monorepo? (How do I add shared dependencies to a monorepo using Yarn workspaces?)

使用紗線工作區在monorepo中跨項目共享配置變量? (Sharing config variables across projects in a monorepo using yarn workspaces?)







留言討論