module-federation / core

Module Federation is a concept that allows developers to share code and resources across multiple JavaScript applications
https://module-federation.io/
MIT License
1.43k stars 214 forks source link

Support for React-Native #2811

Open jbroma opened 2 months ago

jbroma commented 2 months ago

Clear and concise description of the problem

Re.Pack supports MF V1, for V2 supports we need adjust how containers are loaded in React-Native environment.

Suggested solution

Alternative

Additional context

Related Re.Pack issue: https://github.com/callstack/repack/issues/518 Related Re.Pack PR: https://github.com/callstack/repack/pull/674

Validations

2heal1 commented 1 week ago

hey i don't sure why it depends on the disable autoPreload . And i support the shareStrategy option , which you can config in runtime/build configuration , maybe this can satisfy your need ?

jbroma commented 6 days ago

hey i don't sure why it depends on the disable autoPreload . And i support the shareStrategy option , which you can config in runtime/build configuration , maybe this can satisfy your need ?

hey, shareStrategy is definitely sufficient for this exact purpose, I've been using it in the POC ever since it was implemented and it works as expected 👍

As to why it's necessary: RN startup is complicated - we need to have eager access to react and react-native packages there, but at the same time we want to share them with other federated modules. When it's set to version-first, I think both of these dependencies were set to Promises and this caused Errors in RN env since we need to have sync startup.