const require_attachShareScopeMap = require('./attachShareScopeMap.cjs'); const require_updateOptions = require('./updateOptions.cjs'); const require_getUsedExports = require('./getUsedExports.cjs'); const require_error_codes = require('./error-codes/dist/error-codes.cjs'); const require_getShortErrorMsg = require('./error-codes/dist/getShortErrorMsg.cjs'); //#region src/consumes.ts function consumes(options) { require_updateOptions.updateConsumeOptions(options); const { chunkId, promises, installedModules, webpackRequire, chunkMapping, moduleToHandlerMapping } = options; require_attachShareScopeMap.attachShareScopeMap(webpackRequire); if (webpackRequire.o(chunkMapping, chunkId)) chunkMapping[chunkId].forEach((id) => { if (webpackRequire.o(installedModules, id)) return promises.push(installedModules[id]); const onFactory = (factory) => { installedModules[id] = 0; webpackRequire.m[id] = (module) => { delete webpackRequire.c[id]; const result = factory(); const { shareInfo } = moduleToHandlerMapping[id]; if (shareInfo?.shareConfig?.layer && result && typeof result === "object") try { if (!result.hasOwnProperty("layer") || result.layer === void 0) result.layer = shareInfo.shareConfig.layer; } catch (e) {} module.exports = result; }; }; const onError = (error) => { delete installedModules[id]; webpackRequire.m[id] = (module) => { delete webpackRequire.c[id]; throw error; }; }; try { const federationInstance = webpackRequire.federation.instance; if (!federationInstance) throw new Error("Federation instance not found!"); const { shareKey, getter, shareInfo, treeShakingGetter } = moduleToHandlerMapping[id]; const usedExports = require_getUsedExports.getUsedExports(webpackRequire, shareKey); const customShareInfo = { ...shareInfo }; if (Array.isArray(customShareInfo.scope) && Array.isArray(customShareInfo.scope[0])) customShareInfo.scope = customShareInfo.scope[0]; if (usedExports) customShareInfo.treeShaking = { usedExports, useIn: [federationInstance.options.name] }; const promise = federationInstance.loadShare(shareKey, { customShareInfo }).then((factory) => { if (factory === false) { if (typeof getter !== "function") throw new Error(require_getShortErrorMsg.getShortErrorMsg(require_error_codes.RUNTIME_012, { [require_error_codes.RUNTIME_012]: "The getter for the shared module is not a function. This may be caused by setting \"shared.import: false\" without the host providing the corresponding lib." }, { shareKey })); return treeShakingGetter?.() || getter(); } return factory; }); if (promise.then) promises.push(installedModules[id] = promise.then(onFactory).catch(onError)); else onFactory(promise); } catch (e) { onError(e); } }); } //#endregion exports.consumes = consumes; //# sourceMappingURL=consumes.cjs.map