Class: ModuleFederationPlugin
plugins.ModuleFederationPlugin
Webpack plugin to configure Module Federation with platform differences handled under the hood.
Usually, you should use Repack.plugin.ModuleFederationPlugin
instead of webpack.container.ModuleFederationPlugin
.
Repack.plugin.ModuleFederationPlugin
creates:
- default for
filename
option whenexposes
is defined - default for
library
option whenexposes
is defined - default for
shared
option withreact
andreact-native
dependencies - converts
remotes
intoScriptManager
-poweredpromise new Promise
loaders
You can overwrite all defaults by passing respective options.
remotes
will always be converted to ScriptManager-powered
promise new Promise` loaders
using Federated.createRemote.
example
Host example.
import * as Repack from '@callstack/repack';
new Repack.plugins.ModuleFederationPlugin({
name: 'host,
});
example
Host example with additional shared
dependencies.
import * as Repack from '@callstack/repack';
new Repack.plugins.ModuleFederationPlugin({
name: 'host,
shared: {
react: Repack.Federated.SHARED_REACT,
'react-native': Repack.Federated.SHARED_REACT,
'react-native-reanimated': {
singleton: true,
},
},
});
example
Container examples.
import * as Repack from '@callstack/repack';
new Repack.plugins.ModuleFederationPlugin({
name: 'app1',
remotes: {
module1: 'module1@https://example.com/module1.container.bundle',
},
});
new Repack.plugins.ModuleFederationPlugin({
name: 'app2',
remotes: {
module1: 'module1@https://example.com/module1.container.bundle',
module2: 'module1@dynamic',
},
});
Implements
Table of contents
Constructors
Methods
Constructors
constructor
• new ModuleFederationPlugin(config
)
Parameters
Name | Type |
---|---|
config | ModuleFederationPluginConfig |
Defined in
packages/repack/src/webpack/plugins/ModuleFederationPlugin.ts:112
Methods
apply
▸ apply(compiler
): void
Apply the plugin.
Parameters
Name | Type | Description |
---|---|---|
compiler | Compiler | Webpack compiler instance. |
Returns
void
Implementation of
Defined in
packages/repack/src/webpack/plugins/ModuleFederationPlugin.ts:237