reactnativecn / react-native-website

React Native 中文网
https://reactnative.cn
MIT License
218 stars 328 forks source link

RN如何引入平级项目 #596

Closed Shanbei closed 2 years ago

Shanbei commented 2 years ago

我建立了一个共用的js项目,用来加载相同的功能; 在React项目时,使用npm run reject暴露了配置文件后,加载了这个共用的js项目; 但我在使用RN时,虽然没有限制引入外部js的提醒,却依旧无法找到文件,即使使用了babel-plugin-module-resolver来配置别名也无法找到; 这里是有某些配置的限制吗? None of these files exist:

sunnylqm commented 2 years ago

metro不能引入父级目录的文件,这里有个讨论 https://github.com/facebook/metro/issues/7 里面有一些解决方法,但随着版本变化和时间推移可能已经失效,请尽量参考最新的评论尝试

sunnylqm commented 2 years ago

另外,可以参考 expo 设计的结构和方案来在web和rn间共享代码 https://docs.expo.dev/guides/monorepos/

github-actions[bot] commented 2 years ago

👋 Hey there, it looks like there has been no activity on this issue in the last 90 days. Has the issue been fixed, or does it still require the community attention? This issue will be closed in the next 7 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 2 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.