This plugin is designed to configure Module Federation 2.0. It's an enhanced version of the standard Module Federation plugin that's specifically tailored for React Native environments.
This documentation describes only Re.Pack-specific configuration options. For the complete configuration reference, please see the official Module Federation 2.0 documentation.
All standard Module Federation 2.0 options are supported in addition to the options described below.
The plugin extends the standard Module Federation 2.0 plugin with functionality specific to mobile React Native apps:
react
and react-native
as shared dependencies with singleton: true
and eager: true
by default.loaded-first
share strategy by default.@callstack/repack/mf/core-plugin
- Core functionality@callstack/repack/mf/resolver-plugin
- React Native-specific module resolutionname
option) to prevent runtime issuesFirst, install the official @module-federation/enhanced
package which is required by Re.Pack:
If you would like to use the runtime capabilites of MF2 (like adding remotes on the fly),
you should install the @module-federation/runtime
package as well:
Check out the official Module Federation 2.0 quick start guide for more information.
boolean
true
Enable or disable adding React Native deep imports to shared dependencies. When enabled, the plugin will automatically add:
react-native/
for deep imports from React Native core@react-native/
for deep imports from official React Native packagesThis ensures proper sharing of deep imports and single instances of things like assetsRegistry
.
Deep imports are when you import from a specific subdirectory or file within a package rather than the package's main entry point. For example:
React Native uses deep imports extensively in its internal implementation. The reactNativeDeepImports
option ensures these imports are properly shared between federated modules.
This feature solves a common Module Federation issue where deep imports create separate instances in host and remote apps - see this Stack Overflow discussion for the original problem.
string[]
["@callstack/repack/mf/core-plugin", "@callstack/repack/mf/resolver-plugin"]
List of default runtime plugins for Federation Runtime. These plugins provide core functionality and React Native-specific resolution for Module Federation.
You can modify this list to: