Global variables
Global variables are readable only, do not modify them!
FEDERATION
After initialization, the __FEDERATION__ variable will be injected globally. This variable is an object that contains all the module federation information of the current application.
moduleInfo
It is recommended to use chrome devtools to view the processed moduleInfo.
Record all module information of the current application. Based on this information, you can get the module's dependencies.
The moduleInfo structure is an object, where the key consists of two parts: moduleName and moduleVersion: {moduleName}(:{moduleVersion}).
moduleName is the name of the module, and moduleVersion is the version of the module or url.
moduleVersion only exists in the producer module.
The following example shows how to use moduleInfo to get dependencies, assuming the following moduleInfo:
moduleInfo
In the above example, moduleInfo contains information about 5 modules, among which manifest_host does not have a version number after it, indicating that it is a consumer module.
The remotesInfo field in manifest_host records the information of all producer modules it depends on, and the corresponding matchedVersion field records the version or url it matches.
The corresponding producer module information can be obtained through the key + matchedVersion in the consumer remotesInfo field, such as webpack_provider:http://localhost:3009/mf-manifest.json.
version
Only exists in producers, the value of consumers is an empty string
The version or url of the current module.
buildVersion
The build version of the current module, usually taken from the version field in package.json.
globalName
Only exists in the producer
The global variable name of the current producer module. You can get the producer's container through globalThis[globalName], which is usually taken from the name field in package.json.
publicPath
The publicPath of the current module.
getPublicPath
This field and
publicPathare mutually exclusive
The getPublicPath of the current module, get the final publicPath through new Function(getPublicPath)() call.
ssrPublicPath
The publicPath of the server file of the current module.
remoteEntry
Only exists in the producer
The name of the entry file of the current producer module.
remoteEntryType
Only exists in the producer
The entry file type of the current producer module.
remoteTypesZip
Only exists in the producer
The name of the compressed package of the type declaration file of the current producer module.
remoteTypesAPI
Only exists in the producer
The name of the type API declaration file of the current producer module.
shared
All shared module information that the current module depends on. The type definition is as follows:
modules
Only exists in the producer
All module information exported by the current module. The type definition is as follows:
prefetchInterface
Only exists in the producer
Whether the current module has preloading enabled.
SHARE
All shared module information currently registered (loaded), the type definition is as follows:
Type declaration
We can use __SHARE__ to query the loading status of a specific shared. For example, if the following __SHARE__ exists:
__SHARE__
In the above data, you can see the shared module information of the two modules manifest_host and app1. Among them, react has only one version 18.3.1.
Check __SHARE__["app1:0.1.94"].default.react["18.3.1"] to see the information of the react module, and find that loaded is true, indicating that the react module has been loaded.
In addition, the from field is webpack_provider, indicating that the react module is provided by the webpack_provider module.
Looking at the useIn field, you can see that the useIn field contains the webpack_provider and app1 modules, indicating that the react module is used by the webpack_provider and app1 modules.
INSTANCES
The currently loaded MF instance. It stores a list of all loaded MF modules. Every list entry has the following structure:
bridgeHook
Contains metadata about the MF bridge which is used to enable cross-application use-cases (React, Vue) to load properly.
hooks
Contains metadata about the MF hooks which are used to tap into the MF lifecycle.
loaderHook
Contains metadata about the MF loaderHook.
moduleCache
Contains a Map storing all MF modules with their metadata available in the moduleCache.
name
The name of the MF module.
options
Useful for debugging your modules.
Vital data about the MF module, such as loaded plugins, connected remotes, shareStrategy and the shared dependency object.
remoteHandler
Contains metadata about the MF remoteHandler including the idToRemoteMap which stores all bindings to connected remote components exposed by the connected MF remotes.
shareScopeMap
Contains metadata about the MF shared scope including data about every connected shared dependency.
sharedHandler
Contains metadata about the MF sharedHandler.
snapshotHandler
Useful to check the mf-manifest.json structure and status.
Contains metadata about the MF snapshotHandler including the manifestCache object and the manifestLoading object.
version
The version of the Mf module.
PRELOADED_MAP
The key-value-map of all preloaded modules (build-time). key represents the module name, and value represents the boolean value of the loaded status.
MANIFEST_LOADING
Contains metadata about the manifestLoading object. This is the same as the snapshotHandler.manifestLoading in __INSTANCES__.