The experiments
configuration is used to enable experimental capabilities in the plugin.
boolean
false
When asyncStartup
is enabled, all Module Federation entrypoints will initialize asynchronously by default. This means:
import()
statements at the top of your app (e.g., import('./bootstrap')
)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.
boolean
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!)
boolean
false
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.
This object contains flags related to build-time optimizations that can affect the Module Federation runtime's size and behavior.
boolean
false
When set to true
, this option defines the FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN
global constant as true
during the build. In the @module-federation/runtime-core
, this prevents the snapshotPlugin()
and generatePreloadAssetsPlugin()
from being included and initialized within the FederationHost.
Impact:
snapshotPlugin
is crucial for the "mf-manifest protocol" – it's responsible for generating or providing runtime access to a build manifest (e.g., mf-manifest.json
) containing metadata about exposed modules, shared dependencies, versions, and remotes. Disabling it means:
generatePreloadAssetsPlugin
), and potentially runtime debugging/introspection tools, will not function correctly or will be unavailable.'web' | 'node'
target
option (usually 'web'
)This option defines the ENV_TARGET
global constant during the build, specifying the intended execution environment.
Impact:
target: 'web'
: Optimizes the build for browser environments.
loadEntryDom
).@module-federation/sdk
. Functions like createScriptNode
and loadScriptNode
, along with their required Node.js built-in modules (e.g., vm
, path
, http
), are completely removed from the bundle, significantly reducing its size.target: 'node'
: Optimizes the build for Node.js environments.
loadEntryNode
).createScriptNode
, loadScriptNode
) in the bundle, allowing the federated application to function correctly in Node.js.Explicitly setting this value is recommended to ensure the intended optimizations are applied, especially in universal or server-side rendering scenarios.