Guide For Micro-Frontends
Module Federation
Shared
The shared
configuration is used to share common dependencies between consumers and producers, reducing the runtime download volume and thus improving performance. shared
allows you to configure rules for reusing dependency versions.
- Type:
PluginSharedOptions
- Required: No
- Default:
undefined
The PluginSharedOptions
type is as follows:
type PluginSharedOptions = string[] | SharedObject;
interface SharedObject {
[sharedName: string]: SharedConfig;
}
interface SharedConfig {
singleton?: boolean;
requiredVersion?: string;
eager?: boolean;
shareScope?: string;
}
- Example
new ModuleFederationPlugin({
name: '@demo/host',
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
//...
});