Skip to main content
Version: 3x

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 when exposes is defined
  • default for library option when exposes is defined
  • default for shared option with react and react-native dependencies
  • converts remotes into ScriptManager-powered promise 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

NameType
configModuleFederationPluginConfig

Defined in

packages/repack/src/webpack/plugins/ModuleFederationPlugin.ts:112

Methods

apply

apply(compiler): void

Apply the plugin.

Parameters

NameTypeDescription
compilerCompilerWebpack compiler instance.

Returns

void

Implementation of

WebpackPlugin.apply

Defined in

packages/repack/src/webpack/plugins/ModuleFederationPlugin.ts:237