Experiments

The experiments configuration is used to enable experimental capabilities in the plugin.

  • Example
new ModuleFederationPlugin({
  name: '@demo/host',
  experiments: {
    asyncStartup: true,
    externalRuntime: false,
    provideExternalRuntime: false
  },
  shared: {
    react: {
      singleton: true,
    },
    'react-dom': {
      singleton: true,
    },
  },
  //...
});

asyncStartup

  • Type: boolean
  • Required: No
  • Default: false

When asyncStartup is enabled, all Module Federation entrypoints will initialize asynchronously by default. This means:

  • No need for manual import() statements at the top of your app (e.g., import('./bootstrap'))
  • All entrypoints automatically handle async initialization
  • Prevention of "eager consumption" errors through automatic async handling
WARNING

When using this mode, all entrypoints will initialize asynchronously. If you're manually requiring a bundled entrypoint or exposing a UMD library, it will return a promise resolving to the exports.

externalRuntime

  • Type: boolean
  • Required: No
  • Default: false

After setting true, the external MF runtime will be used and the runtime provided by the consumer will be used. (Please make sure your consumer has provideExternalRuntime: true set, otherwise it will not run properly!)

provideExternalRuntime

  • Type: boolean
  • Required: No
  • Default: false
note

Make sure to only configure it on the topmost consumer! If multiple consumers inject runtime at the same time, the ones executed later will not overwrite the existing runtime.

Setting true will inject the MF runtime at the consumer.