@module-federation/runtime-core 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/global.cjs +1 -1
- package/dist/global.js +1 -1
- package/dist/remote/index.cjs +12 -9
- package/dist/remote/index.cjs.map +1 -1
- package/dist/remote/index.js +12 -9
- package/dist/remote/index.js.map +1 -1
- package/dist/utils/hooks/pluginSystem.d.ts +1 -1
- package/package.json +3 -3
package/dist/core.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var ModuleFederation = class {
|
|
|
30
30
|
beforeInitContainer: new require_asyncWaterfallHooks.AsyncWaterfallHook("beforeInitContainer"),
|
|
31
31
|
initContainer: new require_asyncWaterfallHooks.AsyncWaterfallHook("initContainer")
|
|
32
32
|
});
|
|
33
|
-
this.version = "2.
|
|
33
|
+
this.version = "2.6.0";
|
|
34
34
|
this.moduleCache = /* @__PURE__ */ new Map();
|
|
35
35
|
this.loaderHook = new require_pluginSystem.PluginSystem({
|
|
36
36
|
getModuleInfo: new require_syncHook.SyncHook(),
|
package/dist/core.js
CHANGED
|
@@ -30,7 +30,7 @@ var ModuleFederation = class {
|
|
|
30
30
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
31
31
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
32
32
|
});
|
|
33
|
-
this.version = "2.
|
|
33
|
+
this.version = "2.6.0";
|
|
34
34
|
this.moduleCache = /* @__PURE__ */ new Map();
|
|
35
35
|
this.loaderHook = new PluginSystem({
|
|
36
36
|
getModuleInfo: new SyncHook(),
|
package/dist/global.cjs
CHANGED
|
@@ -65,7 +65,7 @@ function getGlobalFederationConstructor() {
|
|
|
65
65
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = (0, _module_federation_sdk.isDebugMode)()) {
|
|
66
66
|
if (isDebug) {
|
|
67
67
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
68
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.
|
|
68
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.6.0";
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function getInfoWithoutType(target, key) {
|
package/dist/global.js
CHANGED
|
@@ -65,7 +65,7 @@ function getGlobalFederationConstructor() {
|
|
|
65
65
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
66
66
|
if (isDebug) {
|
|
67
67
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
68
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.
|
|
68
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.6.0";
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function getInfoWithoutType(target, key) {
|
package/dist/remote/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_logger = require('../utils/logger.cjs');
|
|
2
|
+
const require_tool = require('../utils/tool.cjs');
|
|
2
3
|
const require_global = require('../global.cjs');
|
|
3
4
|
const require_constant = require('../constant.cjs');
|
|
4
5
|
const require_share = require('../utils/share.cjs');
|
|
@@ -365,6 +366,17 @@ var RemoteHandler = class {
|
|
|
365
366
|
const { name } = remote;
|
|
366
367
|
const remoteIndex = host.options.remotes.findIndex((item) => item.name === name);
|
|
367
368
|
if (remoteIndex !== -1) host.options.remotes.splice(remoteIndex, 1);
|
|
369
|
+
const globalSnapshotKey = require_global.getInfoWithoutType(require_global.CurrentGlobal.__FEDERATION__.moduleInfo, require_tool.getFMId(remote)).key;
|
|
370
|
+
delete require_global.CurrentGlobal.__FEDERATION__.moduleInfo[globalSnapshotKey];
|
|
371
|
+
if ("entry" in remote) {
|
|
372
|
+
host.snapshotHandler.manifestCache.delete(remote.entry);
|
|
373
|
+
delete require_global.Global.__FEDERATION__.__MANIFEST_LOADING__[remote.entry];
|
|
374
|
+
}
|
|
375
|
+
const { hostGlobalSnapshot } = require_SnapshotHandler.getGlobalRemoteInfo(remote, host);
|
|
376
|
+
if (hostGlobalSnapshot) {
|
|
377
|
+
const remoteKey = hostGlobalSnapshot && "remotesInfo" in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && require_global.getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
378
|
+
if (remoteKey) delete hostGlobalSnapshot.remotesInfo[remoteKey];
|
|
379
|
+
}
|
|
368
380
|
const loadedModule = host.moduleCache.get(remote.name);
|
|
369
381
|
if (loadedModule) {
|
|
370
382
|
const remoteInfo = loadedModule.remoteInfo;
|
|
@@ -373,7 +385,6 @@ var RemoteHandler = class {
|
|
|
373
385
|
else require_global.CurrentGlobal[key] = void 0;
|
|
374
386
|
const remoteEntryUniqueKey = require_load.getRemoteEntryUniqueKey(loadedModule.remoteInfo);
|
|
375
387
|
if (require_global.globalLoading[remoteEntryUniqueKey]) delete require_global.globalLoading[remoteEntryUniqueKey];
|
|
376
|
-
host.snapshotHandler.manifestCache.delete(remoteInfo.entry);
|
|
377
388
|
let remoteInsId = remoteInfo.buildVersion ? (0, _module_federation_sdk.composeKeyWithSeparator)(remoteInfo.name, remoteInfo.buildVersion) : remoteInfo.name;
|
|
378
389
|
const remoteInsIndex = require_global.CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {
|
|
379
390
|
if (remoteInfo.buildVersion) return ins.options.id === remoteInsId;
|
|
@@ -421,14 +432,6 @@ var RemoteHandler = class {
|
|
|
421
432
|
});
|
|
422
433
|
require_global.CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);
|
|
423
434
|
}
|
|
424
|
-
const { hostGlobalSnapshot } = require_SnapshotHandler.getGlobalRemoteInfo(remote, host);
|
|
425
|
-
if (hostGlobalSnapshot) {
|
|
426
|
-
const remoteKey = hostGlobalSnapshot && "remotesInfo" in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && require_global.getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
427
|
-
if (remoteKey) {
|
|
428
|
-
delete hostGlobalSnapshot.remotesInfo[remoteKey];
|
|
429
|
-
if (Boolean(require_global.Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) delete require_global.Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
435
|
host.moduleCache.delete(remote.name);
|
|
433
436
|
}
|
|
434
437
|
} catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["PluginSystem","SyncWaterfallHook","AsyncWaterfallHook","AsyncHook","SyncHook","matchRemoteWithNameAndExpose","getRemoteInfo","formatPreloadArgs","composeRemoteRequestId","preloadAssets","RUNTIME_004","runtimeDescMap","optionsToMFContext","Module","isBrowserEnvValue","DEFAULT_SCOPE","DEFAULT_REMOTE_TYPE","CurrentGlobal","getRemoteEntryUniqueKey","globalLoading","getGlobalShareScope","getGlobalRemoteInfo","getInfoWithoutType","Global"],"sources":["../../src/remote/index.ts"],"sourcesContent":["import {\n isBrowserEnvValue,\n warn,\n composeKeyWithSeparator,\n ModuleInfo,\n GlobalModuleInfo,\n} from '@module-federation/sdk';\nimport { RUNTIME_004, runtimeDescMap } from '@module-federation/error-codes';\nimport {\n Global,\n getInfoWithoutType,\n globalLoading,\n CurrentGlobal,\n} from '../global';\nimport {\n Options,\n UserOptions,\n PreloadAssets,\n PreloadOptions,\n PreloadRemoteArgs,\n PreloadRemoteResult,\n Remote,\n RemoteInfo,\n RemoteEntryExports,\n CallFrom,\n} from '../type';\nimport { ModuleFederation } from '../core';\nimport {\n PluginSystem,\n AsyncHook,\n AsyncWaterfallHook,\n SyncHook,\n SyncWaterfallHook,\n} from '../utils/hooks';\nimport {\n assert,\n error,\n getRemoteInfo,\n getRemoteEntryUniqueKey,\n composeRemoteRequestId,\n matchRemoteWithNameAndExpose,\n optionsToMFContext,\n logger,\n} from '../utils';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { Module, ModuleOptions } from '../module';\nimport { formatPreloadArgs, preloadAssets } from '../utils/preload';\nimport { getGlobalShareScope } from '../utils/share';\nimport { getGlobalRemoteInfo } from '../plugins/snapshot/SnapshotHandler';\n\nexport interface LoadRemoteMatch {\n id: string;\n pkgNameOrAlias: string;\n expose: string;\n remote: Remote;\n options: Options;\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n}\n\nexport class RemoteHandler {\n host: ModuleFederation;\n idToRemoteMap: Record<string, { name: string; expose: string }>;\n\n hooks = new PluginSystem({\n beforeRegisterRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('beforeRegisterRemote'),\n registerRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('registerRemote'),\n beforeRequest: new AsyncWaterfallHook<{\n id: string;\n options: Options;\n origin: ModuleFederation;\n }>('beforeRequest'),\n afterMatchRemote: new AsyncHook<\n [\n {\n id: string;\n options: Options;\n remote?: Remote;\n expose?: string;\n remoteInfo?: RemoteInfo;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterMatchRemote'),\n onLoad: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n pkgNameOrAlias: string;\n remote: Remote;\n options: ModuleOptions;\n origin: ModuleFederation;\n exposeModule: any;\n exposeModuleFactory: any;\n moduleInstance: Module;\n },\n ],\n unknown\n >('onLoad'),\n afterLoadRemote: new AsyncHook<\n [\n {\n id: string;\n expose?: string;\n remote?: RemoteInfo;\n options?: {\n loadFactory?: boolean;\n from?: CallFrom;\n };\n error?: unknown;\n recovered?: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterLoadRemote'),\n handlePreloadModule: new SyncHook<\n [\n {\n id: string;\n name: string;\n remote: Remote;\n remoteSnapshot: ModuleInfo;\n preloadConfig: PreloadRemoteArgs;\n origin: ModuleFederation;\n },\n ],\n void\n >('handlePreloadModule'),\n errorLoadRemote: new AsyncHook<\n [\n {\n id: string;\n error: unknown;\n options?: any;\n from: CallFrom;\n lifecycle:\n | 'beforeRequest'\n | 'beforeLoadShare'\n | 'afterResolve'\n | 'onLoad';\n remote?: RemoteInfo;\n expose?: string;\n origin: ModuleFederation;\n },\n ],\n void | unknown\n >('errorLoadRemote'),\n beforePreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n },\n ]\n >('beforePreloadRemote'),\n generatePreloadAssets: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n preloadOptions: PreloadOptions[number];\n remote: Remote;\n remoteInfo: RemoteInfo;\n remoteSnapshot: ModuleInfo;\n globalSnapshot: GlobalModuleInfo;\n },\n ],\n Promise<PreloadAssets>\n >('generatePreloadAssets'),\n afterPreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n results: PreloadRemoteResult[];\n error?: unknown;\n },\n ]\n >('afterPreloadRemote'),\n // TODO: Move to loaderHook\n loadEntry: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n loaderHook: ModuleFederation['loaderHook'];\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n },\n ],\n Promise<RemoteEntryExports | void> | RemoteEntryExports | void\n >(),\n });\n\n constructor(host: ModuleFederation) {\n this.host = host;\n this.idToRemoteMap = {};\n }\n\n formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions) {\n const userRemotes = userOptions.remotes || [];\n\n return userRemotes.reduce((res, remote) => {\n this.registerRemote(remote, res, { force: false });\n return res;\n }, globalOptions.remotes);\n }\n\n setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch) {\n const { remote, expose } = remoteMatchInfo;\n const { name, alias } = remote;\n this.idToRemoteMap[id] = { name: remote.name, expose };\n if (alias && id.startsWith(name)) {\n const idWithAlias = id.replace(name, alias);\n this.idToRemoteMap[idWithAlias] = { name: remote.name, expose };\n return;\n }\n\n if (alias && id.startsWith(alias)) {\n const idWithName = id.replace(alias, name);\n this.idToRemoteMap[idWithName] = { name: remote.name, expose };\n }\n }\n\n // eslint-disable-next-line max-lines-per-function\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async loadRemote<T>(\n id: string,\n options?: { loadFactory?: boolean; from: CallFrom },\n ): Promise<T | null> {\n const { host } = this;\n const startMatchInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n id,\n );\n let completeRequestId = id;\n let completeExpose = startMatchInfo?.expose;\n let completeRemote = startMatchInfo\n ? getRemoteInfo(startMatchInfo.remote)\n : undefined;\n let afterLoadRemoteArgs:\n | Parameters<\n RemoteHandler['hooks']['lifecycle']['afterLoadRemote']['emit']\n >[0]\n | undefined;\n\n try {\n const { loadFactory = true } = options || {\n loadFactory: true,\n };\n // 1. Validate the parameters of the retrieved module. There are two module request methods: pkgName + expose and alias + expose.\n // 2. Request the snapshot information of the current host and globally store the obtained snapshot information. The retrieved module information is partially offline and partially online. The online module information will retrieve the modules used online.\n // 3. Retrieve the detailed information of the current module from global (remoteEntry address, expose resource address)\n // 4. After retrieving remoteEntry, call the init of the module, and then retrieve the exported content of the module through get\n // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button\n // id: alias(app1) + expose(button) = app1/button\n // id: alias(app1/utils) + expose(loadash/sort) = app1/utils/loadash/sort\n const { module, moduleOptions, remoteMatchInfo } =\n await this.getRemoteModuleAndOptions({\n id,\n });\n const {\n pkgNameOrAlias,\n remote,\n expose,\n id: idRes,\n remoteSnapshot,\n } = remoteMatchInfo;\n completeRequestId = idRes;\n completeExpose = expose;\n completeRemote = getRemoteInfo(remote);\n\n const moduleOrFactory = (await module.get(\n idRes,\n expose,\n options,\n remoteSnapshot,\n )) as T;\n\n const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({\n id: idRes,\n pkgNameOrAlias,\n expose,\n exposeModule: loadFactory ? moduleOrFactory : undefined,\n exposeModuleFactory: loadFactory ? undefined : moduleOrFactory,\n remote,\n options: moduleOptions,\n moduleInstance: module,\n origin: host,\n });\n\n this.setIdToRemoteMap(id, remoteMatchInfo);\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n origin: host,\n };\n\n if (typeof moduleWrapper === 'function') {\n return moduleWrapper as T;\n }\n\n return moduleOrFactory;\n } catch (error) {\n const { from = 'runtime' } = options || { from: 'runtime' };\n\n let failOver;\n try {\n failOver = await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n error,\n from,\n lifecycle: 'onLoad',\n expose: completeExpose,\n remote: completeRemote,\n origin: host,\n });\n } catch (hookError) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error: hookError,\n origin: host,\n };\n throw hookError;\n }\n\n if (!failOver) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n };\n throw error;\n }\n\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n recovered: true,\n };\n\n return failOver as T;\n } finally {\n if (afterLoadRemoteArgs) {\n await this.hooks.lifecycle.afterLoadRemote.emit(afterLoadRemoteArgs);\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void> {\n const { host } = this;\n const preloadResults: PreloadRemoteResult[] = [];\n\n await this.hooks.lifecycle.beforePreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n });\n\n const preloadOps: PreloadOptions = formatPreloadArgs(\n host.options.remotes,\n preloadOptions,\n );\n\n const createPreloadAssetOps = (ops: PreloadOptions[number]) => {\n const { preloadConfig, remote } = ops;\n const exposes = preloadConfig.exposes || [];\n\n if (!exposes.length) {\n return [\n {\n ops,\n id: `${remote.name}/*`,\n },\n ];\n }\n\n return exposes.map((expose) => ({\n ops: {\n ...ops,\n preloadConfig: {\n ...preloadConfig,\n exposes: [expose],\n },\n },\n id: composeRemoteRequestId(remote.name, expose),\n }));\n };\n\n let preloadError: Error | undefined;\n\n await Promise.all(\n preloadOps.flatMap(createPreloadAssetOps).map(async (assetOps) => {\n const { ops, id: preloadId } = assetOps;\n const { remote, preloadConfig } = ops;\n const remoteInfo = getRemoteInfo(remote);\n try {\n const { globalSnapshot, remoteSnapshot } =\n await host.snapshotHandler.loadRemoteSnapshotInfo({\n moduleInfo: remote,\n id: preloadId,\n initiator: 'preloadRemote',\n });\n\n const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({\n origin: host,\n preloadOptions: ops,\n remote,\n remoteInfo,\n globalSnapshot,\n remoteSnapshot,\n });\n if (!assets) {\n return;\n }\n const results = await preloadAssets(remoteInfo, host, assets, true, {\n initiator: 'preloadRemote',\n id: preloadId,\n });\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results,\n });\n } catch (error) {\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results: [\n {\n url: remoteInfo.entry,\n status: 'error',\n resourceType: /\\.json(?:$|[?#])/i.test(remoteInfo.entry)\n ? 'manifest'\n : 'remoteEntry',\n initiator: 'preloadRemote',\n id: preloadId,\n error,\n },\n ],\n });\n }\n }),\n );\n\n const failedResults = preloadResults.flatMap((preloadResult) =>\n preloadResult.results.filter(\n (result) => result.status === 'error' || result.status === 'timeout',\n ),\n );\n if (failedResults.length > 0) {\n preloadError = new Error(\n `preloadRemote failed to load ${failedResults.length} resource(s).`,\n );\n Object.assign(preloadError, {\n results: preloadResults,\n failedResults,\n });\n }\n\n await this.hooks.lifecycle.afterPreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n results: preloadResults,\n error: preloadError,\n });\n\n if (preloadError) {\n throw preloadError;\n }\n }\n\n registerRemotes(remotes: Remote[], options?: { force?: boolean }): void {\n const { host } = this;\n remotes.forEach((remote) => {\n this.registerRemote(remote, host.options.remotes, {\n force: options?.force,\n });\n });\n }\n\n async getRemoteModuleAndOptions(options: { id: string }): Promise<{\n module: Module;\n moduleOptions: ModuleOptions;\n remoteMatchInfo: LoadRemoteMatch;\n }> {\n const { host } = this;\n const { id } = options;\n let loadRemoteArgs;\n\n try {\n loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({\n id,\n options: host.options,\n origin: host,\n });\n } catch (error) {\n loadRemoteArgs = (await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n options: host.options,\n origin: host,\n from: 'runtime',\n error,\n lifecycle: 'beforeRequest',\n })) as {\n id: string;\n options: Options;\n origin: ModuleFederation;\n };\n\n if (!loadRemoteArgs) {\n throw error;\n }\n }\n\n const { id: idRes } = loadRemoteArgs;\n\n const remoteSplitInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n idRes,\n );\n if (!remoteSplitInfo) {\n try {\n error(\n RUNTIME_004,\n runtimeDescMap,\n {\n hostName: host.options.name,\n requestId: idRes,\n },\n undefined,\n optionsToMFContext(host.options),\n );\n } catch (matchError) {\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n options: host.options,\n error: matchError,\n origin: host,\n });\n throw matchError;\n }\n }\n\n const { remote: rawRemote } = remoteSplitInfo;\n const remoteInfo = getRemoteInfo(rawRemote);\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n remoteInfo,\n origin: host,\n });\n const matchInfo =\n await host.sharedHandler.hooks.lifecycle.afterResolve.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n origin: host,\n remoteInfo,\n });\n\n const { remote, expose } = matchInfo;\n assert(\n remote && expose,\n `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`,\n );\n let module: Module | undefined = host.moduleCache.get(remote.name);\n\n const moduleOptions: ModuleOptions = {\n host: host,\n remoteInfo,\n };\n\n if (!module) {\n module = new Module(moduleOptions);\n host.moduleCache.set(remote.name, module);\n }\n return {\n module,\n moduleOptions,\n remoteMatchInfo: matchInfo,\n };\n }\n\n registerRemote(\n remote: Remote,\n targetRemotes: Remote[],\n options?: { force?: boolean },\n ): void {\n const { host } = this;\n const normalizeRemote = () => {\n if (remote.alias) {\n // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error\n // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported\n const findEqual = targetRemotes.find(\n (item) =>\n remote.alias &&\n (item.name.startsWith(remote.alias) ||\n item.alias?.startsWith(remote.alias)),\n );\n assert(\n !findEqual,\n `The alias ${remote.alias} of remote ${\n remote.name\n } is not allowed to be the prefix of ${\n findEqual && findEqual.name\n } name or alias`,\n );\n }\n // Set the remote entry to a complete path\n if ('entry' in remote) {\n if (\n isBrowserEnvValue &&\n typeof window !== 'undefined' &&\n !remote.entry.startsWith('http')\n ) {\n remote.entry = new URL(remote.entry, window.location.origin).href;\n }\n }\n if (!remote.shareScope) {\n remote.shareScope = DEFAULT_SCOPE;\n }\n if (!remote.type) {\n remote.type = DEFAULT_REMOTE_TYPE;\n }\n };\n this.hooks.lifecycle.beforeRegisterRemote.emit({ remote, origin: host });\n const registeredRemote = targetRemotes.find(\n (item) => item.name === remote.name,\n );\n if (!registeredRemote) {\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n } else {\n const messages = [\n `The remote \"${remote.name}\" is already registered.`,\n 'Please note that overriding it may cause unexpected errors.',\n ];\n if (options?.force) {\n // remove registered remote\n this.removeRemote(registeredRemote);\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n warn(messages.join(' '));\n }\n }\n }\n\n private removeRemote(remote: Remote): void {\n try {\n const { host } = this;\n const { name } = remote;\n const remoteIndex = host.options.remotes.findIndex(\n (item) => item.name === name,\n );\n if (remoteIndex !== -1) {\n host.options.remotes.splice(remoteIndex, 1);\n }\n const loadedModule = host.moduleCache.get(remote.name);\n if (loadedModule) {\n const remoteInfo = loadedModule.remoteInfo;\n const key = remoteInfo.entryGlobalName as keyof typeof CurrentGlobal;\n\n if (CurrentGlobal[key]) {\n if (\n Object.getOwnPropertyDescriptor(CurrentGlobal, key)?.configurable\n ) {\n delete CurrentGlobal[key];\n } else {\n // @ts-ignore\n CurrentGlobal[key] = undefined;\n }\n }\n const remoteEntryUniqueKey = getRemoteEntryUniqueKey(\n loadedModule.remoteInfo,\n );\n\n if (globalLoading[remoteEntryUniqueKey]) {\n delete globalLoading[remoteEntryUniqueKey];\n }\n\n host.snapshotHandler.manifestCache.delete(remoteInfo.entry);\n\n // delete unloaded shared and instance\n let remoteInsId = remoteInfo.buildVersion\n ? composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion)\n : remoteInfo.name;\n const remoteInsIndex =\n CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {\n if (remoteInfo.buildVersion) {\n return ins.options.id === remoteInsId;\n } else {\n return ins.name === remoteInsId;\n }\n });\n if (remoteInsIndex !== -1) {\n const remoteIns =\n CurrentGlobal.__FEDERATION__.__INSTANCES__[remoteInsIndex];\n remoteInsId = remoteIns.options.id || remoteInsId;\n const globalShareScopeMap = getGlobalShareScope();\n\n let isAllSharedNotUsed = true;\n const needDeleteKeys: Array<[string, string, string, string]> = [];\n Object.keys(globalShareScopeMap).forEach((instId) => {\n const shareScopeMap = globalShareScopeMap[instId];\n shareScopeMap &&\n Object.keys(shareScopeMap).forEach((shareScope) => {\n const shareScopeVal = shareScopeMap[shareScope];\n shareScopeVal &&\n Object.keys(shareScopeVal).forEach((shareName) => {\n const sharedPkgs = shareScopeVal[shareName];\n sharedPkgs &&\n Object.keys(sharedPkgs).forEach((shareVersion) => {\n const shared = sharedPkgs[shareVersion];\n if (\n shared &&\n typeof shared === 'object' &&\n shared.from === remoteInfo.name\n ) {\n if (shared.loaded || shared.loading) {\n shared.useIn = shared.useIn.filter(\n (usedHostName) =>\n usedHostName !== remoteInfo.name,\n );\n if (shared.useIn.length) {\n isAllSharedNotUsed = false;\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n }\n });\n });\n });\n });\n\n if (isAllSharedNotUsed) {\n remoteIns.shareScopeMap = {};\n delete globalShareScopeMap[remoteInsId];\n }\n needDeleteKeys.forEach(\n ([insId, shareScope, shareName, shareVersion]) => {\n delete globalShareScopeMap[insId]?.[shareScope]?.[shareName]?.[\n shareVersion\n ];\n },\n );\n CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);\n }\n\n const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);\n if (hostGlobalSnapshot) {\n const remoteKey =\n hostGlobalSnapshot &&\n 'remotesInfo' in hostGlobalSnapshot &&\n hostGlobalSnapshot.remotesInfo &&\n getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;\n if (remoteKey) {\n delete hostGlobalSnapshot.remotesInfo[remoteKey];\n if (\n //eslint-disable-next-line no-extra-boolean-cast\n Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])\n ) {\n delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];\n }\n }\n }\n\n host.moduleCache.delete(remote.name);\n }\n } catch (err) {\n logger.error(\n `removeRemote failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,gBAAb,MAA2B;CAgJzB,YAAY,MAAwB;eA5I5B,IAAIA,kCAAa;GACvB,sBAAsB,I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,SAAS,cAAc,aAChD;OAGL;AACD,kCAAc,eAAe,cAAc,OAAO,gBAAgB,EAAE;;IAGtE,MAAM,EAAE,uBAAuBC,4CAAoB,QAAQ,KAAK;AAChE,QAAI,oBAAoB;KACtB,MAAM,YACJ,sBACA,iBAAiB,sBACjB,mBAAmB,eACnBC,kCAAmB,mBAAmB,aAAa,OAAO,KAAK,CAAC;AAClE,SAAI,WAAW;AACb,aAAO,mBAAmB,YAAY;AACtC,UAEE,QAAQC,sBAAO,eAAe,qBAAqB,WAAW,CAE9D,QAAOA,sBAAO,eAAe,qBAAqB;;;AAKxD,SAAK,YAAY,OAAO,OAAO,KAAK;;WAE/B,KAAK;AACZ,yBAAO,MACL,wBAAwB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GACzE"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PluginSystem","SyncWaterfallHook","AsyncWaterfallHook","AsyncHook","SyncHook","matchRemoteWithNameAndExpose","getRemoteInfo","formatPreloadArgs","composeRemoteRequestId","preloadAssets","RUNTIME_004","runtimeDescMap","optionsToMFContext","Module","isBrowserEnvValue","DEFAULT_SCOPE","DEFAULT_REMOTE_TYPE","getInfoWithoutType","CurrentGlobal","getFMId","Global","getGlobalRemoteInfo","getRemoteEntryUniqueKey","globalLoading","getGlobalShareScope"],"sources":["../../src/remote/index.ts"],"sourcesContent":["import {\n isBrowserEnvValue,\n warn,\n composeKeyWithSeparator,\n ModuleInfo,\n GlobalModuleInfo,\n} from '@module-federation/sdk';\nimport { RUNTIME_004, runtimeDescMap } from '@module-federation/error-codes';\nimport {\n Global,\n getInfoWithoutType,\n globalLoading,\n CurrentGlobal,\n} from '../global';\nimport {\n Options,\n UserOptions,\n PreloadAssets,\n PreloadOptions,\n PreloadRemoteArgs,\n PreloadRemoteResult,\n Remote,\n RemoteInfo,\n RemoteEntryExports,\n CallFrom,\n} from '../type';\nimport { ModuleFederation } from '../core';\nimport {\n PluginSystem,\n AsyncHook,\n AsyncWaterfallHook,\n SyncHook,\n SyncWaterfallHook,\n} from '../utils/hooks';\nimport {\n assert,\n error,\n getRemoteInfo,\n getRemoteEntryUniqueKey,\n getFMId,\n composeRemoteRequestId,\n matchRemoteWithNameAndExpose,\n optionsToMFContext,\n logger,\n} from '../utils';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { Module, ModuleOptions } from '../module';\nimport { formatPreloadArgs, preloadAssets } from '../utils/preload';\nimport { getGlobalShareScope } from '../utils/share';\nimport { getGlobalRemoteInfo } from '../plugins/snapshot/SnapshotHandler';\n\nexport interface LoadRemoteMatch {\n id: string;\n pkgNameOrAlias: string;\n expose: string;\n remote: Remote;\n options: Options;\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n}\n\nexport class RemoteHandler {\n host: ModuleFederation;\n idToRemoteMap: Record<string, { name: string; expose: string }>;\n\n hooks = new PluginSystem({\n beforeRegisterRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('beforeRegisterRemote'),\n registerRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('registerRemote'),\n beforeRequest: new AsyncWaterfallHook<{\n id: string;\n options: Options;\n origin: ModuleFederation;\n }>('beforeRequest'),\n afterMatchRemote: new AsyncHook<\n [\n {\n id: string;\n options: Options;\n remote?: Remote;\n expose?: string;\n remoteInfo?: RemoteInfo;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterMatchRemote'),\n onLoad: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n pkgNameOrAlias: string;\n remote: Remote;\n options: ModuleOptions;\n origin: ModuleFederation;\n exposeModule: any;\n exposeModuleFactory: any;\n moduleInstance: Module;\n },\n ],\n unknown\n >('onLoad'),\n afterLoadRemote: new AsyncHook<\n [\n {\n id: string;\n expose?: string;\n remote?: RemoteInfo;\n options?: {\n loadFactory?: boolean;\n from?: CallFrom;\n };\n error?: unknown;\n recovered?: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterLoadRemote'),\n handlePreloadModule: new SyncHook<\n [\n {\n id: string;\n name: string;\n remote: Remote;\n remoteSnapshot: ModuleInfo;\n preloadConfig: PreloadRemoteArgs;\n origin: ModuleFederation;\n },\n ],\n void\n >('handlePreloadModule'),\n errorLoadRemote: new AsyncHook<\n [\n {\n id: string;\n error: unknown;\n options?: any;\n from: CallFrom;\n lifecycle:\n | 'beforeRequest'\n | 'beforeLoadShare'\n | 'afterResolve'\n | 'onLoad';\n remote?: RemoteInfo;\n expose?: string;\n origin: ModuleFederation;\n },\n ],\n void | unknown\n >('errorLoadRemote'),\n beforePreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n },\n ]\n >('beforePreloadRemote'),\n generatePreloadAssets: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n preloadOptions: PreloadOptions[number];\n remote: Remote;\n remoteInfo: RemoteInfo;\n remoteSnapshot: ModuleInfo;\n globalSnapshot: GlobalModuleInfo;\n },\n ],\n Promise<PreloadAssets>\n >('generatePreloadAssets'),\n afterPreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n results: PreloadRemoteResult[];\n error?: unknown;\n },\n ]\n >('afterPreloadRemote'),\n // TODO: Move to loaderHook\n loadEntry: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n loaderHook: ModuleFederation['loaderHook'];\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n },\n ],\n Promise<RemoteEntryExports | void> | RemoteEntryExports | void\n >(),\n });\n\n constructor(host: ModuleFederation) {\n this.host = host;\n this.idToRemoteMap = {};\n }\n\n formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions) {\n const userRemotes = userOptions.remotes || [];\n\n return userRemotes.reduce((res, remote) => {\n this.registerRemote(remote, res, { force: false });\n return res;\n }, globalOptions.remotes);\n }\n\n setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch) {\n const { remote, expose } = remoteMatchInfo;\n const { name, alias } = remote;\n this.idToRemoteMap[id] = { name: remote.name, expose };\n if (alias && id.startsWith(name)) {\n const idWithAlias = id.replace(name, alias);\n this.idToRemoteMap[idWithAlias] = { name: remote.name, expose };\n return;\n }\n\n if (alias && id.startsWith(alias)) {\n const idWithName = id.replace(alias, name);\n this.idToRemoteMap[idWithName] = { name: remote.name, expose };\n }\n }\n\n // eslint-disable-next-line max-lines-per-function\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async loadRemote<T>(\n id: string,\n options?: { loadFactory?: boolean; from: CallFrom },\n ): Promise<T | null> {\n const { host } = this;\n const startMatchInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n id,\n );\n let completeRequestId = id;\n let completeExpose = startMatchInfo?.expose;\n let completeRemote = startMatchInfo\n ? getRemoteInfo(startMatchInfo.remote)\n : undefined;\n let afterLoadRemoteArgs:\n | Parameters<\n RemoteHandler['hooks']['lifecycle']['afterLoadRemote']['emit']\n >[0]\n | undefined;\n\n try {\n const { loadFactory = true } = options || {\n loadFactory: true,\n };\n // 1. Validate the parameters of the retrieved module. There are two module request methods: pkgName + expose and alias + expose.\n // 2. Request the snapshot information of the current host and globally store the obtained snapshot information. The retrieved module information is partially offline and partially online. The online module information will retrieve the modules used online.\n // 3. Retrieve the detailed information of the current module from global (remoteEntry address, expose resource address)\n // 4. After retrieving remoteEntry, call the init of the module, and then retrieve the exported content of the module through get\n // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button\n // id: alias(app1) + expose(button) = app1/button\n // id: alias(app1/utils) + expose(loadash/sort) = app1/utils/loadash/sort\n const { module, moduleOptions, remoteMatchInfo } =\n await this.getRemoteModuleAndOptions({\n id,\n });\n const {\n pkgNameOrAlias,\n remote,\n expose,\n id: idRes,\n remoteSnapshot,\n } = remoteMatchInfo;\n completeRequestId = idRes;\n completeExpose = expose;\n completeRemote = getRemoteInfo(remote);\n\n const moduleOrFactory = (await module.get(\n idRes,\n expose,\n options,\n remoteSnapshot,\n )) as T;\n\n const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({\n id: idRes,\n pkgNameOrAlias,\n expose,\n exposeModule: loadFactory ? moduleOrFactory : undefined,\n exposeModuleFactory: loadFactory ? undefined : moduleOrFactory,\n remote,\n options: moduleOptions,\n moduleInstance: module,\n origin: host,\n });\n\n this.setIdToRemoteMap(id, remoteMatchInfo);\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n origin: host,\n };\n\n if (typeof moduleWrapper === 'function') {\n return moduleWrapper as T;\n }\n\n return moduleOrFactory;\n } catch (error) {\n const { from = 'runtime' } = options || { from: 'runtime' };\n\n let failOver;\n try {\n failOver = await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n error,\n from,\n lifecycle: 'onLoad',\n expose: completeExpose,\n remote: completeRemote,\n origin: host,\n });\n } catch (hookError) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error: hookError,\n origin: host,\n };\n throw hookError;\n }\n\n if (!failOver) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n };\n throw error;\n }\n\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n recovered: true,\n };\n\n return failOver as T;\n } finally {\n if (afterLoadRemoteArgs) {\n await this.hooks.lifecycle.afterLoadRemote.emit(afterLoadRemoteArgs);\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void> {\n const { host } = this;\n const preloadResults: PreloadRemoteResult[] = [];\n\n await this.hooks.lifecycle.beforePreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n });\n\n const preloadOps: PreloadOptions = formatPreloadArgs(\n host.options.remotes,\n preloadOptions,\n );\n\n const createPreloadAssetOps = (ops: PreloadOptions[number]) => {\n const { preloadConfig, remote } = ops;\n const exposes = preloadConfig.exposes || [];\n\n if (!exposes.length) {\n return [\n {\n ops,\n id: `${remote.name}/*`,\n },\n ];\n }\n\n return exposes.map((expose) => ({\n ops: {\n ...ops,\n preloadConfig: {\n ...preloadConfig,\n exposes: [expose],\n },\n },\n id: composeRemoteRequestId(remote.name, expose),\n }));\n };\n\n let preloadError: Error | undefined;\n\n await Promise.all(\n preloadOps.flatMap(createPreloadAssetOps).map(async (assetOps) => {\n const { ops, id: preloadId } = assetOps;\n const { remote, preloadConfig } = ops;\n const remoteInfo = getRemoteInfo(remote);\n try {\n const { globalSnapshot, remoteSnapshot } =\n await host.snapshotHandler.loadRemoteSnapshotInfo({\n moduleInfo: remote,\n id: preloadId,\n initiator: 'preloadRemote',\n });\n\n const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({\n origin: host,\n preloadOptions: ops,\n remote,\n remoteInfo,\n globalSnapshot,\n remoteSnapshot,\n });\n if (!assets) {\n return;\n }\n const results = await preloadAssets(remoteInfo, host, assets, true, {\n initiator: 'preloadRemote',\n id: preloadId,\n });\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results,\n });\n } catch (error) {\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results: [\n {\n url: remoteInfo.entry,\n status: 'error',\n resourceType: /\\.json(?:$|[?#])/i.test(remoteInfo.entry)\n ? 'manifest'\n : 'remoteEntry',\n initiator: 'preloadRemote',\n id: preloadId,\n error,\n },\n ],\n });\n }\n }),\n );\n\n const failedResults = preloadResults.flatMap((preloadResult) =>\n preloadResult.results.filter(\n (result) => result.status === 'error' || result.status === 'timeout',\n ),\n );\n if (failedResults.length > 0) {\n preloadError = new Error(\n `preloadRemote failed to load ${failedResults.length} resource(s).`,\n );\n Object.assign(preloadError, {\n results: preloadResults,\n failedResults,\n });\n }\n\n await this.hooks.lifecycle.afterPreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n results: preloadResults,\n error: preloadError,\n });\n\n if (preloadError) {\n throw preloadError;\n }\n }\n\n registerRemotes(remotes: Remote[], options?: { force?: boolean }): void {\n const { host } = this;\n remotes.forEach((remote) => {\n this.registerRemote(remote, host.options.remotes, {\n force: options?.force,\n });\n });\n }\n\n async getRemoteModuleAndOptions(options: { id: string }): Promise<{\n module: Module;\n moduleOptions: ModuleOptions;\n remoteMatchInfo: LoadRemoteMatch;\n }> {\n const { host } = this;\n const { id } = options;\n let loadRemoteArgs;\n\n try {\n loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({\n id,\n options: host.options,\n origin: host,\n });\n } catch (error) {\n loadRemoteArgs = (await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n options: host.options,\n origin: host,\n from: 'runtime',\n error,\n lifecycle: 'beforeRequest',\n })) as {\n id: string;\n options: Options;\n origin: ModuleFederation;\n };\n\n if (!loadRemoteArgs) {\n throw error;\n }\n }\n\n const { id: idRes } = loadRemoteArgs;\n\n const remoteSplitInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n idRes,\n );\n if (!remoteSplitInfo) {\n try {\n error(\n RUNTIME_004,\n runtimeDescMap,\n {\n hostName: host.options.name,\n requestId: idRes,\n },\n undefined,\n optionsToMFContext(host.options),\n );\n } catch (matchError) {\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n options: host.options,\n error: matchError,\n origin: host,\n });\n throw matchError;\n }\n }\n\n const { remote: rawRemote } = remoteSplitInfo;\n const remoteInfo = getRemoteInfo(rawRemote);\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n remoteInfo,\n origin: host,\n });\n const matchInfo =\n await host.sharedHandler.hooks.lifecycle.afterResolve.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n origin: host,\n remoteInfo,\n });\n\n const { remote, expose } = matchInfo;\n assert(\n remote && expose,\n `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`,\n );\n let module: Module | undefined = host.moduleCache.get(remote.name);\n\n const moduleOptions: ModuleOptions = {\n host: host,\n remoteInfo,\n };\n\n if (!module) {\n module = new Module(moduleOptions);\n host.moduleCache.set(remote.name, module);\n }\n return {\n module,\n moduleOptions,\n remoteMatchInfo: matchInfo,\n };\n }\n\n registerRemote(\n remote: Remote,\n targetRemotes: Remote[],\n options?: { force?: boolean },\n ): void {\n const { host } = this;\n const normalizeRemote = () => {\n if (remote.alias) {\n // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error\n // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported\n const findEqual = targetRemotes.find(\n (item) =>\n remote.alias &&\n (item.name.startsWith(remote.alias) ||\n item.alias?.startsWith(remote.alias)),\n );\n assert(\n !findEqual,\n `The alias ${remote.alias} of remote ${\n remote.name\n } is not allowed to be the prefix of ${\n findEqual && findEqual.name\n } name or alias`,\n );\n }\n // Set the remote entry to a complete path\n if ('entry' in remote) {\n if (\n isBrowserEnvValue &&\n typeof window !== 'undefined' &&\n !remote.entry.startsWith('http')\n ) {\n remote.entry = new URL(remote.entry, window.location.origin).href;\n }\n }\n if (!remote.shareScope) {\n remote.shareScope = DEFAULT_SCOPE;\n }\n if (!remote.type) {\n remote.type = DEFAULT_REMOTE_TYPE;\n }\n };\n this.hooks.lifecycle.beforeRegisterRemote.emit({ remote, origin: host });\n const registeredRemote = targetRemotes.find(\n (item) => item.name === remote.name,\n );\n if (!registeredRemote) {\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n } else {\n const messages = [\n `The remote \"${remote.name}\" is already registered.`,\n 'Please note that overriding it may cause unexpected errors.',\n ];\n if (options?.force) {\n // remove registered remote\n this.removeRemote(registeredRemote);\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n warn(messages.join(' '));\n }\n }\n }\n\n private removeRemote(remote: Remote): void {\n try {\n const { host } = this;\n const { name } = remote;\n const remoteIndex = host.options.remotes.findIndex(\n (item) => item.name === name,\n );\n if (remoteIndex !== -1) {\n host.options.remotes.splice(remoteIndex, 1);\n }\n const globalSnapshotKey = getInfoWithoutType(\n CurrentGlobal.__FEDERATION__.moduleInfo,\n getFMId(remote),\n ).key;\n delete CurrentGlobal.__FEDERATION__.moduleInfo[globalSnapshotKey];\n\n if ('entry' in remote) {\n host.snapshotHandler.manifestCache.delete(remote.entry);\n delete Global.__FEDERATION__.__MANIFEST_LOADING__[remote.entry];\n }\n\n const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);\n if (hostGlobalSnapshot) {\n const remoteKey =\n hostGlobalSnapshot &&\n 'remotesInfo' in hostGlobalSnapshot &&\n hostGlobalSnapshot.remotesInfo &&\n getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;\n if (remoteKey) {\n delete hostGlobalSnapshot.remotesInfo[remoteKey];\n }\n }\n\n const loadedModule = host.moduleCache.get(remote.name);\n if (loadedModule) {\n const remoteInfo = loadedModule.remoteInfo;\n const key = remoteInfo.entryGlobalName as keyof typeof CurrentGlobal;\n\n if (CurrentGlobal[key]) {\n if (\n Object.getOwnPropertyDescriptor(CurrentGlobal, key)?.configurable\n ) {\n delete CurrentGlobal[key];\n } else {\n // @ts-ignore\n CurrentGlobal[key] = undefined;\n }\n }\n const remoteEntryUniqueKey = getRemoteEntryUniqueKey(\n loadedModule.remoteInfo,\n );\n\n if (globalLoading[remoteEntryUniqueKey]) {\n delete globalLoading[remoteEntryUniqueKey];\n }\n\n // delete unloaded shared and instance\n let remoteInsId = remoteInfo.buildVersion\n ? composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion)\n : remoteInfo.name;\n const remoteInsIndex =\n CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {\n if (remoteInfo.buildVersion) {\n return ins.options.id === remoteInsId;\n } else {\n return ins.name === remoteInsId;\n }\n });\n if (remoteInsIndex !== -1) {\n const remoteIns =\n CurrentGlobal.__FEDERATION__.__INSTANCES__[remoteInsIndex];\n remoteInsId = remoteIns.options.id || remoteInsId;\n const globalShareScopeMap = getGlobalShareScope();\n\n let isAllSharedNotUsed = true;\n const needDeleteKeys: Array<[string, string, string, string]> = [];\n Object.keys(globalShareScopeMap).forEach((instId) => {\n const shareScopeMap = globalShareScopeMap[instId];\n shareScopeMap &&\n Object.keys(shareScopeMap).forEach((shareScope) => {\n const shareScopeVal = shareScopeMap[shareScope];\n shareScopeVal &&\n Object.keys(shareScopeVal).forEach((shareName) => {\n const sharedPkgs = shareScopeVal[shareName];\n sharedPkgs &&\n Object.keys(sharedPkgs).forEach((shareVersion) => {\n const shared = sharedPkgs[shareVersion];\n if (\n shared &&\n typeof shared === 'object' &&\n shared.from === remoteInfo.name\n ) {\n if (shared.loaded || shared.loading) {\n shared.useIn = shared.useIn.filter(\n (usedHostName) =>\n usedHostName !== remoteInfo.name,\n );\n if (shared.useIn.length) {\n isAllSharedNotUsed = false;\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n }\n });\n });\n });\n });\n\n if (isAllSharedNotUsed) {\n remoteIns.shareScopeMap = {};\n delete globalShareScopeMap[remoteInsId];\n }\n needDeleteKeys.forEach(\n ([insId, shareScope, shareName, shareVersion]) => {\n delete globalShareScopeMap[insId]?.[shareScope]?.[shareName]?.[\n shareVersion\n ];\n },\n );\n CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);\n }\n\n host.moduleCache.delete(remote.name);\n }\n } catch (err) {\n logger.error(\n `removeRemote failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n}\n"],"mappings":";;;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,iBAAiB;SAChD,MAAM,SAAS,WAAW;AAC1B,aACE,UACA,OAAO,WAAW,YAClB,OAAO,SAAS,WAAW,KAE3B,KAAI,OAAO,UAAU,OAAO,SAAS;AACnC,iBAAO,QAAQ,OAAO,MAAM,QACzB,iBACC,iBAAiB,WAAW,KAC/B;AACD,cAAI,OAAO,MAAM,OACf,sBAAqB;cAErB,gBAAe,KAAK;WAClB;WACA;WACA;WACA;WACD,CAAC;eAGJ,gBAAe,KAAK;UAClB;UACA;UACA;UACA;UACD,CAAC;UAGN;SACJ;QACJ;OACJ;AAEF,SAAI,oBAAoB;AACtB,gBAAU,gBAAgB,EAAE;AAC5B,aAAO,oBAAoB;;AAE7B,oBAAe,SACZ,CAAC,OAAO,YAAY,WAAW,kBAAkB;AAChD,aAAO,oBAAoB,SAAS,cAAc,aAChD;OAGL;AACD,kCAAc,eAAe,cAAc,OAAO,gBAAgB,EAAE;;AAGtE,SAAK,YAAY,OAAO,OAAO,KAAK;;WAE/B,KAAK;AACZ,yBAAO,MACL,wBAAwB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GACzE"}
|
package/dist/remote/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert, error, logger } from "../utils/logger.js";
|
|
2
|
+
import { getFMId } from "../utils/tool.js";
|
|
2
3
|
import { CurrentGlobal, Global, getInfoWithoutType, globalLoading } from "../global.js";
|
|
3
4
|
import { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from "../constant.js";
|
|
4
5
|
import { getGlobalShareScope } from "../utils/share.js";
|
|
@@ -365,6 +366,17 @@ var RemoteHandler = class {
|
|
|
365
366
|
const { name } = remote;
|
|
366
367
|
const remoteIndex = host.options.remotes.findIndex((item) => item.name === name);
|
|
367
368
|
if (remoteIndex !== -1) host.options.remotes.splice(remoteIndex, 1);
|
|
369
|
+
const globalSnapshotKey = getInfoWithoutType(CurrentGlobal.__FEDERATION__.moduleInfo, getFMId(remote)).key;
|
|
370
|
+
delete CurrentGlobal.__FEDERATION__.moduleInfo[globalSnapshotKey];
|
|
371
|
+
if ("entry" in remote) {
|
|
372
|
+
host.snapshotHandler.manifestCache.delete(remote.entry);
|
|
373
|
+
delete Global.__FEDERATION__.__MANIFEST_LOADING__[remote.entry];
|
|
374
|
+
}
|
|
375
|
+
const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);
|
|
376
|
+
if (hostGlobalSnapshot) {
|
|
377
|
+
const remoteKey = hostGlobalSnapshot && "remotesInfo" in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
378
|
+
if (remoteKey) delete hostGlobalSnapshot.remotesInfo[remoteKey];
|
|
379
|
+
}
|
|
368
380
|
const loadedModule = host.moduleCache.get(remote.name);
|
|
369
381
|
if (loadedModule) {
|
|
370
382
|
const remoteInfo = loadedModule.remoteInfo;
|
|
@@ -373,7 +385,6 @@ var RemoteHandler = class {
|
|
|
373
385
|
else CurrentGlobal[key] = void 0;
|
|
374
386
|
const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
|
|
375
387
|
if (globalLoading[remoteEntryUniqueKey]) delete globalLoading[remoteEntryUniqueKey];
|
|
376
|
-
host.snapshotHandler.manifestCache.delete(remoteInfo.entry);
|
|
377
388
|
let remoteInsId = remoteInfo.buildVersion ? composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion) : remoteInfo.name;
|
|
378
389
|
const remoteInsIndex = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {
|
|
379
390
|
if (remoteInfo.buildVersion) return ins.options.id === remoteInsId;
|
|
@@ -421,14 +432,6 @@ var RemoteHandler = class {
|
|
|
421
432
|
});
|
|
422
433
|
CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);
|
|
423
434
|
}
|
|
424
|
-
const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);
|
|
425
|
-
if (hostGlobalSnapshot) {
|
|
426
|
-
const remoteKey = hostGlobalSnapshot && "remotesInfo" in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
427
|
-
if (remoteKey) {
|
|
428
|
-
delete hostGlobalSnapshot.remotesInfo[remoteKey];
|
|
429
|
-
if (Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
435
|
host.moduleCache.delete(remote.name);
|
|
433
436
|
}
|
|
434
437
|
} catch (err) {
|
package/dist/remote/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Module"],"sources":["../../src/remote/index.ts"],"sourcesContent":["import {\n isBrowserEnvValue,\n warn,\n composeKeyWithSeparator,\n ModuleInfo,\n GlobalModuleInfo,\n} from '@module-federation/sdk';\nimport { RUNTIME_004, runtimeDescMap } from '@module-federation/error-codes';\nimport {\n Global,\n getInfoWithoutType,\n globalLoading,\n CurrentGlobal,\n} from '../global';\nimport {\n Options,\n UserOptions,\n PreloadAssets,\n PreloadOptions,\n PreloadRemoteArgs,\n PreloadRemoteResult,\n Remote,\n RemoteInfo,\n RemoteEntryExports,\n CallFrom,\n} from '../type';\nimport { ModuleFederation } from '../core';\nimport {\n PluginSystem,\n AsyncHook,\n AsyncWaterfallHook,\n SyncHook,\n SyncWaterfallHook,\n} from '../utils/hooks';\nimport {\n assert,\n error,\n getRemoteInfo,\n getRemoteEntryUniqueKey,\n composeRemoteRequestId,\n matchRemoteWithNameAndExpose,\n optionsToMFContext,\n logger,\n} from '../utils';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { Module, ModuleOptions } from '../module';\nimport { formatPreloadArgs, preloadAssets } from '../utils/preload';\nimport { getGlobalShareScope } from '../utils/share';\nimport { getGlobalRemoteInfo } from '../plugins/snapshot/SnapshotHandler';\n\nexport interface LoadRemoteMatch {\n id: string;\n pkgNameOrAlias: string;\n expose: string;\n remote: Remote;\n options: Options;\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n}\n\nexport class RemoteHandler {\n host: ModuleFederation;\n idToRemoteMap: Record<string, { name: string; expose: string }>;\n\n hooks = new PluginSystem({\n beforeRegisterRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('beforeRegisterRemote'),\n registerRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('registerRemote'),\n beforeRequest: new AsyncWaterfallHook<{\n id: string;\n options: Options;\n origin: ModuleFederation;\n }>('beforeRequest'),\n afterMatchRemote: new AsyncHook<\n [\n {\n id: string;\n options: Options;\n remote?: Remote;\n expose?: string;\n remoteInfo?: RemoteInfo;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterMatchRemote'),\n onLoad: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n pkgNameOrAlias: string;\n remote: Remote;\n options: ModuleOptions;\n origin: ModuleFederation;\n exposeModule: any;\n exposeModuleFactory: any;\n moduleInstance: Module;\n },\n ],\n unknown\n >('onLoad'),\n afterLoadRemote: new AsyncHook<\n [\n {\n id: string;\n expose?: string;\n remote?: RemoteInfo;\n options?: {\n loadFactory?: boolean;\n from?: CallFrom;\n };\n error?: unknown;\n recovered?: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterLoadRemote'),\n handlePreloadModule: new SyncHook<\n [\n {\n id: string;\n name: string;\n remote: Remote;\n remoteSnapshot: ModuleInfo;\n preloadConfig: PreloadRemoteArgs;\n origin: ModuleFederation;\n },\n ],\n void\n >('handlePreloadModule'),\n errorLoadRemote: new AsyncHook<\n [\n {\n id: string;\n error: unknown;\n options?: any;\n from: CallFrom;\n lifecycle:\n | 'beforeRequest'\n | 'beforeLoadShare'\n | 'afterResolve'\n | 'onLoad';\n remote?: RemoteInfo;\n expose?: string;\n origin: ModuleFederation;\n },\n ],\n void | unknown\n >('errorLoadRemote'),\n beforePreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n },\n ]\n >('beforePreloadRemote'),\n generatePreloadAssets: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n preloadOptions: PreloadOptions[number];\n remote: Remote;\n remoteInfo: RemoteInfo;\n remoteSnapshot: ModuleInfo;\n globalSnapshot: GlobalModuleInfo;\n },\n ],\n Promise<PreloadAssets>\n >('generatePreloadAssets'),\n afterPreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n results: PreloadRemoteResult[];\n error?: unknown;\n },\n ]\n >('afterPreloadRemote'),\n // TODO: Move to loaderHook\n loadEntry: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n loaderHook: ModuleFederation['loaderHook'];\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n },\n ],\n Promise<RemoteEntryExports | void> | RemoteEntryExports | void\n >(),\n });\n\n constructor(host: ModuleFederation) {\n this.host = host;\n this.idToRemoteMap = {};\n }\n\n formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions) {\n const userRemotes = userOptions.remotes || [];\n\n return userRemotes.reduce((res, remote) => {\n this.registerRemote(remote, res, { force: false });\n return res;\n }, globalOptions.remotes);\n }\n\n setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch) {\n const { remote, expose } = remoteMatchInfo;\n const { name, alias } = remote;\n this.idToRemoteMap[id] = { name: remote.name, expose };\n if (alias && id.startsWith(name)) {\n const idWithAlias = id.replace(name, alias);\n this.idToRemoteMap[idWithAlias] = { name: remote.name, expose };\n return;\n }\n\n if (alias && id.startsWith(alias)) {\n const idWithName = id.replace(alias, name);\n this.idToRemoteMap[idWithName] = { name: remote.name, expose };\n }\n }\n\n // eslint-disable-next-line max-lines-per-function\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async loadRemote<T>(\n id: string,\n options?: { loadFactory?: boolean; from: CallFrom },\n ): Promise<T | null> {\n const { host } = this;\n const startMatchInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n id,\n );\n let completeRequestId = id;\n let completeExpose = startMatchInfo?.expose;\n let completeRemote = startMatchInfo\n ? getRemoteInfo(startMatchInfo.remote)\n : undefined;\n let afterLoadRemoteArgs:\n | Parameters<\n RemoteHandler['hooks']['lifecycle']['afterLoadRemote']['emit']\n >[0]\n | undefined;\n\n try {\n const { loadFactory = true } = options || {\n loadFactory: true,\n };\n // 1. Validate the parameters of the retrieved module. There are two module request methods: pkgName + expose and alias + expose.\n // 2. Request the snapshot information of the current host and globally store the obtained snapshot information. The retrieved module information is partially offline and partially online. The online module information will retrieve the modules used online.\n // 3. Retrieve the detailed information of the current module from global (remoteEntry address, expose resource address)\n // 4. After retrieving remoteEntry, call the init of the module, and then retrieve the exported content of the module through get\n // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button\n // id: alias(app1) + expose(button) = app1/button\n // id: alias(app1/utils) + expose(loadash/sort) = app1/utils/loadash/sort\n const { module, moduleOptions, remoteMatchInfo } =\n await this.getRemoteModuleAndOptions({\n id,\n });\n const {\n pkgNameOrAlias,\n remote,\n expose,\n id: idRes,\n remoteSnapshot,\n } = remoteMatchInfo;\n completeRequestId = idRes;\n completeExpose = expose;\n completeRemote = getRemoteInfo(remote);\n\n const moduleOrFactory = (await module.get(\n idRes,\n expose,\n options,\n remoteSnapshot,\n )) as T;\n\n const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({\n id: idRes,\n pkgNameOrAlias,\n expose,\n exposeModule: loadFactory ? moduleOrFactory : undefined,\n exposeModuleFactory: loadFactory ? undefined : moduleOrFactory,\n remote,\n options: moduleOptions,\n moduleInstance: module,\n origin: host,\n });\n\n this.setIdToRemoteMap(id, remoteMatchInfo);\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n origin: host,\n };\n\n if (typeof moduleWrapper === 'function') {\n return moduleWrapper as T;\n }\n\n return moduleOrFactory;\n } catch (error) {\n const { from = 'runtime' } = options || { from: 'runtime' };\n\n let failOver;\n try {\n failOver = await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n error,\n from,\n lifecycle: 'onLoad',\n expose: completeExpose,\n remote: completeRemote,\n origin: host,\n });\n } catch (hookError) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error: hookError,\n origin: host,\n };\n throw hookError;\n }\n\n if (!failOver) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n };\n throw error;\n }\n\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n recovered: true,\n };\n\n return failOver as T;\n } finally {\n if (afterLoadRemoteArgs) {\n await this.hooks.lifecycle.afterLoadRemote.emit(afterLoadRemoteArgs);\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void> {\n const { host } = this;\n const preloadResults: PreloadRemoteResult[] = [];\n\n await this.hooks.lifecycle.beforePreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n });\n\n const preloadOps: PreloadOptions = formatPreloadArgs(\n host.options.remotes,\n preloadOptions,\n );\n\n const createPreloadAssetOps = (ops: PreloadOptions[number]) => {\n const { preloadConfig, remote } = ops;\n const exposes = preloadConfig.exposes || [];\n\n if (!exposes.length) {\n return [\n {\n ops,\n id: `${remote.name}/*`,\n },\n ];\n }\n\n return exposes.map((expose) => ({\n ops: {\n ...ops,\n preloadConfig: {\n ...preloadConfig,\n exposes: [expose],\n },\n },\n id: composeRemoteRequestId(remote.name, expose),\n }));\n };\n\n let preloadError: Error | undefined;\n\n await Promise.all(\n preloadOps.flatMap(createPreloadAssetOps).map(async (assetOps) => {\n const { ops, id: preloadId } = assetOps;\n const { remote, preloadConfig } = ops;\n const remoteInfo = getRemoteInfo(remote);\n try {\n const { globalSnapshot, remoteSnapshot } =\n await host.snapshotHandler.loadRemoteSnapshotInfo({\n moduleInfo: remote,\n id: preloadId,\n initiator: 'preloadRemote',\n });\n\n const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({\n origin: host,\n preloadOptions: ops,\n remote,\n remoteInfo,\n globalSnapshot,\n remoteSnapshot,\n });\n if (!assets) {\n return;\n }\n const results = await preloadAssets(remoteInfo, host, assets, true, {\n initiator: 'preloadRemote',\n id: preloadId,\n });\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results,\n });\n } catch (error) {\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results: [\n {\n url: remoteInfo.entry,\n status: 'error',\n resourceType: /\\.json(?:$|[?#])/i.test(remoteInfo.entry)\n ? 'manifest'\n : 'remoteEntry',\n initiator: 'preloadRemote',\n id: preloadId,\n error,\n },\n ],\n });\n }\n }),\n );\n\n const failedResults = preloadResults.flatMap((preloadResult) =>\n preloadResult.results.filter(\n (result) => result.status === 'error' || result.status === 'timeout',\n ),\n );\n if (failedResults.length > 0) {\n preloadError = new Error(\n `preloadRemote failed to load ${failedResults.length} resource(s).`,\n );\n Object.assign(preloadError, {\n results: preloadResults,\n failedResults,\n });\n }\n\n await this.hooks.lifecycle.afterPreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n results: preloadResults,\n error: preloadError,\n });\n\n if (preloadError) {\n throw preloadError;\n }\n }\n\n registerRemotes(remotes: Remote[], options?: { force?: boolean }): void {\n const { host } = this;\n remotes.forEach((remote) => {\n this.registerRemote(remote, host.options.remotes, {\n force: options?.force,\n });\n });\n }\n\n async getRemoteModuleAndOptions(options: { id: string }): Promise<{\n module: Module;\n moduleOptions: ModuleOptions;\n remoteMatchInfo: LoadRemoteMatch;\n }> {\n const { host } = this;\n const { id } = options;\n let loadRemoteArgs;\n\n try {\n loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({\n id,\n options: host.options,\n origin: host,\n });\n } catch (error) {\n loadRemoteArgs = (await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n options: host.options,\n origin: host,\n from: 'runtime',\n error,\n lifecycle: 'beforeRequest',\n })) as {\n id: string;\n options: Options;\n origin: ModuleFederation;\n };\n\n if (!loadRemoteArgs) {\n throw error;\n }\n }\n\n const { id: idRes } = loadRemoteArgs;\n\n const remoteSplitInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n idRes,\n );\n if (!remoteSplitInfo) {\n try {\n error(\n RUNTIME_004,\n runtimeDescMap,\n {\n hostName: host.options.name,\n requestId: idRes,\n },\n undefined,\n optionsToMFContext(host.options),\n );\n } catch (matchError) {\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n options: host.options,\n error: matchError,\n origin: host,\n });\n throw matchError;\n }\n }\n\n const { remote: rawRemote } = remoteSplitInfo;\n const remoteInfo = getRemoteInfo(rawRemote);\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n remoteInfo,\n origin: host,\n });\n const matchInfo =\n await host.sharedHandler.hooks.lifecycle.afterResolve.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n origin: host,\n remoteInfo,\n });\n\n const { remote, expose } = matchInfo;\n assert(\n remote && expose,\n `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`,\n );\n let module: Module | undefined = host.moduleCache.get(remote.name);\n\n const moduleOptions: ModuleOptions = {\n host: host,\n remoteInfo,\n };\n\n if (!module) {\n module = new Module(moduleOptions);\n host.moduleCache.set(remote.name, module);\n }\n return {\n module,\n moduleOptions,\n remoteMatchInfo: matchInfo,\n };\n }\n\n registerRemote(\n remote: Remote,\n targetRemotes: Remote[],\n options?: { force?: boolean },\n ): void {\n const { host } = this;\n const normalizeRemote = () => {\n if (remote.alias) {\n // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error\n // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported\n const findEqual = targetRemotes.find(\n (item) =>\n remote.alias &&\n (item.name.startsWith(remote.alias) ||\n item.alias?.startsWith(remote.alias)),\n );\n assert(\n !findEqual,\n `The alias ${remote.alias} of remote ${\n remote.name\n } is not allowed to be the prefix of ${\n findEqual && findEqual.name\n } name or alias`,\n );\n }\n // Set the remote entry to a complete path\n if ('entry' in remote) {\n if (\n isBrowserEnvValue &&\n typeof window !== 'undefined' &&\n !remote.entry.startsWith('http')\n ) {\n remote.entry = new URL(remote.entry, window.location.origin).href;\n }\n }\n if (!remote.shareScope) {\n remote.shareScope = DEFAULT_SCOPE;\n }\n if (!remote.type) {\n remote.type = DEFAULT_REMOTE_TYPE;\n }\n };\n this.hooks.lifecycle.beforeRegisterRemote.emit({ remote, origin: host });\n const registeredRemote = targetRemotes.find(\n (item) => item.name === remote.name,\n );\n if (!registeredRemote) {\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n } else {\n const messages = [\n `The remote \"${remote.name}\" is already registered.`,\n 'Please note that overriding it may cause unexpected errors.',\n ];\n if (options?.force) {\n // remove registered remote\n this.removeRemote(registeredRemote);\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n warn(messages.join(' '));\n }\n }\n }\n\n private removeRemote(remote: Remote): void {\n try {\n const { host } = this;\n const { name } = remote;\n const remoteIndex = host.options.remotes.findIndex(\n (item) => item.name === name,\n );\n if (remoteIndex !== -1) {\n host.options.remotes.splice(remoteIndex, 1);\n }\n const loadedModule = host.moduleCache.get(remote.name);\n if (loadedModule) {\n const remoteInfo = loadedModule.remoteInfo;\n const key = remoteInfo.entryGlobalName as keyof typeof CurrentGlobal;\n\n if (CurrentGlobal[key]) {\n if (\n Object.getOwnPropertyDescriptor(CurrentGlobal, key)?.configurable\n ) {\n delete CurrentGlobal[key];\n } else {\n // @ts-ignore\n CurrentGlobal[key] = undefined;\n }\n }\n const remoteEntryUniqueKey = getRemoteEntryUniqueKey(\n loadedModule.remoteInfo,\n );\n\n if (globalLoading[remoteEntryUniqueKey]) {\n delete globalLoading[remoteEntryUniqueKey];\n }\n\n host.snapshotHandler.manifestCache.delete(remoteInfo.entry);\n\n // delete unloaded shared and instance\n let remoteInsId = remoteInfo.buildVersion\n ? composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion)\n : remoteInfo.name;\n const remoteInsIndex =\n CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {\n if (remoteInfo.buildVersion) {\n return ins.options.id === remoteInsId;\n } else {\n return ins.name === remoteInsId;\n }\n });\n if (remoteInsIndex !== -1) {\n const remoteIns =\n CurrentGlobal.__FEDERATION__.__INSTANCES__[remoteInsIndex];\n remoteInsId = remoteIns.options.id || remoteInsId;\n const globalShareScopeMap = getGlobalShareScope();\n\n let isAllSharedNotUsed = true;\n const needDeleteKeys: Array<[string, string, string, string]> = [];\n Object.keys(globalShareScopeMap).forEach((instId) => {\n const shareScopeMap = globalShareScopeMap[instId];\n shareScopeMap &&\n Object.keys(shareScopeMap).forEach((shareScope) => {\n const shareScopeVal = shareScopeMap[shareScope];\n shareScopeVal &&\n Object.keys(shareScopeVal).forEach((shareName) => {\n const sharedPkgs = shareScopeVal[shareName];\n sharedPkgs &&\n Object.keys(sharedPkgs).forEach((shareVersion) => {\n const shared = sharedPkgs[shareVersion];\n if (\n shared &&\n typeof shared === 'object' &&\n shared.from === remoteInfo.name\n ) {\n if (shared.loaded || shared.loading) {\n shared.useIn = shared.useIn.filter(\n (usedHostName) =>\n usedHostName !== remoteInfo.name,\n );\n if (shared.useIn.length) {\n isAllSharedNotUsed = false;\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n }\n });\n });\n });\n });\n\n if (isAllSharedNotUsed) {\n remoteIns.shareScopeMap = {};\n delete globalShareScopeMap[remoteInsId];\n }\n needDeleteKeys.forEach(\n ([insId, shareScope, shareName, shareVersion]) => {\n delete globalShareScopeMap[insId]?.[shareScope]?.[shareName]?.[\n shareVersion\n ];\n },\n );\n CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);\n }\n\n const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);\n if (hostGlobalSnapshot) {\n const remoteKey =\n hostGlobalSnapshot &&\n 'remotesInfo' in hostGlobalSnapshot &&\n hostGlobalSnapshot.remotesInfo &&\n getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;\n if (remoteKey) {\n delete hostGlobalSnapshot.remotesInfo[remoteKey];\n if (\n //eslint-disable-next-line no-extra-boolean-cast\n Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])\n ) {\n delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];\n }\n }\n }\n\n host.moduleCache.delete(remote.name);\n }\n } catch (err) {\n logger.error(\n `removeRemote failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,gBAAb,MAA2B;CAgJzB,YAAY,MAAwB;eA5I5B,IAAI,aAAa;GACvB,sBAAsB,IAAI,kBAGvB,uBAAuB;GAC1B,gBAAgB,IAAI,kBAGjB,iBAAiB;GACpB,eAAe,IAAI,mBAIhB,gBAAgB;GACnB,kBAAkB,IAAI,UAapB,mBAAmB;GACrB,QAAQ,IAAI,UAeV,SAAS;GACX,iBAAiB,IAAI,UAgBnB,kBAAkB;GACpB,qBAAqB,IAAI,SAYvB,sBAAsB;GACxB,iBAAiB,IAAI,UAkBnB,kBAAkB;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,OAAO,eAAe,qBAAqB;;;AAKxD,SAAK,YAAY,OAAO,OAAO,KAAK;;WAE/B,KAAK;AACZ,UAAO,MACL,wBAAwB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,GACzE"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Module"],"sources":["../../src/remote/index.ts"],"sourcesContent":["import {\n isBrowserEnvValue,\n warn,\n composeKeyWithSeparator,\n ModuleInfo,\n GlobalModuleInfo,\n} from '@module-federation/sdk';\nimport { RUNTIME_004, runtimeDescMap } from '@module-federation/error-codes';\nimport {\n Global,\n getInfoWithoutType,\n globalLoading,\n CurrentGlobal,\n} from '../global';\nimport {\n Options,\n UserOptions,\n PreloadAssets,\n PreloadOptions,\n PreloadRemoteArgs,\n PreloadRemoteResult,\n Remote,\n RemoteInfo,\n RemoteEntryExports,\n CallFrom,\n} from '../type';\nimport { ModuleFederation } from '../core';\nimport {\n PluginSystem,\n AsyncHook,\n AsyncWaterfallHook,\n SyncHook,\n SyncWaterfallHook,\n} from '../utils/hooks';\nimport {\n assert,\n error,\n getRemoteInfo,\n getRemoteEntryUniqueKey,\n getFMId,\n composeRemoteRequestId,\n matchRemoteWithNameAndExpose,\n optionsToMFContext,\n logger,\n} from '../utils';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { Module, ModuleOptions } from '../module';\nimport { formatPreloadArgs, preloadAssets } from '../utils/preload';\nimport { getGlobalShareScope } from '../utils/share';\nimport { getGlobalRemoteInfo } from '../plugins/snapshot/SnapshotHandler';\n\nexport interface LoadRemoteMatch {\n id: string;\n pkgNameOrAlias: string;\n expose: string;\n remote: Remote;\n options: Options;\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n}\n\nexport class RemoteHandler {\n host: ModuleFederation;\n idToRemoteMap: Record<string, { name: string; expose: string }>;\n\n hooks = new PluginSystem({\n beforeRegisterRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('beforeRegisterRemote'),\n registerRemote: new SyncWaterfallHook<{\n remote: Remote;\n origin: ModuleFederation;\n }>('registerRemote'),\n beforeRequest: new AsyncWaterfallHook<{\n id: string;\n options: Options;\n origin: ModuleFederation;\n }>('beforeRequest'),\n afterMatchRemote: new AsyncHook<\n [\n {\n id: string;\n options: Options;\n remote?: Remote;\n expose?: string;\n remoteInfo?: RemoteInfo;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterMatchRemote'),\n onLoad: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n pkgNameOrAlias: string;\n remote: Remote;\n options: ModuleOptions;\n origin: ModuleFederation;\n exposeModule: any;\n exposeModuleFactory: any;\n moduleInstance: Module;\n },\n ],\n unknown\n >('onLoad'),\n afterLoadRemote: new AsyncHook<\n [\n {\n id: string;\n expose?: string;\n remote?: RemoteInfo;\n options?: {\n loadFactory?: boolean;\n from?: CallFrom;\n };\n error?: unknown;\n recovered?: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterLoadRemote'),\n handlePreloadModule: new SyncHook<\n [\n {\n id: string;\n name: string;\n remote: Remote;\n remoteSnapshot: ModuleInfo;\n preloadConfig: PreloadRemoteArgs;\n origin: ModuleFederation;\n },\n ],\n void\n >('handlePreloadModule'),\n errorLoadRemote: new AsyncHook<\n [\n {\n id: string;\n error: unknown;\n options?: any;\n from: CallFrom;\n lifecycle:\n | 'beforeRequest'\n | 'beforeLoadShare'\n | 'afterResolve'\n | 'onLoad';\n remote?: RemoteInfo;\n expose?: string;\n origin: ModuleFederation;\n },\n ],\n void | unknown\n >('errorLoadRemote'),\n beforePreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n },\n ]\n >('beforePreloadRemote'),\n generatePreloadAssets: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n preloadOptions: PreloadOptions[number];\n remote: Remote;\n remoteInfo: RemoteInfo;\n remoteSnapshot: ModuleInfo;\n globalSnapshot: GlobalModuleInfo;\n },\n ],\n Promise<PreloadAssets>\n >('generatePreloadAssets'),\n afterPreloadRemote: new AsyncHook<\n [\n {\n preloadOps: Array<PreloadRemoteArgs>;\n options: Options;\n origin: ModuleFederation;\n results: PreloadRemoteResult[];\n error?: unknown;\n },\n ]\n >('afterPreloadRemote'),\n // TODO: Move to loaderHook\n loadEntry: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n loaderHook: ModuleFederation['loaderHook'];\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n },\n ],\n Promise<RemoteEntryExports | void> | RemoteEntryExports | void\n >(),\n });\n\n constructor(host: ModuleFederation) {\n this.host = host;\n this.idToRemoteMap = {};\n }\n\n formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions) {\n const userRemotes = userOptions.remotes || [];\n\n return userRemotes.reduce((res, remote) => {\n this.registerRemote(remote, res, { force: false });\n return res;\n }, globalOptions.remotes);\n }\n\n setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch) {\n const { remote, expose } = remoteMatchInfo;\n const { name, alias } = remote;\n this.idToRemoteMap[id] = { name: remote.name, expose };\n if (alias && id.startsWith(name)) {\n const idWithAlias = id.replace(name, alias);\n this.idToRemoteMap[idWithAlias] = { name: remote.name, expose };\n return;\n }\n\n if (alias && id.startsWith(alias)) {\n const idWithName = id.replace(alias, name);\n this.idToRemoteMap[idWithName] = { name: remote.name, expose };\n }\n }\n\n // eslint-disable-next-line max-lines-per-function\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async loadRemote<T>(\n id: string,\n options?: { loadFactory?: boolean; from: CallFrom },\n ): Promise<T | null> {\n const { host } = this;\n const startMatchInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n id,\n );\n let completeRequestId = id;\n let completeExpose = startMatchInfo?.expose;\n let completeRemote = startMatchInfo\n ? getRemoteInfo(startMatchInfo.remote)\n : undefined;\n let afterLoadRemoteArgs:\n | Parameters<\n RemoteHandler['hooks']['lifecycle']['afterLoadRemote']['emit']\n >[0]\n | undefined;\n\n try {\n const { loadFactory = true } = options || {\n loadFactory: true,\n };\n // 1. Validate the parameters of the retrieved module. There are two module request methods: pkgName + expose and alias + expose.\n // 2. Request the snapshot information of the current host and globally store the obtained snapshot information. The retrieved module information is partially offline and partially online. The online module information will retrieve the modules used online.\n // 3. Retrieve the detailed information of the current module from global (remoteEntry address, expose resource address)\n // 4. After retrieving remoteEntry, call the init of the module, and then retrieve the exported content of the module through get\n // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button\n // id: alias(app1) + expose(button) = app1/button\n // id: alias(app1/utils) + expose(loadash/sort) = app1/utils/loadash/sort\n const { module, moduleOptions, remoteMatchInfo } =\n await this.getRemoteModuleAndOptions({\n id,\n });\n const {\n pkgNameOrAlias,\n remote,\n expose,\n id: idRes,\n remoteSnapshot,\n } = remoteMatchInfo;\n completeRequestId = idRes;\n completeExpose = expose;\n completeRemote = getRemoteInfo(remote);\n\n const moduleOrFactory = (await module.get(\n idRes,\n expose,\n options,\n remoteSnapshot,\n )) as T;\n\n const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({\n id: idRes,\n pkgNameOrAlias,\n expose,\n exposeModule: loadFactory ? moduleOrFactory : undefined,\n exposeModuleFactory: loadFactory ? undefined : moduleOrFactory,\n remote,\n options: moduleOptions,\n moduleInstance: module,\n origin: host,\n });\n\n this.setIdToRemoteMap(id, remoteMatchInfo);\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n origin: host,\n };\n\n if (typeof moduleWrapper === 'function') {\n return moduleWrapper as T;\n }\n\n return moduleOrFactory;\n } catch (error) {\n const { from = 'runtime' } = options || { from: 'runtime' };\n\n let failOver;\n try {\n failOver = await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n error,\n from,\n lifecycle: 'onLoad',\n expose: completeExpose,\n remote: completeRemote,\n origin: host,\n });\n } catch (hookError) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error: hookError,\n origin: host,\n };\n throw hookError;\n }\n\n if (!failOver) {\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n };\n throw error;\n }\n\n afterLoadRemoteArgs = {\n id: completeRequestId,\n expose: completeExpose,\n remote: completeRemote,\n options,\n error,\n origin: host,\n recovered: true,\n };\n\n return failOver as T;\n } finally {\n if (afterLoadRemoteArgs) {\n await this.hooks.lifecycle.afterLoadRemote.emit(afterLoadRemoteArgs);\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void> {\n const { host } = this;\n const preloadResults: PreloadRemoteResult[] = [];\n\n await this.hooks.lifecycle.beforePreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n });\n\n const preloadOps: PreloadOptions = formatPreloadArgs(\n host.options.remotes,\n preloadOptions,\n );\n\n const createPreloadAssetOps = (ops: PreloadOptions[number]) => {\n const { preloadConfig, remote } = ops;\n const exposes = preloadConfig.exposes || [];\n\n if (!exposes.length) {\n return [\n {\n ops,\n id: `${remote.name}/*`,\n },\n ];\n }\n\n return exposes.map((expose) => ({\n ops: {\n ...ops,\n preloadConfig: {\n ...preloadConfig,\n exposes: [expose],\n },\n },\n id: composeRemoteRequestId(remote.name, expose),\n }));\n };\n\n let preloadError: Error | undefined;\n\n await Promise.all(\n preloadOps.flatMap(createPreloadAssetOps).map(async (assetOps) => {\n const { ops, id: preloadId } = assetOps;\n const { remote, preloadConfig } = ops;\n const remoteInfo = getRemoteInfo(remote);\n try {\n const { globalSnapshot, remoteSnapshot } =\n await host.snapshotHandler.loadRemoteSnapshotInfo({\n moduleInfo: remote,\n id: preloadId,\n initiator: 'preloadRemote',\n });\n\n const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({\n origin: host,\n preloadOptions: ops,\n remote,\n remoteInfo,\n globalSnapshot,\n remoteSnapshot,\n });\n if (!assets) {\n return;\n }\n const results = await preloadAssets(remoteInfo, host, assets, true, {\n initiator: 'preloadRemote',\n id: preloadId,\n });\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results,\n });\n } catch (error) {\n preloadResults.push({\n remote,\n remoteInfo,\n preloadConfig,\n id: preloadId,\n results: [\n {\n url: remoteInfo.entry,\n status: 'error',\n resourceType: /\\.json(?:$|[?#])/i.test(remoteInfo.entry)\n ? 'manifest'\n : 'remoteEntry',\n initiator: 'preloadRemote',\n id: preloadId,\n error,\n },\n ],\n });\n }\n }),\n );\n\n const failedResults = preloadResults.flatMap((preloadResult) =>\n preloadResult.results.filter(\n (result) => result.status === 'error' || result.status === 'timeout',\n ),\n );\n if (failedResults.length > 0) {\n preloadError = new Error(\n `preloadRemote failed to load ${failedResults.length} resource(s).`,\n );\n Object.assign(preloadError, {\n results: preloadResults,\n failedResults,\n });\n }\n\n await this.hooks.lifecycle.afterPreloadRemote.emit({\n preloadOps: preloadOptions,\n options: host.options,\n origin: host,\n results: preloadResults,\n error: preloadError,\n });\n\n if (preloadError) {\n throw preloadError;\n }\n }\n\n registerRemotes(remotes: Remote[], options?: { force?: boolean }): void {\n const { host } = this;\n remotes.forEach((remote) => {\n this.registerRemote(remote, host.options.remotes, {\n force: options?.force,\n });\n });\n }\n\n async getRemoteModuleAndOptions(options: { id: string }): Promise<{\n module: Module;\n moduleOptions: ModuleOptions;\n remoteMatchInfo: LoadRemoteMatch;\n }> {\n const { host } = this;\n const { id } = options;\n let loadRemoteArgs;\n\n try {\n loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({\n id,\n options: host.options,\n origin: host,\n });\n } catch (error) {\n loadRemoteArgs = (await this.hooks.lifecycle.errorLoadRemote.emit({\n id,\n options: host.options,\n origin: host,\n from: 'runtime',\n error,\n lifecycle: 'beforeRequest',\n })) as {\n id: string;\n options: Options;\n origin: ModuleFederation;\n };\n\n if (!loadRemoteArgs) {\n throw error;\n }\n }\n\n const { id: idRes } = loadRemoteArgs;\n\n const remoteSplitInfo = matchRemoteWithNameAndExpose(\n host.options.remotes,\n idRes,\n );\n if (!remoteSplitInfo) {\n try {\n error(\n RUNTIME_004,\n runtimeDescMap,\n {\n hostName: host.options.name,\n requestId: idRes,\n },\n undefined,\n optionsToMFContext(host.options),\n );\n } catch (matchError) {\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n options: host.options,\n error: matchError,\n origin: host,\n });\n throw matchError;\n }\n }\n\n const { remote: rawRemote } = remoteSplitInfo;\n const remoteInfo = getRemoteInfo(rawRemote);\n await this.hooks.lifecycle.afterMatchRemote.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n remoteInfo,\n origin: host,\n });\n const matchInfo =\n await host.sharedHandler.hooks.lifecycle.afterResolve.emit({\n id: idRes,\n ...remoteSplitInfo,\n options: host.options,\n origin: host,\n remoteInfo,\n });\n\n const { remote, expose } = matchInfo;\n assert(\n remote && expose,\n `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`,\n );\n let module: Module | undefined = host.moduleCache.get(remote.name);\n\n const moduleOptions: ModuleOptions = {\n host: host,\n remoteInfo,\n };\n\n if (!module) {\n module = new Module(moduleOptions);\n host.moduleCache.set(remote.name, module);\n }\n return {\n module,\n moduleOptions,\n remoteMatchInfo: matchInfo,\n };\n }\n\n registerRemote(\n remote: Remote,\n targetRemotes: Remote[],\n options?: { force?: boolean },\n ): void {\n const { host } = this;\n const normalizeRemote = () => {\n if (remote.alias) {\n // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error\n // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported\n const findEqual = targetRemotes.find(\n (item) =>\n remote.alias &&\n (item.name.startsWith(remote.alias) ||\n item.alias?.startsWith(remote.alias)),\n );\n assert(\n !findEqual,\n `The alias ${remote.alias} of remote ${\n remote.name\n } is not allowed to be the prefix of ${\n findEqual && findEqual.name\n } name or alias`,\n );\n }\n // Set the remote entry to a complete path\n if ('entry' in remote) {\n if (\n isBrowserEnvValue &&\n typeof window !== 'undefined' &&\n !remote.entry.startsWith('http')\n ) {\n remote.entry = new URL(remote.entry, window.location.origin).href;\n }\n }\n if (!remote.shareScope) {\n remote.shareScope = DEFAULT_SCOPE;\n }\n if (!remote.type) {\n remote.type = DEFAULT_REMOTE_TYPE;\n }\n };\n this.hooks.lifecycle.beforeRegisterRemote.emit({ remote, origin: host });\n const registeredRemote = targetRemotes.find(\n (item) => item.name === remote.name,\n );\n if (!registeredRemote) {\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n } else {\n const messages = [\n `The remote \"${remote.name}\" is already registered.`,\n 'Please note that overriding it may cause unexpected errors.',\n ];\n if (options?.force) {\n // remove registered remote\n this.removeRemote(registeredRemote);\n normalizeRemote();\n targetRemotes.push(remote);\n this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });\n warn(messages.join(' '));\n }\n }\n }\n\n private removeRemote(remote: Remote): void {\n try {\n const { host } = this;\n const { name } = remote;\n const remoteIndex = host.options.remotes.findIndex(\n (item) => item.name === name,\n );\n if (remoteIndex !== -1) {\n host.options.remotes.splice(remoteIndex, 1);\n }\n const globalSnapshotKey = getInfoWithoutType(\n CurrentGlobal.__FEDERATION__.moduleInfo,\n getFMId(remote),\n ).key;\n delete CurrentGlobal.__FEDERATION__.moduleInfo[globalSnapshotKey];\n\n if ('entry' in remote) {\n host.snapshotHandler.manifestCache.delete(remote.entry);\n delete Global.__FEDERATION__.__MANIFEST_LOADING__[remote.entry];\n }\n\n const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);\n if (hostGlobalSnapshot) {\n const remoteKey =\n hostGlobalSnapshot &&\n 'remotesInfo' in hostGlobalSnapshot &&\n hostGlobalSnapshot.remotesInfo &&\n getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;\n if (remoteKey) {\n delete hostGlobalSnapshot.remotesInfo[remoteKey];\n }\n }\n\n const loadedModule = host.moduleCache.get(remote.name);\n if (loadedModule) {\n const remoteInfo = loadedModule.remoteInfo;\n const key = remoteInfo.entryGlobalName as keyof typeof CurrentGlobal;\n\n if (CurrentGlobal[key]) {\n if (\n Object.getOwnPropertyDescriptor(CurrentGlobal, key)?.configurable\n ) {\n delete CurrentGlobal[key];\n } else {\n // @ts-ignore\n CurrentGlobal[key] = undefined;\n }\n }\n const remoteEntryUniqueKey = getRemoteEntryUniqueKey(\n loadedModule.remoteInfo,\n );\n\n if (globalLoading[remoteEntryUniqueKey]) {\n delete globalLoading[remoteEntryUniqueKey];\n }\n\n // delete unloaded shared and instance\n let remoteInsId = remoteInfo.buildVersion\n ? composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion)\n : remoteInfo.name;\n const remoteInsIndex =\n CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {\n if (remoteInfo.buildVersion) {\n return ins.options.id === remoteInsId;\n } else {\n return ins.name === remoteInsId;\n }\n });\n if (remoteInsIndex !== -1) {\n const remoteIns =\n CurrentGlobal.__FEDERATION__.__INSTANCES__[remoteInsIndex];\n remoteInsId = remoteIns.options.id || remoteInsId;\n const globalShareScopeMap = getGlobalShareScope();\n\n let isAllSharedNotUsed = true;\n const needDeleteKeys: Array<[string, string, string, string]> = [];\n Object.keys(globalShareScopeMap).forEach((instId) => {\n const shareScopeMap = globalShareScopeMap[instId];\n shareScopeMap &&\n Object.keys(shareScopeMap).forEach((shareScope) => {\n const shareScopeVal = shareScopeMap[shareScope];\n shareScopeVal &&\n Object.keys(shareScopeVal).forEach((shareName) => {\n const sharedPkgs = shareScopeVal[shareName];\n sharedPkgs &&\n Object.keys(sharedPkgs).forEach((shareVersion) => {\n const shared = sharedPkgs[shareVersion];\n if (\n shared &&\n typeof shared === 'object' &&\n shared.from === remoteInfo.name\n ) {\n if (shared.loaded || shared.loading) {\n shared.useIn = shared.useIn.filter(\n (usedHostName) =>\n usedHostName !== remoteInfo.name,\n );\n if (shared.useIn.length) {\n isAllSharedNotUsed = false;\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n } else {\n needDeleteKeys.push([\n instId,\n shareScope,\n shareName,\n shareVersion,\n ]);\n }\n }\n });\n });\n });\n });\n\n if (isAllSharedNotUsed) {\n remoteIns.shareScopeMap = {};\n delete globalShareScopeMap[remoteInsId];\n }\n needDeleteKeys.forEach(\n ([insId, shareScope, shareName, shareVersion]) => {\n delete globalShareScopeMap[insId]?.[shareScope]?.[shareName]?.[\n shareVersion\n ];\n },\n );\n CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);\n }\n\n host.moduleCache.delete(remote.name);\n }\n } catch (err) {\n logger.error(\n `removeRemote failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAa,gBAAb,MAA2B;CAgJzB,YAAY,MAAwB;eA5I5B,IAAI,aAAa;GACvB,sBAAsB,IAAI,kBAGvB,uBAAuB;GAC1B,gBAAgB,IAAI,kBAGjB,iBAAiB;GACpB,eAAe,IAAI,mBAIhB,gBAAgB;GACnB,kBAAkB,IAAI,UAapB,mBAAmB;GACrB,QAAQ,IAAI,UAeV,SAAS;GACX,iBAAiB,IAAI,UAgBnB,kBAAkB;GACpB,qBAAqB,IAAI,SAYvB,sBAAsB;GACxB,iBAAiB,IAAI,UAkBnB,kBAAkB;GACpB,qBAAqB,IAAI,UAQvB,sBAAsB;GACxB,uBAAuB,IAAI,UAYzB,wBAAwB;GAC1B,oBAAoB,IAAI,UAUtB,qBAAqB;GAEvB,WAAW,IAAI,WAUZ;GACJ,CAAC;AAGA,OAAK,OAAO;AACZ,OAAK,gBAAgB,EAAE;;CAGzB,wBAAwB,eAAwB,aAA0B;AAGxE,UAFoB,YAAY,WAAW,E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1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@module-federation/sdk": "2.
|
|
56
|
-
"@module-federation/error-codes": "2.
|
|
55
|
+
"@module-federation/sdk": "2.6.0",
|
|
56
|
+
"@module-federation/error-codes": "2.6.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsdown --config tsdown.config.ts",
|