Global variables are readable only, do not modify them!
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.
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:
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.
Only exists in producers, the value of consumers is an empty string
The version or url of the current module.
The build version of the current module, usually taken from the version field in package.json.
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.
The publicPath of the current module.
This field and
publicPathare mutually exclusive
The getPublicPath of the current module, get the final publicPath through new Function(getPublicPath)() call.
The publicPath of the server file of the current module.
Only exists in the producer
The name of the entry file of the current producer module.
Only exists in the producer
The entry file type of the current producer module.
Only exists in the producer
The name of the compressed package of the type declaration file of the current producer module.
Only exists in the producer
The name of the type API declaration file of the current producer module.
All shared module information that the current module depends on. The type definition is as follows:
Only exists in the producer
All module information exported by the current module. The type definition is as follows:
Only exists in the producer
Whether the current module has preloading enabled.
All shared module information currently registered (loaded), the type definition is as follows:
We can use __SHARE__ to query the loading status of a specific shared. For example, if the following __SHARE__ exists:
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.
The currently loaded MF instance. It stores a list of all loaded MF modules. Every list entry has the following structure:
Contains metadata about the MF bridge which is used to enable cross-application use-cases (React, Vue) to load properly.
Contains metadata about the MF hooks which are used to tap into the MF lifecycle.
Contains metadata about the MF loaderHook.
Contains a Map storing all MF modules with their metadata available in the moduleCache.
The name of the MF module.
Useful for debugging your modules.
Vital data about the MF module, such as loaded plugins, connected remotes, shareStrategy and the shared dependency object.
Contains metadata about the MF remoteHandler including the idToRemoteMap which stores all bindings to connected remote components exposed by the connected MF remotes.
Contains metadata about the MF shared scope including data about every connected shared dependency.
Contains metadata about the MF sharedHandler.
Useful to check the mf-manifest.json structure and status.
Contains metadata about the MF snapshotHandler including the manifestCache object and the manifestLoading object.
The version of the Mf module.
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.
Contains metadata about the manifestLoading object. This is the same as the snapshotHandler.manifestLoading in __INSTANCES__.