Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023-present zhanghang(2heal1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,21 @@
# `@module-federation/webpack-bundler-runtime`
- Extract the build runtime and combine it with the internal runtime
- Used with webpack/rspack
## Usage
The package needs to be used with webpack/rspack bundler. It will export federation object which includes runtime, instance, bundlerRuntime, initOptions, attachShareScopeMap, bundlerRuntimeOptions.
After referencing, mount it to the corresponding bundler runtime, and then use the corresponding api/instance.
- example
```ts
import federation from '@module-federation/webpack-bundler-runtime';
__webpack_require__.federation = federation;
__webpack_require__.f.remotes = __webpack_require__.federation.remotes(options);
__webpack_require__.f.consumes = __webpack_require__.federation.remotes(options);
```

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023-present zhanghang(2heal1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,29 @@
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) {
__defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
}
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
exports.__toESM = __toESM;

View File

@@ -0,0 +1,11 @@
//#region src/attachShareScopeMap.ts
function attachShareScopeMap(webpackRequire) {
if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) return;
webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
webpackRequire.federation.hasAttachShareScopeMap = true;
}
//#endregion
exports.attachShareScopeMap = attachShareScopeMap;
//# sourceMappingURL=attachShareScopeMap.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"attachShareScopeMap.cjs","names":[],"sources":["../src/attachShareScopeMap.ts"],"sourcesContent":["import { WebpackRequire } from './types';\n\nexport function attachShareScopeMap(webpackRequire: WebpackRequire) {\n if (\n !webpackRequire.S ||\n webpackRequire.federation.hasAttachShareScopeMap ||\n !webpackRequire.federation.instance ||\n !webpackRequire.federation.instance.shareScopeMap\n ) {\n return;\n }\n\n webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;\n\n webpackRequire.federation.hasAttachShareScopeMap = true;\n}\n"],"mappings":";;AAEA,SAAgB,oBAAoB,gBAAgC;AAClE,KACE,CAAC,eAAe,KAChB,eAAe,WAAW,0BAC1B,CAAC,eAAe,WAAW,YAC3B,CAAC,eAAe,WAAW,SAAS,cAEpC;AAGF,gBAAe,IAAI,eAAe,WAAW,SAAS;AAEtD,gBAAe,WAAW,yBAAyB"}

View File

@@ -0,0 +1,7 @@
import { WebpackRequire } from "./types.js";
//#region src/attachShareScopeMap.d.ts
declare function attachShareScopeMap(webpackRequire: WebpackRequire): void;
//#endregion
export { attachShareScopeMap };
//# sourceMappingURL=attachShareScopeMap.d.ts.map

View File

@@ -0,0 +1,10 @@
//#region src/attachShareScopeMap.ts
function attachShareScopeMap(webpackRequire) {
if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) return;
webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
webpackRequire.federation.hasAttachShareScopeMap = true;
}
//#endregion
export { attachShareScopeMap };
//# sourceMappingURL=attachShareScopeMap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"attachShareScopeMap.js","names":[],"sources":["../src/attachShareScopeMap.ts"],"sourcesContent":["import { WebpackRequire } from './types';\n\nexport function attachShareScopeMap(webpackRequire: WebpackRequire) {\n if (\n !webpackRequire.S ||\n webpackRequire.federation.hasAttachShareScopeMap ||\n !webpackRequire.federation.instance ||\n !webpackRequire.federation.instance.shareScopeMap\n ) {\n return;\n }\n\n webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;\n\n webpackRequire.federation.hasAttachShareScopeMap = true;\n}\n"],"mappings":";AAEA,SAAgB,oBAAoB,gBAAgC;AAClE,KACE,CAAC,eAAe,KAChB,eAAe,WAAW,0BAC1B,CAAC,eAAe,WAAW,YAC3B,CAAC,eAAe,WAAW,SAAS,cAEpC;AAGF,gBAAe,IAAI,eAAe,WAAW,SAAS;AAEtD,gBAAe,WAAW,yBAAyB"}

View File

@@ -0,0 +1,18 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
const require_attachShareScopeMap = require('./attachShareScopeMap.cjs');
const require_index = require('./index.cjs');
let _module_federation_runtime = require("@module-federation/runtime");
exports.attachShareScopeMap = require_attachShareScopeMap.attachShareScopeMap;
exports.bundlerRuntime = require_index.bundlerRuntime;
exports.bundlerRuntimeOptions = require_index.bundlerRuntimeOptions;
exports.default = require_index.default;
exports.initOptions = require_index.initOptions;
exports.instance = require_index.instance;
Object.defineProperty(exports, 'runtime', {
enumerable: true,
get: function () {
return _module_federation_runtime;
}
});

View File

@@ -0,0 +1,4 @@
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { ConsumesLoadingData, ConsumesOptions, CoreRemotesOptions, Federation, GetSharedFallbackGetterOptions, HandleInitialConsumesOptions, IdToExternalAndNameMapping, IdToRemoteMap, IdToRemoteMapItem, InitContainerEntryOptions, InitializeSharingData, InitializeSharingOptions, InstallInitialConsumesOptions, ModuleId, ModuleIdToRemoteDataMapping, RemoteChunkMapping, RemoteDataItem, RemoteEntryExports, RemoteInfos, RemotesLoadingData, RemotesOptions, ShareScopeMap, WebpackRequire } from "./types.js";
import federation, { bundlerRuntime, bundlerRuntimeOptions, initOptions, instance, runtime } from "./index.js";
export { ConsumesLoadingData, ConsumesOptions, CoreRemotesOptions, Federation, GetSharedFallbackGetterOptions, HandleInitialConsumesOptions, IdToExternalAndNameMapping, IdToRemoteMap, IdToRemoteMapItem, InitContainerEntryOptions, InitializeSharingData, InitializeSharingOptions, InstallInitialConsumesOptions, ModuleId, ModuleIdToRemoteDataMapping, RemoteChunkMapping, RemoteDataItem, RemoteEntryExports, RemoteInfos, RemotesLoadingData, RemotesOptions, ShareScopeMap, WebpackRequire, attachShareScopeMap, bundlerRuntime, bundlerRuntimeOptions, federation as default, initOptions, instance, runtime };

View File

@@ -0,0 +1,4 @@
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import federation, { bundlerRuntime, bundlerRuntimeOptions, initOptions, instance, runtime } from "./index.js";
export { attachShareScopeMap, bundlerRuntime, bundlerRuntimeOptions, federation as default, initOptions, instance, runtime };

View File

@@ -0,0 +1,8 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
//#region src/constant.ts
const FEDERATION_SUPPORTED_TYPES = ["script"];
//#endregion
exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
//# sourceMappingURL=constant.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constant.cjs","names":[],"sources":["../src/constant.ts"],"sourcesContent":["export const FEDERATION_SUPPORTED_TYPES = ['script'];\n"],"mappings":";;;AAAA,MAAa,6BAA6B,CAAC,SAAS"}

View File

@@ -0,0 +1,5 @@
//#region src/constant.d.ts
declare const FEDERATION_SUPPORTED_TYPES: string[];
//#endregion
export { FEDERATION_SUPPORTED_TYPES };
//# sourceMappingURL=constant.d.ts.map

View File

@@ -0,0 +1,6 @@
//#region src/constant.ts
const FEDERATION_SUPPORTED_TYPES = ["script"];
//#endregion
export { FEDERATION_SUPPORTED_TYPES };
//# sourceMappingURL=constant.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constant.js","names":[],"sources":["../src/constant.ts"],"sourcesContent":["export const FEDERATION_SUPPORTED_TYPES = ['script'];\n"],"mappings":";AAAA,MAAa,6BAA6B,CAAC,SAAS"}

View File

@@ -0,0 +1,61 @@
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,61 @@
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { updateConsumeOptions } from "./updateOptions.js";
import { getUsedExports } from "./getUsedExports.js";
import { RUNTIME_012 } from "./error-codes/dist/error-codes.js";
import { getShortErrorMsg } from "./error-codes/dist/getShortErrorMsg.js";
//#region src/consumes.ts
function consumes(options) {
updateConsumeOptions(options);
const { chunkId, promises, installedModules, webpackRequire, chunkMapping, moduleToHandlerMapping } = options;
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 = 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(getShortErrorMsg(RUNTIME_012, { [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
export { consumes };
//# sourceMappingURL=consumes.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
//#region ../error-codes/dist/error-codes.mjs
const RUNTIME_012 = "RUNTIME-012";
//#endregion
exports.RUNTIME_012 = RUNTIME_012;
//# sourceMappingURL=error-codes.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"error-codes.cjs","names":[],"sources":["../../../../error-codes/dist/error-codes.mjs"],"sourcesContent":["//#region src/error-codes.ts\nconst RUNTIME_001 = \"RUNTIME-001\";\nconst RUNTIME_002 = \"RUNTIME-002\";\nconst RUNTIME_003 = \"RUNTIME-003\";\nconst RUNTIME_004 = \"RUNTIME-004\";\nconst RUNTIME_005 = \"RUNTIME-005\";\nconst RUNTIME_006 = \"RUNTIME-006\";\nconst RUNTIME_007 = \"RUNTIME-007\";\nconst RUNTIME_008 = \"RUNTIME-008\";\nconst RUNTIME_009 = \"RUNTIME-009\";\nconst RUNTIME_010 = \"RUNTIME-010\";\nconst RUNTIME_011 = \"RUNTIME-011\";\nconst RUNTIME_012 = \"RUNTIME-012\";\nconst RUNTIME_013 = \"RUNTIME-013\";\nconst RUNTIME_014 = \"RUNTIME-014\";\nconst RUNTIME_015 = \"RUNTIME-015\";\nconst TYPE_001 = \"TYPE-001\";\nconst BUILD_001 = \"BUILD-001\";\nconst BUILD_002 = \"BUILD-002\";\n\n//#endregion\nexport { BUILD_001, BUILD_002, RUNTIME_001, RUNTIME_002, RUNTIME_003, RUNTIME_004, RUNTIME_005, RUNTIME_006, RUNTIME_007, RUNTIME_008, RUNTIME_009, RUNTIME_010, RUNTIME_011, RUNTIME_012, RUNTIME_013, RUNTIME_014, RUNTIME_015, TYPE_001 };\n//# sourceMappingURL=error-codes.mjs.map"],"mappings":";;AAYA,MAAM,cAAc"}

View File

@@ -0,0 +1,6 @@
//#region ../error-codes/dist/error-codes.mjs
const RUNTIME_012 = "RUNTIME-012";
//#endregion
export { RUNTIME_012 };
//# sourceMappingURL=error-codes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"error-codes.js","names":[],"sources":["../../../../error-codes/dist/error-codes.mjs"],"sourcesContent":["//#region src/error-codes.ts\nconst RUNTIME_001 = \"RUNTIME-001\";\nconst RUNTIME_002 = \"RUNTIME-002\";\nconst RUNTIME_003 = \"RUNTIME-003\";\nconst RUNTIME_004 = \"RUNTIME-004\";\nconst RUNTIME_005 = \"RUNTIME-005\";\nconst RUNTIME_006 = \"RUNTIME-006\";\nconst RUNTIME_007 = \"RUNTIME-007\";\nconst RUNTIME_008 = \"RUNTIME-008\";\nconst RUNTIME_009 = \"RUNTIME-009\";\nconst RUNTIME_010 = \"RUNTIME-010\";\nconst RUNTIME_011 = \"RUNTIME-011\";\nconst RUNTIME_012 = \"RUNTIME-012\";\nconst RUNTIME_013 = \"RUNTIME-013\";\nconst RUNTIME_014 = \"RUNTIME-014\";\nconst RUNTIME_015 = \"RUNTIME-015\";\nconst TYPE_001 = \"TYPE-001\";\nconst BUILD_001 = \"BUILD-001\";\nconst BUILD_002 = \"BUILD-002\";\n\n//#endregion\nexport { BUILD_001, BUILD_002, RUNTIME_001, RUNTIME_002, RUNTIME_003, RUNTIME_004, RUNTIME_005, RUNTIME_006, RUNTIME_007, RUNTIME_008, RUNTIME_009, RUNTIME_010, RUNTIME_011, RUNTIME_012, RUNTIME_013, RUNTIME_014, RUNTIME_015, TYPE_001 };\n//# sourceMappingURL=error-codes.mjs.map"],"mappings":";AAYA,MAAM,cAAc"}

View File

@@ -0,0 +1,16 @@
//#region ../error-codes/dist/getShortErrorMsg.mjs
const getDocsUrl = (errorCode) => {
return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split("-")[0].toLowerCase()}#${errorCode.toLowerCase()}`;
};
const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
args && msg.push(`args: ${JSON.stringify(args)}`);
msg.push(getDocsUrl(errorCode));
originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);
return msg.join("\n");
};
//#endregion
exports.getShortErrorMsg = getShortErrorMsg;
//# sourceMappingURL=getShortErrorMsg.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getShortErrorMsg.cjs","names":[],"sources":["../../../../error-codes/dist/getShortErrorMsg.mjs"],"sourcesContent":["//#region src/getShortErrorMsg.ts\nconst getDocsUrl = (errorCode) => {\n\treturn `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split(\"-\")[0].toLowerCase()}#${errorCode.toLowerCase()}`;\n};\nconst getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {\n\tconst msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];\n\targs && msg.push(`args: ${JSON.stringify(args)}`);\n\tmsg.push(getDocsUrl(errorCode));\n\toriginalErrorMsg && msg.push(`Original Error Message:\\n ${originalErrorMsg}`);\n\treturn msg.join(\"\\n\");\n};\n\n//#endregion\nexport { getShortErrorMsg };\n//# sourceMappingURL=getShortErrorMsg.mjs.map"],"mappings":";;AACA,MAAM,cAAc,cAAc;AACjC,QAAO,yFAAyF,UAAU,MAAM,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,UAAU,aAAa;;AAEjK,MAAM,oBAAoB,WAAW,cAAc,MAAM,qBAAqB;CAC7E,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,WAAW,CAAC,IAAI,YAAY;AAC1D,SAAQ,IAAI,KAAK,SAAS,KAAK,UAAU,KAAK,GAAG;AACjD,KAAI,KAAK,WAAW,UAAU,CAAC;AAC/B,qBAAoB,IAAI,KAAK,6BAA6B,mBAAmB;AAC7E,QAAO,IAAI,KAAK,KAAK"}

View File

@@ -0,0 +1,15 @@
//#region ../error-codes/dist/getShortErrorMsg.mjs
const getDocsUrl = (errorCode) => {
return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split("-")[0].toLowerCase()}#${errorCode.toLowerCase()}`;
};
const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
args && msg.push(`args: ${JSON.stringify(args)}`);
msg.push(getDocsUrl(errorCode));
originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);
return msg.join("\n");
};
//#endregion
export { getShortErrorMsg };
//# sourceMappingURL=getShortErrorMsg.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getShortErrorMsg.js","names":[],"sources":["../../../../error-codes/dist/getShortErrorMsg.mjs"],"sourcesContent":["//#region src/getShortErrorMsg.ts\nconst getDocsUrl = (errorCode) => {\n\treturn `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split(\"-\")[0].toLowerCase()}#${errorCode.toLowerCase()}`;\n};\nconst getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {\n\tconst msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];\n\targs && msg.push(`args: ${JSON.stringify(args)}`);\n\tmsg.push(getDocsUrl(errorCode));\n\toriginalErrorMsg && msg.push(`Original Error Message:\\n ${originalErrorMsg}`);\n\treturn msg.join(\"\\n\");\n};\n\n//#endregion\nexport { getShortErrorMsg };\n//# sourceMappingURL=getShortErrorMsg.mjs.map"],"mappings":";AACA,MAAM,cAAc,cAAc;AACjC,QAAO,yFAAyF,UAAU,MAAM,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,UAAU,aAAa;;AAEjK,MAAM,oBAAoB,WAAW,cAAc,MAAM,qBAAqB;CAC7E,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,WAAW,CAAC,IAAI,YAAY;AAC1D,SAAQ,IAAI,KAAK,SAAS,KAAK,UAAU,KAAK,GAAG;AACjD,KAAI,KAAK,WAAW,UAAU,CAAC;AAC/B,qBAAoB,IAAI,KAAK,6BAA6B,mBAAmB;AAC7E,QAAO,IAAI,KAAK,KAAK"}

View File

@@ -0,0 +1,27 @@
//#region src/getSharedFallbackGetter.ts
const getSharedFallbackGetter = ({ shareKey, factory, version, webpackRequire, libraryType = "global" }) => {
const { runtime, instance, bundlerRuntime, sharedFallback } = webpackRequire.federation;
if (!sharedFallback) return factory;
const fallbackItems = sharedFallback[shareKey];
if (!fallbackItems) return factory;
const fallbackItem = version ? fallbackItems.find((item) => item[1] === version) : fallbackItems[0];
if (!fallbackItem) throw new Error(`No fallback item found for shareKey: ${shareKey} and version: ${version}`);
return () => runtime.getRemoteEntry({
origin: webpackRequire.federation.instance,
remoteInfo: {
name: fallbackItem[2],
entry: `${webpackRequire.p}${fallbackItem[0]}`,
type: libraryType,
entryGlobalName: fallbackItem[2],
shareScope: "default"
}
}).then((shareEntry) => {
if (!shareEntry) throw new Error(`Failed to load fallback entry for shareKey: ${shareKey} and version: ${version}`);
return shareEntry.init(webpackRequire.federation.instance, bundlerRuntime).then(() => shareEntry.get());
});
};
//#endregion
exports.getSharedFallbackGetter = getSharedFallbackGetter;
//# sourceMappingURL=getSharedFallbackGetter.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getSharedFallbackGetter.cjs","names":[],"sources":["../src/getSharedFallbackGetter.ts"],"sourcesContent":["import type { GetSharedFallbackGetterOptions } from './types';\n\nexport const getSharedFallbackGetter = ({\n shareKey,\n factory,\n version,\n webpackRequire,\n libraryType = 'global',\n}: GetSharedFallbackGetterOptions) => {\n const { runtime, instance, bundlerRuntime, sharedFallback } =\n webpackRequire.federation!;\n if (!sharedFallback) {\n return factory;\n }\n // { react: [ [ react/19.0.0/index.js , 19.0.0, react_global_name, var ] ] }\n const fallbackItems = sharedFallback[shareKey];\n if (!fallbackItems) {\n return factory;\n }\n const fallbackItem = version\n ? fallbackItems.find((item) => item[1] === version)\n : fallbackItems[0];\n if (!fallbackItem) {\n throw new Error(\n `No fallback item found for shareKey: ${shareKey} and version: ${version}`,\n );\n }\n return () =>\n runtime!\n .getRemoteEntry({\n origin: webpackRequire.federation.instance!,\n remoteInfo: {\n name: fallbackItem[2],\n entry: `${webpackRequire.p}${fallbackItem[0]}`,\n type: libraryType,\n entryGlobalName: fallbackItem[2],\n // current not used\n shareScope: 'default',\n },\n })\n // @ts-ignore\n .then((shareEntry) => {\n if (!shareEntry) {\n throw new Error(\n `Failed to load fallback entry for shareKey: ${shareKey} and version: ${version}`,\n );\n }\n return (\n shareEntry\n // @ts-ignore\n .init(webpackRequire.federation.instance!, bundlerRuntime)\n // @ts-ignore\n .then(() => shareEntry.get())\n );\n });\n};\n"],"mappings":";;AAEA,MAAa,2BAA2B,EACtC,UACA,SACA,SACA,gBACA,cAAc,eACsB;CACpC,MAAM,EAAE,SAAS,UAAU,gBAAgB,mBACzC,eAAe;AACjB,KAAI,CAAC,eACH,QAAO;CAGT,MAAM,gBAAgB,eAAe;AACrC,KAAI,CAAC,cACH,QAAO;CAET,MAAM,eAAe,UACjB,cAAc,MAAM,SAAS,KAAK,OAAO,QAAQ,GACjD,cAAc;AAClB,KAAI,CAAC,aACH,OAAM,IAAI,MACR,wCAAwC,SAAS,gBAAgB,UAClE;AAEH,cACE,QACG,eAAe;EACd,QAAQ,eAAe,WAAW;EAClC,YAAY;GACV,MAAM,aAAa;GACnB,OAAO,GAAG,eAAe,IAAI,aAAa;GAC1C,MAAM;GACN,iBAAiB,aAAa;GAE9B,YAAY;GACb;EACF,CAAC,CAED,MAAM,eAAe;AACpB,MAAI,CAAC,WACH,OAAM,IAAI,MACR,+CAA+C,SAAS,gBAAgB,UACzE;AAEH,SACE,WAEG,KAAK,eAAe,WAAW,UAAW,eAAe,CAEzD,WAAW,WAAW,KAAK,CAAC;GAEjC"}

View File

@@ -0,0 +1,26 @@
//#region src/getSharedFallbackGetter.ts
const getSharedFallbackGetter = ({ shareKey, factory, version, webpackRequire, libraryType = "global" }) => {
const { runtime, instance, bundlerRuntime, sharedFallback } = webpackRequire.federation;
if (!sharedFallback) return factory;
const fallbackItems = sharedFallback[shareKey];
if (!fallbackItems) return factory;
const fallbackItem = version ? fallbackItems.find((item) => item[1] === version) : fallbackItems[0];
if (!fallbackItem) throw new Error(`No fallback item found for shareKey: ${shareKey} and version: ${version}`);
return () => runtime.getRemoteEntry({
origin: webpackRequire.federation.instance,
remoteInfo: {
name: fallbackItem[2],
entry: `${webpackRequire.p}${fallbackItem[0]}`,
type: libraryType,
entryGlobalName: fallbackItem[2],
shareScope: "default"
}
}).then((shareEntry) => {
if (!shareEntry) throw new Error(`Failed to load fallback entry for shareKey: ${shareKey} and version: ${version}`);
return shareEntry.init(webpackRequire.federation.instance, bundlerRuntime).then(() => shareEntry.get());
});
};
//#endregion
export { getSharedFallbackGetter };
//# sourceMappingURL=getSharedFallbackGetter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getSharedFallbackGetter.js","names":[],"sources":["../src/getSharedFallbackGetter.ts"],"sourcesContent":["import type { GetSharedFallbackGetterOptions } from './types';\n\nexport const getSharedFallbackGetter = ({\n shareKey,\n factory,\n version,\n webpackRequire,\n libraryType = 'global',\n}: GetSharedFallbackGetterOptions) => {\n const { runtime, instance, bundlerRuntime, sharedFallback } =\n webpackRequire.federation!;\n if (!sharedFallback) {\n return factory;\n }\n // { react: [ [ react/19.0.0/index.js , 19.0.0, react_global_name, var ] ] }\n const fallbackItems = sharedFallback[shareKey];\n if (!fallbackItems) {\n return factory;\n }\n const fallbackItem = version\n ? fallbackItems.find((item) => item[1] === version)\n : fallbackItems[0];\n if (!fallbackItem) {\n throw new Error(\n `No fallback item found for shareKey: ${shareKey} and version: ${version}`,\n );\n }\n return () =>\n runtime!\n .getRemoteEntry({\n origin: webpackRequire.federation.instance!,\n remoteInfo: {\n name: fallbackItem[2],\n entry: `${webpackRequire.p}${fallbackItem[0]}`,\n type: libraryType,\n entryGlobalName: fallbackItem[2],\n // current not used\n shareScope: 'default',\n },\n })\n // @ts-ignore\n .then((shareEntry) => {\n if (!shareEntry) {\n throw new Error(\n `Failed to load fallback entry for shareKey: ${shareKey} and version: ${version}`,\n );\n }\n return (\n shareEntry\n // @ts-ignore\n .init(webpackRequire.federation.instance!, bundlerRuntime)\n // @ts-ignore\n .then(() => shareEntry.get())\n );\n });\n};\n"],"mappings":";AAEA,MAAa,2BAA2B,EACtC,UACA,SACA,SACA,gBACA,cAAc,eACsB;CACpC,MAAM,EAAE,SAAS,UAAU,gBAAgB,mBACzC,eAAe;AACjB,KAAI,CAAC,eACH,QAAO;CAGT,MAAM,gBAAgB,eAAe;AACrC,KAAI,CAAC,cACH,QAAO;CAET,MAAM,eAAe,UACjB,cAAc,MAAM,SAAS,KAAK,OAAO,QAAQ,GACjD,cAAc;AAClB,KAAI,CAAC,aACH,OAAM,IAAI,MACR,wCAAwC,SAAS,gBAAgB,UAClE;AAEH,cACE,QACG,eAAe;EACd,QAAQ,eAAe,WAAW;EAClC,YAAY;GACV,MAAM,aAAa;GACnB,OAAO,GAAG,eAAe,IAAI,aAAa;GAC1C,MAAM;GACN,iBAAiB,aAAa;GAE9B,YAAY;GACb;EACF,CAAC,CAED,MAAM,eAAe;AACpB,MAAI,CAAC,WACH,OAAM,IAAI,MACR,+CAA+C,SAAS,gBAAgB,UACzE;AAEH,SACE,WAEG,KAAK,eAAe,WAAW,UAAW,eAAe,CAEzD,WAAW,WAAW,KAAK,CAAC;GAEjC"}

View File

@@ -0,0 +1,11 @@
//#region src/getUsedExports.ts
function getUsedExports(webpackRequire, sharedName) {
const usedExports = webpackRequire.federation.usedExports;
if (!usedExports) return;
return usedExports[sharedName];
}
//#endregion
exports.getUsedExports = getUsedExports;
//# sourceMappingURL=getUsedExports.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUsedExports.cjs","names":[],"sources":["../src/getUsedExports.ts"],"sourcesContent":["import type { WebpackRequire } from './types';\n\nexport function getUsedExports(\n webpackRequire: WebpackRequire,\n sharedName: string,\n) {\n const usedExports = webpackRequire.federation.usedExports;\n if (!usedExports) {\n return;\n }\n\n return usedExports[sharedName];\n}\n"],"mappings":";;AAEA,SAAgB,eACd,gBACA,YACA;CACA,MAAM,cAAc,eAAe,WAAW;AAC9C,KAAI,CAAC,YACH;AAGF,QAAO,YAAY"}

View File

@@ -0,0 +1,10 @@
//#region src/getUsedExports.ts
function getUsedExports(webpackRequire, sharedName) {
const usedExports = webpackRequire.federation.usedExports;
if (!usedExports) return;
return usedExports[sharedName];
}
//#endregion
export { getUsedExports };
//# sourceMappingURL=getUsedExports.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getUsedExports.js","names":[],"sources":["../src/getUsedExports.ts"],"sourcesContent":["import type { WebpackRequire } from './types';\n\nexport function getUsedExports(\n webpackRequire: WebpackRequire,\n sharedName: string,\n) {\n const usedExports = webpackRequire.federation.usedExports;\n if (!usedExports) {\n return;\n }\n\n return usedExports[sharedName];\n}\n"],"mappings":";AAEA,SAAgB,eACd,gBACA,YACA;CACA,MAAM,cAAc,eAAe,WAAW;AAC9C,KAAI,CAAC,YACH;AAGF,QAAO,YAAY"}

View File

@@ -0,0 +1,50 @@
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
const require_attachShareScopeMap = require('./attachShareScopeMap.cjs');
const require_remotes = require('./remotes.cjs');
const require_consumes = require('./consumes.cjs');
const require_initializeSharing = require('./initializeSharing.cjs');
const require_installInitialConsumes = require('./installInitialConsumes.cjs');
const require_initContainerEntry = require('./initContainerEntry.cjs');
const require_init = require('./init.cjs');
const require_getSharedFallbackGetter = require('./getSharedFallbackGetter.cjs');
let _module_federation_runtime = require("@module-federation/runtime");
_module_federation_runtime = require_runtime.__toESM(_module_federation_runtime);
//#region src/index.ts
const federation = {
runtime: _module_federation_runtime,
instance: void 0,
initOptions: void 0,
bundlerRuntime: {
remotes: require_remotes.remotes,
consumes: require_consumes.consumes,
I: require_initializeSharing.initializeSharing,
S: {},
installInitialConsumes: require_installInitialConsumes.installInitialConsumes,
initContainerEntry: require_initContainerEntry.initContainerEntry,
init: require_init.init,
getSharedFallbackGetter: require_getSharedFallbackGetter.getSharedFallbackGetter
},
attachShareScopeMap: require_attachShareScopeMap.attachShareScopeMap,
bundlerRuntimeOptions: {}
};
const instance = federation.instance;
const initOptions = federation.initOptions;
const bundlerRuntime = federation.bundlerRuntime;
const bundlerRuntimeOptions = federation.bundlerRuntimeOptions;
//#endregion
exports.attachShareScopeMap = require_attachShareScopeMap.attachShareScopeMap;
exports.bundlerRuntime = bundlerRuntime;
exports.bundlerRuntimeOptions = bundlerRuntimeOptions;
exports.default = federation;
exports.initOptions = initOptions;
exports.instance = instance;
Object.defineProperty(exports, 'runtime', {
enumerable: true,
get: function () {
return _module_federation_runtime;
}
});
//# sourceMappingURL=index.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.cjs","names":["initializeSharing"],"sources":["../src/index.ts"],"sourcesContent":["import * as runtime from '@module-federation/runtime';\nimport { Federation } from './types';\nimport { remotes } from './remotes';\nimport { consumes } from './consumes';\nimport { initializeSharing } from './initializeSharing';\nimport { installInitialConsumes } from './installInitialConsumes';\nimport { attachShareScopeMap } from './attachShareScopeMap';\nimport { initContainerEntry } from './initContainerEntry';\nimport { init } from './init';\nimport { getSharedFallbackGetter } from './getSharedFallbackGetter';\n\nexport * from './types';\n\nconst federation: Federation = {\n runtime,\n instance: undefined,\n initOptions: undefined,\n bundlerRuntime: {\n remotes,\n consumes,\n I: initializeSharing,\n S: {},\n installInitialConsumes,\n initContainerEntry,\n init,\n getSharedFallbackGetter,\n },\n attachShareScopeMap,\n bundlerRuntimeOptions: {},\n};\n\n// Keep CJS interop stable for consumers that iterate required keys directly.\nexport { runtime, attachShareScopeMap };\nexport const instance = federation.instance;\nexport const initOptions = federation.initOptions;\nexport const bundlerRuntime = federation.bundlerRuntime;\nexport const bundlerRuntimeOptions = federation.bundlerRuntimeOptions;\n\nexport default federation;\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,aAAyB;CAC7B;CACA,UAAU;CACV,aAAa;CACb,gBAAgB;EACd;EACA;EACA,GAAGA;EACH,GAAG,EAAE;EACL;EACA;EACA;EACA;EACD;CACD;CACA,uBAAuB,EAAE;CAC1B;AAID,MAAa,WAAW,WAAW;AACnC,MAAa,cAAc,WAAW;AACtC,MAAa,iBAAiB,WAAW;AACzC,MAAa,wBAAwB,WAAW"}

View File

@@ -0,0 +1,46 @@
import { Remote, Shared, SharedGetter, UserOptions } from "./runtime-core/dist/type/config.js";
import { ExternalsType } from "./sdk/dist/types/plugins/ModuleFederationPlugin.js";
import { initializeSharing } from "./initializeSharing.js";
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { initContainerEntry } from "./initContainerEntry.js";
import { ConsumesLoadingData, ConsumesOptions, CoreRemotesOptions, Federation, GetSharedFallbackGetterOptions, HandleInitialConsumesOptions, IdToExternalAndNameMapping, IdToRemoteMap, IdToRemoteMapItem, InitContainerEntryOptions, InitializeSharingData, InitializeSharingOptions, InstallInitialConsumesOptions, ModuleId, ModuleIdToRemoteDataMapping, RemoteChunkMapping, RemoteDataItem, RemoteEntryExports, RemoteInfos, RemotesLoadingData, RemotesOptions, ShareScopeMap, WebpackRequire } from "./types.js";
import * as runtime from "@module-federation/runtime";
//#region src/index.d.ts
declare const federation: Federation;
declare const instance: runtime.ModuleFederation | undefined;
declare const initOptions: (Omit<UserOptions, "remotes"> & {
remotes: Array<Remote & {
externalType: ExternalsType;
}>;
}) | undefined;
declare const bundlerRuntime: {
remotes: (options: RemotesOptions) => void;
consumes: (options: ConsumesOptions) => void;
I: typeof initializeSharing;
S: {
[scope: string]: {
[pkgName: string]: {
[sharedVersion: string]: Shared;
};
};
};
installInitialConsumes: (options: InstallInitialConsumesOptions) => any;
initContainerEntry: typeof initContainerEntry;
init: ({
webpackRequire,
libraryType
}: {
webpackRequire: WebpackRequire;
libraryType: string;
}) => void;
getSharedFallbackGetter: (options: GetSharedFallbackGetterOptions) => SharedGetter;
} | undefined;
declare const bundlerRuntimeOptions: {
remotes?: Exclude<RemotesOptions, "chunkId" | "promises"> & {
remoteInfos?: RemoteInfos;
};
};
//#endregion
export { ConsumesLoadingData, ConsumesOptions, CoreRemotesOptions, Federation, GetSharedFallbackGetterOptions, HandleInitialConsumesOptions, IdToExternalAndNameMapping, IdToRemoteMap, IdToRemoteMapItem, InitContainerEntryOptions, InitializeSharingData, InitializeSharingOptions, InstallInitialConsumesOptions, ModuleId, ModuleIdToRemoteDataMapping, RemoteChunkMapping, RemoteDataItem, RemoteEntryExports, RemoteInfos, RemotesLoadingData, RemotesOptions, ShareScopeMap, WebpackRequire, attachShareScopeMap, bundlerRuntime, bundlerRuntimeOptions, federation as default, initOptions, instance, runtime };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,36 @@
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { remotes } from "./remotes.js";
import { consumes } from "./consumes.js";
import { initializeSharing } from "./initializeSharing.js";
import { installInitialConsumes } from "./installInitialConsumes.js";
import { initContainerEntry } from "./initContainerEntry.js";
import { init } from "./init.js";
import { getSharedFallbackGetter } from "./getSharedFallbackGetter.js";
import * as runtime from "@module-federation/runtime";
//#region src/index.ts
const federation = {
runtime,
instance: void 0,
initOptions: void 0,
bundlerRuntime: {
remotes,
consumes,
I: initializeSharing,
S: {},
installInitialConsumes,
initContainerEntry,
init,
getSharedFallbackGetter
},
attachShareScopeMap,
bundlerRuntimeOptions: {}
};
const instance = federation.instance;
const initOptions = federation.initOptions;
const bundlerRuntime = federation.bundlerRuntime;
const bundlerRuntimeOptions = federation.bundlerRuntimeOptions;
//#endregion
export { attachShareScopeMap, bundlerRuntime, bundlerRuntimeOptions, federation as default, initOptions, instance, runtime };
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import * as runtime from '@module-federation/runtime';\nimport { Federation } from './types';\nimport { remotes } from './remotes';\nimport { consumes } from './consumes';\nimport { initializeSharing } from './initializeSharing';\nimport { installInitialConsumes } from './installInitialConsumes';\nimport { attachShareScopeMap } from './attachShareScopeMap';\nimport { initContainerEntry } from './initContainerEntry';\nimport { init } from './init';\nimport { getSharedFallbackGetter } from './getSharedFallbackGetter';\n\nexport * from './types';\n\nconst federation: Federation = {\n runtime,\n instance: undefined,\n initOptions: undefined,\n bundlerRuntime: {\n remotes,\n consumes,\n I: initializeSharing,\n S: {},\n installInitialConsumes,\n initContainerEntry,\n init,\n getSharedFallbackGetter,\n },\n attachShareScopeMap,\n bundlerRuntimeOptions: {},\n};\n\n// Keep CJS interop stable for consumers that iterate required keys directly.\nexport { runtime, attachShareScopeMap };\nexport const instance = federation.instance;\nexport const initOptions = federation.initOptions;\nexport const bundlerRuntime = federation.bundlerRuntime;\nexport const bundlerRuntimeOptions = federation.bundlerRuntimeOptions;\n\nexport default federation;\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,aAAyB;CAC7B;CACA,UAAU;CACV,aAAa;CACb,gBAAgB;EACd;EACA;EACA,GAAG;EACH,GAAG,EAAE;EACL;EACA;EACA;EACA;EACD;CACD;CACA,uBAAuB,EAAE;CAC1B;AAID,MAAa,WAAW,WAAW;AACnC,MAAa,cAAc,WAAW;AACtC,MAAa,iBAAiB,WAAW;AACzC,MAAa,wBAAwB,WAAW"}

View File

@@ -0,0 +1,82 @@
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
let _module_federation_runtime = require("@module-federation/runtime");
let _module_federation_runtime_helpers = require("@module-federation/runtime/helpers");
_module_federation_runtime_helpers = require_runtime.__toESM(_module_federation_runtime_helpers);
//#region src/init.ts
function init({ webpackRequire }) {
const { initOptions, runtime, sharedFallback, bundlerRuntime, libraryType } = webpackRequire.federation;
if (!initOptions) throw new Error("initOptions is required!");
const treeShakingSharePlugin = function() {
return {
name: "tree-shake-plugin",
beforeInit(args) {
const { userOptions, origin, options: registeredOptions } = args;
const version = userOptions.version || registeredOptions.version;
if (!sharedFallback) return args;
const currentShared = userOptions.shared || {};
const shared = [];
Object.keys(currentShared).forEach((sharedName) => {
(Array.isArray(currentShared[sharedName]) ? currentShared[sharedName] : [currentShared[sharedName]]).forEach((sharedArg) => {
shared.push([sharedName, sharedArg]);
if ("get" in sharedArg) {
sharedArg.treeShaking ||= {};
sharedArg.treeShaking.get = sharedArg.get;
sharedArg.get = bundlerRuntime.getSharedFallbackGetter({
shareKey: sharedName,
factory: sharedArg.get,
webpackRequire,
libraryType,
version: sharedArg.version
});
}
});
});
const hostGlobalSnapshot = _module_federation_runtime_helpers.default.global.getGlobalSnapshotInfoByModuleInfo({
name: origin.name,
version
});
if (!hostGlobalSnapshot || !("shared" in hostGlobalSnapshot)) return args;
Object.keys(registeredOptions.shared || {}).forEach((pkgName) => {
registeredOptions.shared[pkgName].forEach((sharedArg) => {
shared.push([pkgName, sharedArg]);
});
});
const patchShared = (pkgName, shared) => {
const shareSnapshot = hostGlobalSnapshot.shared.find((item) => item.sharedName === pkgName);
if (!shareSnapshot) return;
const { treeShaking } = shared;
if (!treeShaking) return;
const { secondarySharedTreeShakingName, secondarySharedTreeShakingEntry, treeShakingStatus } = shareSnapshot;
if (treeShaking.status === treeShakingStatus) return;
treeShaking.status = treeShakingStatus;
if (secondarySharedTreeShakingEntry && libraryType && secondarySharedTreeShakingName) treeShaking.get = async () => {
const shareEntry = await (0, _module_federation_runtime.getRemoteEntry)({
origin,
remoteInfo: {
name: secondarySharedTreeShakingName,
entry: secondarySharedTreeShakingEntry,
type: libraryType,
entryGlobalName: secondarySharedTreeShakingName,
shareScope: "default"
}
});
await shareEntry.init(origin, __webpack_require__.federation.bundlerRuntime);
return shareEntry.get();
};
};
shared.forEach(([pkgName, sharedArg]) => {
patchShared(pkgName, sharedArg);
});
return args;
}
};
};
initOptions.plugins ||= [];
initOptions.plugins.push(treeShakingSharePlugin());
return runtime.init(initOptions);
}
//#endregion
exports.init = init;
//# sourceMappingURL=init.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
import { getRemoteEntry } from "@module-federation/runtime";
import helpers from "@module-federation/runtime/helpers";
//#region src/init.ts
function init({ webpackRequire }) {
const { initOptions, runtime, sharedFallback, bundlerRuntime, libraryType } = webpackRequire.federation;
if (!initOptions) throw new Error("initOptions is required!");
const treeShakingSharePlugin = function() {
return {
name: "tree-shake-plugin",
beforeInit(args) {
const { userOptions, origin, options: registeredOptions } = args;
const version = userOptions.version || registeredOptions.version;
if (!sharedFallback) return args;
const currentShared = userOptions.shared || {};
const shared = [];
Object.keys(currentShared).forEach((sharedName) => {
(Array.isArray(currentShared[sharedName]) ? currentShared[sharedName] : [currentShared[sharedName]]).forEach((sharedArg) => {
shared.push([sharedName, sharedArg]);
if ("get" in sharedArg) {
sharedArg.treeShaking ||= {};
sharedArg.treeShaking.get = sharedArg.get;
sharedArg.get = bundlerRuntime.getSharedFallbackGetter({
shareKey: sharedName,
factory: sharedArg.get,
webpackRequire,
libraryType,
version: sharedArg.version
});
}
});
});
const hostGlobalSnapshot = helpers.global.getGlobalSnapshotInfoByModuleInfo({
name: origin.name,
version
});
if (!hostGlobalSnapshot || !("shared" in hostGlobalSnapshot)) return args;
Object.keys(registeredOptions.shared || {}).forEach((pkgName) => {
registeredOptions.shared[pkgName].forEach((sharedArg) => {
shared.push([pkgName, sharedArg]);
});
});
const patchShared = (pkgName, shared) => {
const shareSnapshot = hostGlobalSnapshot.shared.find((item) => item.sharedName === pkgName);
if (!shareSnapshot) return;
const { treeShaking } = shared;
if (!treeShaking) return;
const { secondarySharedTreeShakingName, secondarySharedTreeShakingEntry, treeShakingStatus } = shareSnapshot;
if (treeShaking.status === treeShakingStatus) return;
treeShaking.status = treeShakingStatus;
if (secondarySharedTreeShakingEntry && libraryType && secondarySharedTreeShakingName) treeShaking.get = async () => {
const shareEntry = await getRemoteEntry({
origin,
remoteInfo: {
name: secondarySharedTreeShakingName,
entry: secondarySharedTreeShakingEntry,
type: libraryType,
entryGlobalName: secondarySharedTreeShakingName,
shareScope: "default"
}
});
await shareEntry.init(origin, __webpack_require__.federation.bundlerRuntime);
return shareEntry.get();
};
};
shared.forEach(([pkgName, sharedArg]) => {
patchShared(pkgName, sharedArg);
});
return args;
}
};
};
initOptions.plugins ||= [];
initOptions.plugins.push(treeShakingSharePlugin());
return runtime.init(initOptions);
}
//#endregion
export { init };
//# sourceMappingURL=init.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,42 @@
//#region src/initContainerEntry.ts
function initContainerEntry(options) {
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options;
if (!webpackRequire.S) return;
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
const federationInstance = webpackRequire.federation.instance;
federationInstance.initOptions({
name: webpackRequire.federation.initOptions.name,
remotes: [],
...remoteEntryInitOptions
});
const hostShareScopeKeys = remoteEntryInitOptions?.shareScopeKeys;
const hostShareScopeMap = remoteEntryInitOptions?.shareScopeMap;
if (!shareScopeKey || typeof shareScopeKey === "string") {
const key = shareScopeKey || "default";
if (Array.isArray(hostShareScopeKeys)) hostShareScopeKeys.forEach((hostKey) => {
if (!hostShareScopeMap[hostKey]) hostShareScopeMap[hostKey] = {};
const sc = hostShareScopeMap[hostKey];
federationInstance.initShareScopeMap(hostKey, sc, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
});
else federationInstance.initShareScopeMap(key, shareScope, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
} else shareScopeKey.forEach((key) => {
if (!hostShareScopeKeys || !hostShareScopeMap) {
federationInstance.initShareScopeMap(key, shareScope, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
return;
}
if (!hostShareScopeMap[key]) hostShareScopeMap[key] = {};
const sc = hostShareScopeMap[key];
federationInstance.initShareScopeMap(key, sc, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
});
if (webpackRequire.federation.attachShareScopeMap) webpackRequire.federation.attachShareScopeMap(webpackRequire);
if (!Array.isArray(shareScopeKey)) return webpackRequire.I(shareScopeKey || "default", initScope);
if (Boolean(webpackRequire.federation.initOptions.shared)) return webpackRequire.I(shareScopeKey, initScope);
return Promise.all(shareScopeKey.map((key) => {
return webpackRequire.I(key, initScope);
})).then(() => true);
}
//#endregion
exports.initContainerEntry = initContainerEntry;
//# sourceMappingURL=initContainerEntry.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"initContainerEntry.cjs","names":[],"sources":["../src/initContainerEntry.ts"],"sourcesContent":["import { InitContainerEntryOptions, WebpackRequire } from './types';\n\nexport function initContainerEntry(\n options: InitContainerEntryOptions,\n): WebpackRequire['I'] | void {\n const {\n webpackRequire,\n shareScope,\n initScope,\n shareScopeKey,\n remoteEntryInitOptions,\n } = options;\n if (!webpackRequire.S) return;\n if (\n !webpackRequire.federation ||\n !webpackRequire.federation.instance ||\n !webpackRequire.federation.initOptions\n )\n return;\n\n const federationInstance = webpackRequire.federation.instance;\n\n federationInstance.initOptions({\n name: webpackRequire.federation.initOptions.name,\n remotes: [],\n ...remoteEntryInitOptions,\n });\n\n const hostShareScopeKeys = remoteEntryInitOptions?.shareScopeKeys;\n const hostShareScopeMap = remoteEntryInitOptions?.shareScopeMap;\n\n // host: 'default' remote: 'default' remote['default'] = hostShareScopeMap['default']\n // host: ['default', 'scope1'] remote: 'default' remote['default'] = hostShareScopeMap['default']; remote['scope1'] = hostShareScopeMap['scop1']\n // host: 'default' remote: ['default','scope1'] remote['default'] = hostShareScopeMap['default']; remote['scope1'] = hostShareScopeMap['scope1'] = {}\n // host: ['scope1','default'] remote: ['scope1','scope2'] => remote['scope1'] = hostShareScopeMap['scope1']; remote['scope2'] = hostShareScopeMap['scope2'] = {};\n if (!shareScopeKey || typeof shareScopeKey === 'string') {\n const key = shareScopeKey || 'default';\n if (Array.isArray(hostShareScopeKeys)) {\n // const sc = hostShareScopeMap![key];\n // if (!sc) {\n // throw new Error('shareScopeKey is not exist in hostShareScopeMap');\n // }\n // federationInstance.initShareScopeMap(key, sc, {\n // hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n // });\n\n hostShareScopeKeys.forEach((hostKey) => {\n if (!hostShareScopeMap![hostKey]) {\n hostShareScopeMap![hostKey] = {};\n }\n const sc = hostShareScopeMap![hostKey];\n federationInstance.initShareScopeMap(hostKey, sc, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n });\n } else {\n federationInstance.initShareScopeMap(key, shareScope, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n }\n } else {\n shareScopeKey.forEach((key) => {\n if (!hostShareScopeKeys || !hostShareScopeMap) {\n federationInstance.initShareScopeMap(key, shareScope, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n return;\n }\n\n if (!hostShareScopeMap[key]) {\n hostShareScopeMap[key] = {};\n }\n const sc = hostShareScopeMap[key];\n federationInstance.initShareScopeMap(key, sc, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n });\n }\n\n if (webpackRequire.federation.attachShareScopeMap) {\n webpackRequire.federation.attachShareScopeMap(webpackRequire);\n }\n\n if (!Array.isArray(shareScopeKey)) {\n // @ts-ignore\n return webpackRequire.I(shareScopeKey || 'default', initScope);\n }\n\n var proxyInitializeSharing = Boolean(\n webpackRequire.federation.initOptions.shared,\n );\n\n if (proxyInitializeSharing) {\n // @ts-ignore\n return webpackRequire.I(shareScopeKey, initScope);\n }\n // @ts-ignore\n return Promise.all(\n shareScopeKey.map((key) => {\n // @ts-ignore\n return webpackRequire.I(key, initScope);\n }),\n ).then(() => true);\n}\n"],"mappings":";;AAEA,SAAgB,mBACd,SAC4B;CAC5B,MAAM,EACJ,gBACA,YACA,WACA,eACA,2BACE;AACJ,KAAI,CAAC,eAAe,EAAG;AACvB,KACE,CAAC,eAAe,cAChB,CAAC,eAAe,WAAW,YAC3B,CAAC,eAAe,WAAW,YAE3B;CAEF,MAAM,qBAAqB,eAAe,WAAW;AAErD,oBAAmB,YAAY;EAC7B,MAAM,eAAe,WAAW,YAAY;EAC5C,SAAS,EAAE;EACX,GAAG;EACJ,CAAC;CAEF,MAAM,qBAAqB,wBAAwB;CACnD,MAAM,oBAAoB,wBAAwB;AAMlD,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;EACvD,MAAM,MAAM,iBAAiB;AAC7B,MAAI,MAAM,QAAQ,mBAAmB,CASnC,oBAAmB,SAAS,YAAY;AACtC,OAAI,CAAC,kBAAmB,SACtB,mBAAmB,WAAW,EAAE;GAElC,MAAM,KAAK,kBAAmB;AAC9B,sBAAmB,kBAAkB,SAAS,IAAI,EAChD,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;IACF;MAEF,oBAAmB,kBAAkB,KAAK,YAAY,EACpD,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;OAGJ,eAAc,SAAS,QAAQ;AAC7B,MAAI,CAAC,sBAAsB,CAAC,mBAAmB;AAC7C,sBAAmB,kBAAkB,KAAK,YAAY,EACpD,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;AACF;;AAGF,MAAI,CAAC,kBAAkB,KACrB,mBAAkB,OAAO,EAAE;EAE7B,MAAM,KAAK,kBAAkB;AAC7B,qBAAmB,kBAAkB,KAAK,IAAI,EAC5C,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;GACF;AAGJ,KAAI,eAAe,WAAW,oBAC5B,gBAAe,WAAW,oBAAoB,eAAe;AAG/D,KAAI,CAAC,MAAM,QAAQ,cAAc,CAE/B,QAAO,eAAe,EAAE,iBAAiB,WAAW,UAAU;AAOhE,KAJ6B,QAC3B,eAAe,WAAW,YAAY,OACvC,CAIC,QAAO,eAAe,EAAE,eAAe,UAAU;AAGnD,QAAO,QAAQ,IACb,cAAc,KAAK,QAAQ;AAEzB,SAAO,eAAe,EAAE,KAAK,UAAU;GACvC,CACH,CAAC,WAAW,KAAK"}

View File

@@ -0,0 +1,7 @@
import { InitContainerEntryOptions, WebpackRequire } from "./types.js";
//#region src/initContainerEntry.d.ts
declare function initContainerEntry(options: InitContainerEntryOptions): WebpackRequire['I'] | void;
//#endregion
export { initContainerEntry };
//# sourceMappingURL=initContainerEntry.d.ts.map

View File

@@ -0,0 +1,41 @@
//#region src/initContainerEntry.ts
function initContainerEntry(options) {
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options;
if (!webpackRequire.S) return;
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
const federationInstance = webpackRequire.federation.instance;
federationInstance.initOptions({
name: webpackRequire.federation.initOptions.name,
remotes: [],
...remoteEntryInitOptions
});
const hostShareScopeKeys = remoteEntryInitOptions?.shareScopeKeys;
const hostShareScopeMap = remoteEntryInitOptions?.shareScopeMap;
if (!shareScopeKey || typeof shareScopeKey === "string") {
const key = shareScopeKey || "default";
if (Array.isArray(hostShareScopeKeys)) hostShareScopeKeys.forEach((hostKey) => {
if (!hostShareScopeMap[hostKey]) hostShareScopeMap[hostKey] = {};
const sc = hostShareScopeMap[hostKey];
federationInstance.initShareScopeMap(hostKey, sc, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
});
else federationInstance.initShareScopeMap(key, shareScope, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
} else shareScopeKey.forEach((key) => {
if (!hostShareScopeKeys || !hostShareScopeMap) {
federationInstance.initShareScopeMap(key, shareScope, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
return;
}
if (!hostShareScopeMap[key]) hostShareScopeMap[key] = {};
const sc = hostShareScopeMap[key];
federationInstance.initShareScopeMap(key, sc, { hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {} });
});
if (webpackRequire.federation.attachShareScopeMap) webpackRequire.federation.attachShareScopeMap(webpackRequire);
if (!Array.isArray(shareScopeKey)) return webpackRequire.I(shareScopeKey || "default", initScope);
if (Boolean(webpackRequire.federation.initOptions.shared)) return webpackRequire.I(shareScopeKey, initScope);
return Promise.all(shareScopeKey.map((key) => {
return webpackRequire.I(key, initScope);
})).then(() => true);
}
//#endregion
export { initContainerEntry };
//# sourceMappingURL=initContainerEntry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"initContainerEntry.js","names":[],"sources":["../src/initContainerEntry.ts"],"sourcesContent":["import { InitContainerEntryOptions, WebpackRequire } from './types';\n\nexport function initContainerEntry(\n options: InitContainerEntryOptions,\n): WebpackRequire['I'] | void {\n const {\n webpackRequire,\n shareScope,\n initScope,\n shareScopeKey,\n remoteEntryInitOptions,\n } = options;\n if (!webpackRequire.S) return;\n if (\n !webpackRequire.federation ||\n !webpackRequire.federation.instance ||\n !webpackRequire.federation.initOptions\n )\n return;\n\n const federationInstance = webpackRequire.federation.instance;\n\n federationInstance.initOptions({\n name: webpackRequire.federation.initOptions.name,\n remotes: [],\n ...remoteEntryInitOptions,\n });\n\n const hostShareScopeKeys = remoteEntryInitOptions?.shareScopeKeys;\n const hostShareScopeMap = remoteEntryInitOptions?.shareScopeMap;\n\n // host: 'default' remote: 'default' remote['default'] = hostShareScopeMap['default']\n // host: ['default', 'scope1'] remote: 'default' remote['default'] = hostShareScopeMap['default']; remote['scope1'] = hostShareScopeMap['scop1']\n // host: 'default' remote: ['default','scope1'] remote['default'] = hostShareScopeMap['default']; remote['scope1'] = hostShareScopeMap['scope1'] = {}\n // host: ['scope1','default'] remote: ['scope1','scope2'] => remote['scope1'] = hostShareScopeMap['scope1']; remote['scope2'] = hostShareScopeMap['scope2'] = {};\n if (!shareScopeKey || typeof shareScopeKey === 'string') {\n const key = shareScopeKey || 'default';\n if (Array.isArray(hostShareScopeKeys)) {\n // const sc = hostShareScopeMap![key];\n // if (!sc) {\n // throw new Error('shareScopeKey is not exist in hostShareScopeMap');\n // }\n // federationInstance.initShareScopeMap(key, sc, {\n // hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n // });\n\n hostShareScopeKeys.forEach((hostKey) => {\n if (!hostShareScopeMap![hostKey]) {\n hostShareScopeMap![hostKey] = {};\n }\n const sc = hostShareScopeMap![hostKey];\n federationInstance.initShareScopeMap(hostKey, sc, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n });\n } else {\n federationInstance.initShareScopeMap(key, shareScope, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n }\n } else {\n shareScopeKey.forEach((key) => {\n if (!hostShareScopeKeys || !hostShareScopeMap) {\n federationInstance.initShareScopeMap(key, shareScope, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n return;\n }\n\n if (!hostShareScopeMap[key]) {\n hostShareScopeMap[key] = {};\n }\n const sc = hostShareScopeMap[key];\n federationInstance.initShareScopeMap(key, sc, {\n hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},\n });\n });\n }\n\n if (webpackRequire.federation.attachShareScopeMap) {\n webpackRequire.federation.attachShareScopeMap(webpackRequire);\n }\n\n if (!Array.isArray(shareScopeKey)) {\n // @ts-ignore\n return webpackRequire.I(shareScopeKey || 'default', initScope);\n }\n\n var proxyInitializeSharing = Boolean(\n webpackRequire.federation.initOptions.shared,\n );\n\n if (proxyInitializeSharing) {\n // @ts-ignore\n return webpackRequire.I(shareScopeKey, initScope);\n }\n // @ts-ignore\n return Promise.all(\n shareScopeKey.map((key) => {\n // @ts-ignore\n return webpackRequire.I(key, initScope);\n }),\n ).then(() => true);\n}\n"],"mappings":";AAEA,SAAgB,mBACd,SAC4B;CAC5B,MAAM,EACJ,gBACA,YACA,WACA,eACA,2BACE;AACJ,KAAI,CAAC,eAAe,EAAG;AACvB,KACE,CAAC,eAAe,cAChB,CAAC,eAAe,WAAW,YAC3B,CAAC,eAAe,WAAW,YAE3B;CAEF,MAAM,qBAAqB,eAAe,WAAW;AAErD,oBAAmB,YAAY;EAC7B,MAAM,eAAe,WAAW,YAAY;EAC5C,SAAS,EAAE;EACX,GAAG;EACJ,CAAC;CAEF,MAAM,qBAAqB,wBAAwB;CACnD,MAAM,oBAAoB,wBAAwB;AAMlD,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;EACvD,MAAM,MAAM,iBAAiB;AAC7B,MAAI,MAAM,QAAQ,mBAAmB,CASnC,oBAAmB,SAAS,YAAY;AACtC,OAAI,CAAC,kBAAmB,SACtB,mBAAmB,WAAW,EAAE;GAElC,MAAM,KAAK,kBAAmB;AAC9B,sBAAmB,kBAAkB,SAAS,IAAI,EAChD,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;IACF;MAEF,oBAAmB,kBAAkB,KAAK,YAAY,EACpD,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;OAGJ,eAAc,SAAS,QAAQ;AAC7B,MAAI,CAAC,sBAAsB,CAAC,mBAAmB;AAC7C,sBAAmB,kBAAkB,KAAK,YAAY,EACpD,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;AACF;;AAGF,MAAI,CAAC,kBAAkB,KACrB,mBAAkB,OAAO,EAAE;EAE7B,MAAM,KAAK,kBAAkB;AAC7B,qBAAmB,kBAAkB,KAAK,IAAI,EAC5C,mBAAmB,wBAAwB,iBAAiB,EAAE,EAC/D,CAAC;GACF;AAGJ,KAAI,eAAe,WAAW,oBAC5B,gBAAe,WAAW,oBAAoB,eAAe;AAG/D,KAAI,CAAC,MAAM,QAAQ,cAAc,CAE/B,QAAO,eAAe,EAAE,iBAAiB,WAAW,UAAU;AAOhE,KAJ6B,QAC3B,eAAe,WAAW,YAAY,OACvC,CAIC,QAAO,eAAe,EAAE,eAAe,UAAU;AAGnD,QAAO,QAAQ,IACb,cAAc,KAAK,QAAQ;AAEzB,SAAO,eAAe,EAAE,KAAK,UAAU;GACvC,CACH,CAAC,WAAW,KAAK"}

View File

@@ -0,0 +1,61 @@
const require_attachShareScopeMap = require('./attachShareScopeMap.cjs');
const require_constant = require('./constant.cjs');
//#region src/initializeSharing.ts
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) {
const shareScopeKeys = Array.isArray(shareScopeName) ? shareScopeName : [shareScopeName];
var initializeSharingPromises = [];
var _initializeSharing = function(shareScopeKey) {
if (!initScope) initScope = [];
const mfInstance = webpackRequire.federation.instance;
var initToken = initTokens[shareScopeKey];
if (!initToken) initToken = initTokens[shareScopeKey] = { from: mfInstance.name };
if (initScope.indexOf(initToken) >= 0) return;
initScope.push(initToken);
const promise = initPromises[shareScopeKey];
if (promise) return promise;
var warn = (msg) => typeof console !== "undefined" && console.warn && console.warn(msg);
var initExternal = (id) => {
var handleError = (err) => warn("Initialization of sharing external failed: " + err);
try {
var module = webpackRequire(id);
if (!module) return;
var initFn = (module) => module && module.init && module.init(webpackRequire.S[shareScopeKey], initScope, {
shareScopeMap: webpackRequire.S || {},
shareScopeKeys: shareScopeName
});
if (module.then) return promises.push(module.then(initFn, handleError));
var initResult = initFn(module);
if (initResult && typeof initResult !== "boolean" && initResult.then) return promises.push(initResult["catch"](handleError));
} catch (err) {
handleError(err);
}
};
const promises = mfInstance.initializeSharing(shareScopeKey, {
strategy: mfInstance.options.shareStrategy,
initScope,
from: "build"
});
require_attachShareScopeMap.attachShareScopeMap(webpackRequire);
const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
if (bundlerRuntimeRemotesOptions) Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId) => {
const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
if (info.length > 1) initExternal(externalModuleId);
else if (info.length === 1) {
const remoteInfo = info[0];
if (!require_constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) initExternal(externalModuleId);
}
});
if (!promises.length) return initPromises[shareScopeKey] = true;
return initPromises[shareScopeKey] = Promise.all(promises).then(() => initPromises[shareScopeKey] = true);
};
shareScopeKeys.forEach((key) => {
initializeSharingPromises.push(_initializeSharing(key));
});
return Promise.all(initializeSharingPromises).then(() => true);
}
//#endregion
exports.initializeSharing = initializeSharing;
//# sourceMappingURL=initializeSharing.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
import { InitializeSharingOptions } from "./types.js";
//#region src/initializeSharing.d.ts
declare function initializeSharing({
shareScopeName,
webpackRequire,
initPromises,
initTokens,
initScope
}: InitializeSharingOptions): Promise<boolean> | boolean | void;
//#endregion
export { initializeSharing };
//# sourceMappingURL=initializeSharing.d.ts.map

View File

@@ -0,0 +1,61 @@
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { FEDERATION_SUPPORTED_TYPES } from "./constant.js";
//#region src/initializeSharing.ts
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) {
const shareScopeKeys = Array.isArray(shareScopeName) ? shareScopeName : [shareScopeName];
var initializeSharingPromises = [];
var _initializeSharing = function(shareScopeKey) {
if (!initScope) initScope = [];
const mfInstance = webpackRequire.federation.instance;
var initToken = initTokens[shareScopeKey];
if (!initToken) initToken = initTokens[shareScopeKey] = { from: mfInstance.name };
if (initScope.indexOf(initToken) >= 0) return;
initScope.push(initToken);
const promise = initPromises[shareScopeKey];
if (promise) return promise;
var warn = (msg) => typeof console !== "undefined" && console.warn && console.warn(msg);
var initExternal = (id) => {
var handleError = (err) => warn("Initialization of sharing external failed: " + err);
try {
var module = webpackRequire(id);
if (!module) return;
var initFn = (module) => module && module.init && module.init(webpackRequire.S[shareScopeKey], initScope, {
shareScopeMap: webpackRequire.S || {},
shareScopeKeys: shareScopeName
});
if (module.then) return promises.push(module.then(initFn, handleError));
var initResult = initFn(module);
if (initResult && typeof initResult !== "boolean" && initResult.then) return promises.push(initResult["catch"](handleError));
} catch (err) {
handleError(err);
}
};
const promises = mfInstance.initializeSharing(shareScopeKey, {
strategy: mfInstance.options.shareStrategy,
initScope,
from: "build"
});
attachShareScopeMap(webpackRequire);
const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
if (bundlerRuntimeRemotesOptions) Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId) => {
const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
if (info.length > 1) initExternal(externalModuleId);
else if (info.length === 1) {
const remoteInfo = info[0];
if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) initExternal(externalModuleId);
}
});
if (!promises.length) return initPromises[shareScopeKey] = true;
return initPromises[shareScopeKey] = Promise.all(promises).then(() => initPromises[shareScopeKey] = true);
};
shareScopeKeys.forEach((key) => {
initializeSharingPromises.push(_initializeSharing(key));
});
return Promise.all(initializeSharingPromises).then(() => true);
}
//#endregion
export { initializeSharing };
//# sourceMappingURL=initializeSharing.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,63 @@
const require_updateOptions = require('./updateOptions.cjs');
const require_getUsedExports = require('./getUsedExports.cjs');
//#region src/installInitialConsumes.ts
function handleInitialConsumes(options) {
const { moduleId, moduleToHandlerMapping, webpackRequire, asyncLoad } = options;
const federationInstance = webpackRequire.federation.instance;
if (!federationInstance) throw new Error("Federation instance not found!");
const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
try {
const usedExports = require_getUsedExports.getUsedExports(webpackRequire, shareKey);
const customShareInfo = { ...shareInfo };
if (usedExports) customShareInfo.treeShaking = {
usedExports,
useIn: [federationInstance.options.name]
};
if (asyncLoad) return federationInstance.loadShare(shareKey, { customShareInfo });
return federationInstance.loadShareSync(shareKey, { customShareInfo });
} catch (err) {
console.error("loadShareSync failed! The function should not be called unless you set \"eager:true\". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.");
console.error("The original error message is as follows: ");
throw err;
}
}
function installInitialConsumes(options) {
require_updateOptions.updateConsumeOptions(options);
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes, asyncLoad } = options;
const factoryIdSets = [];
initialConsumes.forEach((id) => {
const factoryGetter = () => handleInitialConsumes({
moduleId: id,
moduleToHandlerMapping,
webpackRequire,
asyncLoad
});
factoryIdSets.push([id, factoryGetter]);
});
const setModule = (id, factoryGetter) => {
webpackRequire.m[id] = (module) => {
installedModules[id] = 0;
delete webpackRequire.c[id];
const factory = factoryGetter();
if (typeof factory !== "function") throw new Error(`Shared module is not available for eager consumption: ${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;
};
};
if (asyncLoad) return Promise.all(factoryIdSets.map(async ([id, factoryGetter]) => {
const result = await factoryGetter();
setModule(id, () => result);
}));
factoryIdSets.forEach(([id, factoryGetter]) => {
setModule(id, factoryGetter);
});
}
//#endregion
exports.installInitialConsumes = installInitialConsumes;
//# sourceMappingURL=installInitialConsumes.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,63 @@
import { updateConsumeOptions } from "./updateOptions.js";
import { getUsedExports } from "./getUsedExports.js";
//#region src/installInitialConsumes.ts
function handleInitialConsumes(options) {
const { moduleId, moduleToHandlerMapping, webpackRequire, asyncLoad } = options;
const federationInstance = webpackRequire.federation.instance;
if (!federationInstance) throw new Error("Federation instance not found!");
const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
try {
const usedExports = getUsedExports(webpackRequire, shareKey);
const customShareInfo = { ...shareInfo };
if (usedExports) customShareInfo.treeShaking = {
usedExports,
useIn: [federationInstance.options.name]
};
if (asyncLoad) return federationInstance.loadShare(shareKey, { customShareInfo });
return federationInstance.loadShareSync(shareKey, { customShareInfo });
} catch (err) {
console.error("loadShareSync failed! The function should not be called unless you set \"eager:true\". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.");
console.error("The original error message is as follows: ");
throw err;
}
}
function installInitialConsumes(options) {
updateConsumeOptions(options);
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes, asyncLoad } = options;
const factoryIdSets = [];
initialConsumes.forEach((id) => {
const factoryGetter = () => handleInitialConsumes({
moduleId: id,
moduleToHandlerMapping,
webpackRequire,
asyncLoad
});
factoryIdSets.push([id, factoryGetter]);
});
const setModule = (id, factoryGetter) => {
webpackRequire.m[id] = (module) => {
installedModules[id] = 0;
delete webpackRequire.c[id];
const factory = factoryGetter();
if (typeof factory !== "function") throw new Error(`Shared module is not available for eager consumption: ${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;
};
};
if (asyncLoad) return Promise.all(factoryIdSets.map(async ([id, factoryGetter]) => {
const result = await factoryGetter();
setModule(id, () => result);
}));
factoryIdSets.forEach(([id, factoryGetter]) => {
setModule(id, factoryGetter);
});
}
//#endregion
export { installInitialConsumes };
//# sourceMappingURL=installInitialConsumes.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
const require_attachShareScopeMap = require('./attachShareScopeMap.cjs');
const require_constant = require('./constant.cjs');
const require_updateOptions = require('./updateOptions.cjs');
let _module_federation_sdk = require("@module-federation/sdk");
//#region src/remotes.ts
function remotes(options) {
require_updateOptions.updateRemoteOptions(options);
const { chunkId, promises, webpackRequire, chunkMapping, idToExternalAndNameMapping, idToRemoteMap } = options;
require_attachShareScopeMap.attachShareScopeMap(webpackRequire);
if (webpackRequire.o(chunkMapping, chunkId)) chunkMapping[chunkId].forEach((id) => {
let getScope = webpackRequire.R;
if (!getScope) getScope = [];
const data = idToExternalAndNameMapping[id];
const remoteInfos = idToRemoteMap[id] || [];
if (getScope.indexOf(data) >= 0) return;
getScope.push(data);
if (data.p) return promises.push(data.p);
const onError = (error) => {
if (!error) error = /* @__PURE__ */ new Error("Container missing");
if (typeof error.message === "string") error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
webpackRequire.m[id] = () => {
throw error;
};
data.p = 0;
};
const handleFunction = (fn, arg1, arg2, d, next, first) => {
try {
const promise = fn(arg1, arg2);
if (promise && promise.then) {
const p = promise.then((result) => next(result, d), onError);
if (first) promises.push(data.p = p);
else return p;
} else return next(promise, d, first);
} catch (error) {
onError(error);
}
};
const onExternal = (external, _, first) => external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
var onFactory = (factory) => {
data.p = 1;
webpackRequire.m[id] = (module) => {
module.exports = factory();
};
};
const onRemoteLoaded = () => {
try {
const remoteModuleName = (0, _module_federation_sdk.decodeName)(remoteInfos[0].name, _module_federation_sdk.ENCODE_NAME_PREFIX) + data[1].slice(1);
const instance = webpackRequire.federation.instance;
const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
loadFactory: false,
from: "build"
});
if (instance.options.shareStrategy === "version-first") {
const shareScopes = Array.isArray(data[0]) ? data[0] : [data[0]];
return Promise.all(shareScopes.map((shareScope) => instance.sharedHandler.initializeSharing(shareScope))).then(() => {
return loadRemote();
});
}
return loadRemote();
} catch (error) {
onError(error);
}
};
if (remoteInfos.length === 1 && require_constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name) handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
else handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
});
}
//#endregion
exports.remotes = remotes;
//# sourceMappingURL=remotes.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,73 @@
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { FEDERATION_SUPPORTED_TYPES } from "./constant.js";
import { updateRemoteOptions } from "./updateOptions.js";
import { ENCODE_NAME_PREFIX, decodeName } from "@module-federation/sdk";
//#region src/remotes.ts
function remotes(options) {
updateRemoteOptions(options);
const { chunkId, promises, webpackRequire, chunkMapping, idToExternalAndNameMapping, idToRemoteMap } = options;
attachShareScopeMap(webpackRequire);
if (webpackRequire.o(chunkMapping, chunkId)) chunkMapping[chunkId].forEach((id) => {
let getScope = webpackRequire.R;
if (!getScope) getScope = [];
const data = idToExternalAndNameMapping[id];
const remoteInfos = idToRemoteMap[id] || [];
if (getScope.indexOf(data) >= 0) return;
getScope.push(data);
if (data.p) return promises.push(data.p);
const onError = (error) => {
if (!error) error = /* @__PURE__ */ new Error("Container missing");
if (typeof error.message === "string") error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
webpackRequire.m[id] = () => {
throw error;
};
data.p = 0;
};
const handleFunction = (fn, arg1, arg2, d, next, first) => {
try {
const promise = fn(arg1, arg2);
if (promise && promise.then) {
const p = promise.then((result) => next(result, d), onError);
if (first) promises.push(data.p = p);
else return p;
} else return next(promise, d, first);
} catch (error) {
onError(error);
}
};
const onExternal = (external, _, first) => external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
var onFactory = (factory) => {
data.p = 1;
webpackRequire.m[id] = (module) => {
module.exports = factory();
};
};
const onRemoteLoaded = () => {
try {
const remoteModuleName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX) + data[1].slice(1);
const instance = webpackRequire.federation.instance;
const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
loadFactory: false,
from: "build"
});
if (instance.options.shareStrategy === "version-first") {
const shareScopes = Array.isArray(data[0]) ? data[0] : [data[0]];
return Promise.all(shareScopes.map((shareScope) => instance.sharedHandler.initializeSharing(shareScope))).then(() => {
return loadRemote();
});
}
return loadRemote();
} catch (error) {
onError(error);
}
};
if (remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name) handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
else handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
});
}
//#endregion
export { remotes };
//# sourceMappingURL=remotes.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,198 @@
import { SyncHook } from "./utils/hooks/syncHook.js";
import { AsyncHook } from "./utils/hooks/asyncHook.js";
import { SyncWaterfallHook } from "./utils/hooks/syncWaterfallHook.js";
import { AsyncWaterfallHook } from "./utils/hooks/asyncWaterfallHooks.js";
import { PluginSystem } from "./utils/hooks/pluginSystem.js";
import { CallFrom, InitScope, Options, Remote, RemoteEntryExports, RemoteEntryInitOptions, RemoteInfo, ShareInfos, ShareScopeMap, Shared, UserOptions } from "./type/config.js";
import { PreloadRemoteArgs, ResourceLoadContext } from "./type/preload.js";
import { RemoteHandler } from "./remote/index.js";
import { SharedHandler } from "./shared/index.js";
import { SnapshotHandler } from "./plugins/snapshot/SnapshotHandler.js";
import { getRemoteEntry } from "./utils/load.js";
import { Module$1, RemoteModuleFactory } from "./module/index.js";
import { CreateLinkHookReturnDom, CreateScriptHookReturn, GlobalModuleInfo, ModuleInfo } from "@module-federation/sdk";
//#region ../runtime-core/dist/core.d.ts
//#region src/core.d.ts
declare class ModuleFederation {
options: Options;
hooks: PluginSystem<{
beforeInit: SyncWaterfallHook<{
userOptions: UserOptions;
options: Options;
origin: ModuleFederation;
/**
* @deprecated shareInfo will be removed soon, please use userOptions directly!
*/
shareInfo: ShareInfos;
}>;
init: SyncHook<[{
options: Options;
origin: ModuleFederation;
}], void>;
beforeInitContainer: AsyncWaterfallHook<{
shareScope: ShareScopeMap[string];
initScope: InitScope;
remoteEntryInitOptions: RemoteEntryInitOptions;
remoteInfo: RemoteInfo;
origin: ModuleFederation;
}>;
initContainer: AsyncWaterfallHook<{
shareScope: ShareScopeMap[string];
initScope: InitScope;
remoteEntryInitOptions: RemoteEntryInitOptions;
remoteInfo: RemoteInfo;
remoteEntryExports: RemoteEntryExports;
origin: ModuleFederation;
id?: string;
remoteSnapshot?: ModuleInfo;
}>;
}>;
version: string;
name: string;
moduleCache: Map<string, Module$1>;
snapshotHandler: SnapshotHandler;
sharedHandler: SharedHandler;
remoteHandler: RemoteHandler;
shareScopeMap: ShareScopeMap;
loaderHook: PluginSystem<{
getModuleInfo: SyncHook<[{
target: Record<string, any>;
key: any;
}], void | {
value: any | undefined;
key: string;
}>;
createScript: SyncHook<[{
url: string;
attrs?: Record<string, any>;
/**
* The producer(remote) info bound to this resource.
* Only present when the loader is invoked in a remote-related context
* (e.g. preloadRemote / loading remoteEntry).
*/
remoteInfo?: RemoteInfo;
resourceContext?: ResourceLoadContext;
}], CreateScriptHookReturn>;
createLink: SyncHook<[{
url: string;
attrs?: Record<string, any>;
/**
* The producer(remote) info bound to this resource.
* Only present when the loader is invoked in a remote-related context
* (e.g. preloadRemote / loading remoteEntry).
*/
remoteInfo?: RemoteInfo;
resourceContext?: ResourceLoadContext;
}], CreateLinkHookReturnDom>;
fetch: AsyncHook<[string, RequestInit, (RemoteInfo | undefined)?, (ResourceLoadContext | undefined)?], false | void | Promise<Response>>;
loadEntryError: AsyncHook<[{
getRemoteEntry: typeof getRemoteEntry;
origin: ModuleFederation;
remoteInfo: RemoteInfo;
remoteEntryExports?: RemoteEntryExports | undefined;
globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
uniqueKey: string;
}], Promise<Promise<RemoteEntryExports | undefined> | undefined>>;
afterLoadEntry: AsyncHook<[{
origin: ModuleFederation;
remoteInfo: RemoteInfo;
remoteEntryExports?: false | void | RemoteEntryExports | undefined;
error?: unknown;
recovered?: boolean;
}], void>;
beforeInitRemote: AsyncHook<[{
id?: string;
remoteInfo: RemoteInfo;
remoteSnapshot?: ModuleInfo;
origin: ModuleFederation;
}], void>;
afterInitRemote: AsyncHook<[{
id?: string;
remoteInfo: RemoteInfo;
remoteSnapshot?: ModuleInfo;
remoteEntryExports?: RemoteEntryExports;
error?: unknown;
cached?: boolean;
origin: ModuleFederation;
}], void>;
beforeGetExpose: AsyncHook<[{
id: string;
expose: string;
moduleInfo: RemoteInfo;
remoteEntryExports: RemoteEntryExports;
origin: ModuleFederation;
}], void>;
afterGetExpose: AsyncHook<[{
id: string;
expose: string;
moduleInfo: RemoteInfo;
remoteEntryExports: RemoteEntryExports;
moduleFactory?: RemoteModuleFactory;
error?: unknown;
origin: ModuleFederation;
}], void>;
beforeExecuteFactory: AsyncHook<[{
id: string;
expose: string;
moduleInfo: RemoteInfo;
loadFactory: boolean;
origin: ModuleFederation;
}], void>;
afterExecuteFactory: AsyncHook<[{
id: string;
expose: string;
moduleInfo: RemoteInfo;
loadFactory: boolean;
exposeModule?: unknown;
error?: unknown;
origin: ModuleFederation;
}], void>;
getModuleFactory: AsyncHook<[{
remoteEntryExports: RemoteEntryExports;
expose: string;
moduleInfo: RemoteInfo;
}], RemoteModuleFactory | Promise<RemoteModuleFactory | undefined> | undefined>;
}>;
bridgeHook: PluginSystem<{
beforeBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
afterBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
beforeBridgeDestroy: SyncHook<[Record<string, any>], void | Record<string, any>>;
afterBridgeDestroy: SyncHook<[Record<string, any>], void | Record<string, any>>;
}>;
moduleInfo?: GlobalModuleInfo[string];
constructor(userOptions: UserOptions);
initOptions(userOptions: UserOptions): Options;
loadShare<T>(pkgName: string, extraOptions?: {
customShareInfo?: Partial<Shared>;
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
}): Promise<false | (() => T | undefined)>;
loadShareSync<T>(pkgName: string, extraOptions?: {
customShareInfo?: Partial<Shared>;
from?: 'build' | 'runtime';
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
}): () => T | never;
initializeSharing(shareScopeName?: string, extraOptions?: {
initScope?: InitScope;
from?: CallFrom;
strategy?: Shared['strategy'];
}): Array<Promise<void>>;
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module$1;
loadRemote<T>(id: string, options?: {
loadFactory?: boolean;
from: CallFrom;
}): Promise<T | null>;
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
hostShareScopeMap?: ShareScopeMap;
}): void;
formatOptions(globalOptions: Options, userOptions: UserOptions): Options;
registerPlugins(plugins: UserOptions['plugins']): void;
registerRemotes(remotes: Remote[], options?: {
force?: boolean;
}): void;
registerShared(shared: UserOptions['shared']): void;
} //#endregion
//#endregion
export { ModuleFederation };
//# sourceMappingURL=core.d.ts.map

View File

@@ -0,0 +1,24 @@
import { GlobalShareScopeMap, RemoteEntryExports } from "./type/config.js";
import { ModuleFederationRuntimePlugin } from "./type/plugin.js";
import { ModuleFederation } from "./core.js";
import { GlobalModuleInfo, ModuleInfo } from "@module-federation/sdk";
//#region ../runtime-core/dist/global.d.ts
//#region src/global.d.ts
interface Federation {
__GLOBAL_PLUGIN__: Array<ModuleFederationRuntimePlugin>;
__DEBUG_CONSTRUCTOR_VERSION__?: string;
moduleInfo: GlobalModuleInfo;
__DEBUG_CONSTRUCTOR__?: typeof ModuleFederation;
__INSTANCES__: Array<ModuleFederation>;
__SHARE__: GlobalShareScopeMap;
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
__PRELOADED_MAP__: Map<string, boolean>;
}
declare global {
var __FEDERATION__: Federation, __VMOK__: Federation, __GLOBAL_LOADING_REMOTE_ENTRY__: Record<string, undefined | Promise<RemoteEntryExports | void>>;
}
declare const getGlobalSnapshot: () => GlobalModuleInfo;
//#endregion
export { Federation, getGlobalSnapshot };
//# sourceMappingURL=global.d.ts.map

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1,6 @@
import { UserOptions } from "./type/config.js";
import { ModuleFederationRuntimePlugin } from "./type/plugin.js";
import { Federation, getGlobalSnapshot } from "./global.js";
import { getRemoteEntry } from "./utils/load.js";
import { ModuleFederation } from "./core.js";
import { Module$1 } from "./module/index.js";

View File

@@ -0,0 +1,33 @@
import { InitScope, RemoteEntryExports, RemoteInfo } from "../type/config.js";
import { ModuleFederation } from "../core.js";
import { ModuleInfo } from "@module-federation/sdk";
//#region ../runtime-core/dist/module/index.d.ts
//#region src/module/index.d.ts
type ModuleOptions = ConstructorParameters<typeof Module$1>[0];
type RemoteModuleFactory = () => unknown | Promise<unknown>;
declare class Module$1 {
remoteInfo: RemoteInfo;
inited: boolean;
initing: boolean;
initPromise?: Promise<void>;
remoteEntryExports?: RemoteEntryExports;
lib: RemoteEntryExports | undefined;
host: ModuleFederation;
constructor({
remoteInfo,
host
}: {
remoteInfo: RemoteInfo;
host: ModuleFederation;
});
getEntry(expose?: string): Promise<RemoteEntryExports>;
init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope, expose?: string): Promise<RemoteEntryExports>;
get(id: string, expose: string, options?: {
loadFactory?: boolean;
}, remoteSnapshot?: ModuleInfo): Promise<unknown>;
private wraperFactory;
} //#endregion
//#endregion
export { Module$1, ModuleOptions, RemoteModuleFactory };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,70 @@
import { AsyncHook } from "../../utils/hooks/asyncHook.js";
import { AsyncWaterfallHook } from "../../utils/hooks/asyncWaterfallHooks.js";
import { PluginSystem } from "../../utils/hooks/pluginSystem.js";
import { Options, Remote } from "../../type/config.js";
import { ResourceLoadInitiator } from "../../type/preload.js";
import { getGlobalSnapshot } from "../../global.js";
import { ModuleFederation } from "../../core.js";
import { GlobalModuleInfo, Manifest, ModuleInfo } from "@module-federation/sdk";
//#region ../runtime-core/dist/plugins/snapshot/SnapshotHandler.d.ts
//#region src/plugins/snapshot/SnapshotHandler.d.ts
declare class SnapshotHandler {
loadingHostSnapshot: Promise<GlobalModuleInfo | void> | null;
HostInstance: ModuleFederation;
manifestCache: Map<string, Manifest>;
hooks: PluginSystem<{
beforeLoadRemoteSnapshot: AsyncHook<[{
options: Options;
moduleInfo: Remote;
origin: ModuleFederation;
}], void>;
loadSnapshot: AsyncWaterfallHook<{
options: Options;
moduleInfo: Remote;
hostGlobalSnapshot: GlobalModuleInfo[string] | undefined;
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
remoteSnapshot?: GlobalModuleInfo[string] | undefined;
}>;
loadRemoteSnapshot: AsyncWaterfallHook<{
options: Options;
moduleInfo: Remote;
manifestJson?: Manifest;
manifestUrl?: string;
remoteSnapshot: ModuleInfo;
from: "global" | "manifest";
}>;
afterLoadSnapshot: AsyncWaterfallHook<{
id?: string;
host: ModuleFederation;
options: Options;
moduleInfo: Remote;
remoteSnapshot: ModuleInfo;
}>;
}>;
loaderHook: ModuleFederation['loaderHook'];
manifestLoading: Record<string, Promise<ModuleInfo>>;
constructor(HostInstance: ModuleFederation);
loadRemoteSnapshotInfo({
moduleInfo,
id,
initiator
}: {
moduleInfo: Remote;
id?: string;
initiator?: ResourceLoadInitiator;
}): Promise<{
remoteSnapshot: ModuleInfo;
globalSnapshot: GlobalModuleInfo;
}> | never;
getGlobalRemoteInfo(moduleInfo: Remote): {
hostGlobalSnapshot: ModuleInfo | undefined;
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
remoteSnapshot: GlobalModuleInfo[string] | undefined;
};
private getManifestJson;
private loadManifestSnapshot;
} //#endregion
//#endregion
export { SnapshotHandler };
//# sourceMappingURL=SnapshotHandler.d.ts.map

View File

@@ -0,0 +1,146 @@
import { SyncHook } from "../utils/hooks/syncHook.js";
import { AsyncHook } from "../utils/hooks/asyncHook.js";
import { SyncWaterfallHook } from "../utils/hooks/syncWaterfallHook.js";
import { AsyncWaterfallHook } from "../utils/hooks/asyncWaterfallHooks.js";
import { PluginSystem } from "../utils/hooks/pluginSystem.js";
import { CallFrom, Options, Remote, RemoteEntryExports, RemoteInfo, UserOptions } from "../type/config.js";
import { PreloadAssets, PreloadOptions, PreloadRemoteArgs, PreloadRemoteResult } from "../type/preload.js";
import { ModuleFederation } from "../core.js";
import { Module$1, ModuleOptions } from "../module/index.js";
import { GlobalModuleInfo, ModuleInfo } from "@module-federation/sdk";
//#region ../runtime-core/dist/remote/index.d.ts
//#region src/remote/index.d.ts
interface LoadRemoteMatch {
id: string;
pkgNameOrAlias: string;
expose: string;
remote: Remote;
options: Options;
origin: ModuleFederation;
remoteInfo: RemoteInfo;
remoteSnapshot?: ModuleInfo;
}
declare class RemoteHandler {
host: ModuleFederation;
idToRemoteMap: Record<string, {
name: string;
expose: string;
}>;
hooks: PluginSystem<{
beforeRegisterRemote: SyncWaterfallHook<{
remote: Remote;
origin: ModuleFederation;
}>;
registerRemote: SyncWaterfallHook<{
remote: Remote;
origin: ModuleFederation;
}>;
beforeRequest: AsyncWaterfallHook<{
id: string;
options: Options;
origin: ModuleFederation;
}>;
afterMatchRemote: AsyncHook<[{
id: string;
options: Options;
remote?: Remote;
expose?: string;
remoteInfo?: RemoteInfo;
error?: unknown;
origin: ModuleFederation;
}], void>;
onLoad: AsyncHook<[{
id: string;
expose: string;
pkgNameOrAlias: string;
remote: Remote;
options: ModuleOptions;
origin: ModuleFederation;
exposeModule: any;
exposeModuleFactory: any;
moduleInstance: Module$1;
}], unknown>;
afterLoadRemote: AsyncHook<[{
id: string;
expose?: string;
remote?: RemoteInfo;
options?: {
loadFactory?: boolean;
from?: CallFrom;
};
error?: unknown;
recovered?: boolean;
origin: ModuleFederation;
}], void>;
handlePreloadModule: SyncHook<[{
id: string;
name: string;
remote: Remote;
remoteSnapshot: ModuleInfo;
preloadConfig: PreloadRemoteArgs;
origin: ModuleFederation;
}], void>;
errorLoadRemote: AsyncHook<[{
id: string;
error: unknown;
options?: any;
from: CallFrom;
lifecycle: "beforeRequest" | "beforeLoadShare" | "afterResolve" | "onLoad";
remote?: RemoteInfo;
expose?: string;
origin: ModuleFederation;
}], unknown>;
beforePreloadRemote: AsyncHook<[{
preloadOps: Array<PreloadRemoteArgs>;
options: Options;
origin: ModuleFederation;
}], false | void | Promise<false | void>>;
generatePreloadAssets: AsyncHook<[{
origin: ModuleFederation;
preloadOptions: PreloadOptions[number];
remote: Remote;
remoteInfo: RemoteInfo;
remoteSnapshot: ModuleInfo;
globalSnapshot: GlobalModuleInfo;
}], Promise<PreloadAssets>>;
afterPreloadRemote: AsyncHook<[{
preloadOps: Array<PreloadRemoteArgs>;
options: Options;
origin: ModuleFederation;
results: PreloadRemoteResult[];
error?: unknown;
}], false | void | Promise<false | void>>;
loadEntry: AsyncHook<[{
origin: ModuleFederation;
loaderHook: ModuleFederation["loaderHook"];
remoteInfo: RemoteInfo;
remoteEntryExports?: RemoteEntryExports;
}], void | RemoteEntryExports | Promise<void | RemoteEntryExports>>;
}>;
constructor(host: ModuleFederation);
formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch): void;
loadRemote<T>(id: string, options?: {
loadFactory?: boolean;
from: CallFrom;
}): Promise<T | null>;
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
registerRemotes(remotes: Remote[], options?: {
force?: boolean;
}): void;
getRemoteModuleAndOptions(options: {
id: string;
}): Promise<{
module: Module$1;
moduleOptions: ModuleOptions;
remoteMatchInfo: LoadRemoteMatch;
}>;
registerRemote(remote: Remote, targetRemotes: Remote[], options?: {
force?: boolean;
}): void;
private removeRemote;
} //#endregion
//#endregion
export { LoadRemoteMatch, RemoteHandler };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,106 @@
import { SyncHook } from "../utils/hooks/syncHook.js";
import { AsyncHook } from "../utils/hooks/asyncHook.js";
import { SyncWaterfallHook } from "../utils/hooks/syncWaterfallHook.js";
import { AsyncWaterfallHook } from "../utils/hooks/asyncWaterfallHooks.js";
import { PluginSystem } from "../utils/hooks/pluginSystem.js";
import { CallFrom, InitScope, InitTokens, Options, ShareInfos, ShareScopeMap, ShareStrategy, Shared, UserOptions } from "../type/config.js";
import { LoadRemoteMatch } from "../remote/index.js";
import { Federation } from "../global.js";
import { ModuleFederation } from "../core.js";
//#region ../runtime-core/dist/shared/index.d.ts
//#region src/shared/index.d.ts
declare class SharedHandler {
host: ModuleFederation;
shareScopeMap: ShareScopeMap;
hooks: PluginSystem<{
beforeRegisterShare: SyncWaterfallHook<{
pkgName: string;
shared: Shared;
origin: ModuleFederation;
}>;
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
beforeLoadShare: AsyncWaterfallHook<{
pkgName: string;
shareInfo?: Shared;
shared: Options["shared"];
origin: ModuleFederation;
}>;
loadShare: AsyncHook<[ModuleFederation, string, ShareInfos], false | void | Promise<false | void>>;
afterLoadShare: SyncHook<[{
pkgName: string;
shareInfo?: Partial<Shared>;
selectedShared?: Partial<Shared>;
shared: Options["shared"];
shareScopeMap: ShareScopeMap;
lifecycle: "loadShare" | "loadShareSync";
origin: ModuleFederation;
}], void>;
errorLoadShare: SyncHook<[{
pkgName: string;
shareInfo?: Partial<Shared>;
shared: Options["shared"];
shareScopeMap: ShareScopeMap;
lifecycle: "loadShare" | "loadShareSync";
origin: ModuleFederation;
error?: unknown;
recovered?: boolean;
}], void>;
resolveShare: SyncWaterfallHook<{
shareScopeMap: ShareScopeMap;
scope: string;
pkgName: string;
version: string;
shareInfo: Shared;
GlobalFederation: Federation;
resolver: () => {
shared: Shared;
useTreesShaking: boolean;
} | undefined;
}>;
initContainerShareScopeMap: SyncWaterfallHook<{
shareScope: ShareScopeMap[string];
options: Options;
origin: ModuleFederation;
scopeName: string;
hostShareScopeMap?: ShareScopeMap;
}>;
}>;
initTokens: InitTokens;
constructor(host: ModuleFederation);
private emitAfterLoadShare;
private emitErrorLoadShare;
registerShared(globalOptions: Options, userOptions: UserOptions): {
newShareInfos: ShareInfos;
allShareInfos: {
[pkgName: string]: Shared[];
};
};
loadShare<T>(pkgName: string, extraOptions?: {
customShareInfo?: Partial<Shared>;
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
}): Promise<false | (() => T | undefined)>;
/**
* This function initializes the sharing sequence (executed only once per share scope).
* It accepts one argument, the name of the share scope.
* If the share scope does not exist, it creates one.
*/
initializeSharing(shareScopeName?: string, extraOptions?: {
initScope?: InitScope;
from?: CallFrom;
strategy?: ShareStrategy;
}): Array<Promise<void>>;
loadShareSync<T>(pkgName: string, extraOptions?: {
from?: 'build' | 'runtime';
customShareInfo?: Partial<Shared>;
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
}): () => T | never;
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
hostShareScopeMap?: ShareScopeMap;
}): void;
private setShared;
private _setGlobalShareScopeMap;
} //#endregion
//#endregion
export { SharedHandler };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1,117 @@
import { ModuleFederationRuntimePlugin } from "./plugin.js";
import { Module, RemoteEntryType, RemoteWithEntry, RemoteWithVersion, TreeShakingStatus } from "@module-federation/sdk";
//#region ../runtime-core/dist/type/config.d.ts
//#region src/type/config.d.ts
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
interface RemoteInfoCommon {
alias?: string;
shareScope?: string | string[];
type?: RemoteEntryType;
entryGlobalName?: string;
}
type Remote = (RemoteWithEntry | RemoteWithVersion) & RemoteInfoCommon;
interface RemoteInfo {
alias?: string;
name: string;
version?: string;
buildVersion?: string;
entry: string;
type: RemoteEntryType;
entryGlobalName: string;
shareScope: string | string[];
}
interface SharedConfig {
singleton?: boolean;
requiredVersion: false | string;
eager?: boolean;
strictVersion?: boolean;
layer?: string | null;
}
type TreeShakingArgs = {
usedExports?: string[];
get?: SharedGetter;
lib?: () => Module;
status?: TreeShakingStatus;
mode?: 'server-calc' | 'runtime-infer';
loading?: null | Promise<any>;
loaded?: boolean;
useIn?: Array<string>;
};
type SharedBaseArgs = {
version?: string;
shareConfig?: SharedConfig;
scope?: string | Array<string>;
deps?: Array<string>;
strategy?: 'version-first' | 'loaded-first';
loaded?: boolean;
treeShaking?: TreeShakingArgs;
};
type SharedGetter = (() => () => Module) | (() => Promise<() => Module>);
type ShareArgs = (SharedBaseArgs & {
get: SharedGetter;
}) | (SharedBaseArgs & {
lib: () => Module;
}) | SharedBaseArgs;
type ShareStrategy = 'version-first' | 'loaded-first';
type Shared = {
version: string;
get: SharedGetter;
shareConfig: SharedConfig;
scope: Array<string>;
useIn: Array<string>;
from: string;
deps: Array<string>;
lib?: () => Module;
loaded?: boolean;
loading?: null | Promise<any>;
eager?: boolean;
/**
* @deprecated set in initOptions.shareStrategy instead
*/
strategy: ShareStrategy;
treeShaking?: TreeShakingArgs;
};
type ShareScopeMap = {
[scope: string]: {
[pkgName: string]: {
[sharedVersion: string]: Shared;
};
};
};
type GlobalShareScopeMap = {
[instanceName: string]: ShareScopeMap;
};
type ShareInfos = {
[pkgName: string]: Shared[];
};
interface Options {
id?: string;
name: string;
version?: string;
remotes: Array<Remote>;
shared: ShareInfos;
plugins: Array<ModuleFederationRuntimePlugin>;
inBrowser: boolean;
shareStrategy?: ShareStrategy;
}
type UserOptions = Omit<Optional<Options, 'plugins'>, 'shared' | 'inBrowser'> & {
shared?: {
[pkgName: string]: ShareArgs | ShareArgs[];
};
};
type RemoteEntryInitOptions = {
version: string;
shareScopeMap?: ShareScopeMap;
shareScopeKeys: string | string[];
};
type InitTokens = Record<string, Record<string, any>>;
type InitScope = InitTokens[];
type CallFrom = 'build' | 'runtime';
type RemoteEntryExports = {
get: (id: string) => () => Promise<Module>;
init: (shareScope: ShareScopeMap[string], initScope?: InitScope, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void | Promise<void>;
}; //#endregion
//#endregion
export { CallFrom, GlobalShareScopeMap, InitScope, InitTokens, Optional, Options, Remote, RemoteEntryExports, RemoteEntryInitOptions, RemoteInfo, RemoteInfoCommon, ShareArgs, ShareInfos, ShareScopeMap, ShareStrategy, Shared, SharedConfig, SharedGetter, TreeShakingArgs, UserOptions };
//# sourceMappingURL=config.d.ts.map

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1,28 @@
import { RemoteHandler } from "../remote/index.js";
import { SharedHandler } from "../shared/index.js";
import { SnapshotHandler } from "../plugins/snapshot/SnapshotHandler.js";
import { ModuleFederation } from "../core.js";
import { Module$1 } from "../module/index.js";
//#region ../runtime-core/dist/type/plugin.d.ts
//#region src/type/plugin.d.ts
type CoreLifeCycle = ModuleFederation['hooks']['lifecycle'];
type CoreLifeCyclePartial = Partial<{ [k in keyof CoreLifeCycle]: Parameters<CoreLifeCycle[k]['on']>[0] }>;
type SnapshotLifeCycle = SnapshotHandler['hooks']['lifecycle'];
type SnapshotLifeCycleCyclePartial = Partial<{ [k in keyof SnapshotLifeCycle]: Parameters<SnapshotLifeCycle[k]['on']>[0] }>;
type ModuleLifeCycle = Module$1['host']['loaderHook']['lifecycle'];
type ModuleLifeCycleCyclePartial = Partial<{ [k in keyof ModuleLifeCycle]: Parameters<ModuleLifeCycle[k]['on']>[0] }>;
type ModuleBridgeLifeCycle = Module$1['host']['bridgeHook']['lifecycle'];
type ModuleBridgeLifeCycleCyclePartial = Partial<{ [k in keyof ModuleBridgeLifeCycle]: Parameters<ModuleBridgeLifeCycle[k]['on']>[0] }>;
type SharedLifeCycle = SharedHandler['hooks']['lifecycle'];
type SharedLifeCycleCyclePartial = Partial<{ [k in keyof SharedLifeCycle]: Parameters<SharedLifeCycle[k]['on']>[0] }>;
type RemoteLifeCycle = RemoteHandler['hooks']['lifecycle'];
type RemoteLifeCycleCyclePartial = Partial<{ [k in keyof RemoteLifeCycle]: Parameters<RemoteLifeCycle[k]['on']>[0] }>;
type ModuleFederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & ModuleBridgeLifeCycleCyclePartial & {
name: string;
version?: string;
apply?: (instance: ModuleFederation) => void;
}; //#endregion
//#endregion
export { ModuleFederationRuntimePlugin };
//# sourceMappingURL=plugin.d.ts.map

View File

@@ -0,0 +1,55 @@
import { Remote, RemoteInfo } from "./config.js";
//#region ../runtime-core/dist/type/preload.d.ts
//#region src/type/preload.d.ts
type depsPreloadArg = Omit<PreloadRemoteArgs, 'depsRemote'>;
interface PreloadRemoteArgs {
nameOrAlias: string;
exposes?: Array<string>;
resourceCategory?: 'all' | 'sync';
share?: boolean;
depsRemote?: boolean | Array<depsPreloadArg>;
filter?: (assetUrl: string) => boolean;
}
type PreloadConfig = PreloadRemoteArgs;
type PreloadOptions = Array<{
remote: Remote;
preloadConfig: PreloadConfig;
}>;
type ResourceLoadInitiator = 'loadRemote' | 'preloadRemote';
type ResourceLoadType = 'manifest' | 'remoteEntry' | 'js' | 'css';
interface ResourceLoadContext {
initiator: ResourceLoadInitiator;
id: string;
resourceType: ResourceLoadType;
url?: string;
}
type PreloadAssetStatus = 'success' | 'error' | 'timeout' | 'cached';
interface PreloadAssetResult {
url: string;
status: PreloadAssetStatus;
resourceType: ResourceLoadType;
initiator: ResourceLoadInitiator;
id: string;
error?: unknown;
}
interface PreloadRemoteResult {
remote: Remote;
remoteInfo: RemoteInfo;
preloadConfig: PreloadConfig;
id: string;
results: PreloadAssetResult[];
}
type EntryAssets = {
name: string;
url: string;
moduleInfo: RemoteInfo;
};
interface PreloadAssets {
cssAssets: Array<string>;
jsAssetsWithoutEntry: Array<string>;
entryAssets: Array<EntryAssets>;
} //#endregion
//#endregion
export { EntryAssets, PreloadAssetResult, PreloadAssetStatus, PreloadAssets, PreloadConfig, PreloadOptions, PreloadRemoteArgs, PreloadRemoteResult, ResourceLoadContext, ResourceLoadInitiator, ResourceLoadType, depsPreloadArg };
//# sourceMappingURL=preload.d.ts.map

View File

@@ -0,0 +1,3 @@
import { CallFrom, GlobalShareScopeMap, InitScope, InitTokens, Optional, Options, Remote, RemoteEntryExports, RemoteEntryInitOptions, RemoteInfo, RemoteInfoCommon, ShareArgs, ShareInfos, ShareScopeMap, ShareStrategy, Shared, SharedConfig, SharedGetter, TreeShakingArgs, UserOptions } from "./type/config.js";
import { EntryAssets, PreloadAssetResult, PreloadAssetStatus, PreloadAssets, PreloadConfig, PreloadOptions, PreloadRemoteArgs, PreloadRemoteResult, ResourceLoadContext, ResourceLoadInitiator, ResourceLoadType, depsPreloadArg } from "./type/preload.js";
import { ModuleFederationRuntimePlugin } from "./type/plugin.js";

View File

@@ -0,0 +1,11 @@
import { ArgsType, SyncHook } from "./syncHook.js";
//#region ../runtime-core/dist/utils/hooks/asyncHook.d.ts
//#region src/utils/hooks/asyncHook.d.ts
type CallbackReturnType = void | false | Promise<void | false>;
declare class AsyncHook<T, ExternalEmitReturnType = CallbackReturnType> extends SyncHook<T, ExternalEmitReturnType> {
emit(...data: ArgsType<T>): Promise<void | false | ExternalEmitReturnType>;
} //#endregion
//#endregion
export { AsyncHook };
//# sourceMappingURL=asyncHook.d.ts.map

View File

@@ -0,0 +1,13 @@
import { SyncHook } from "./syncHook.js";
//#region ../runtime-core/dist/utils/hooks/asyncWaterfallHooks.d.ts
//#region src/utils/hooks/asyncWaterfallHooks.d.ts
type CallbackReturnType<T> = T | void | Promise<T | void>;
declare class AsyncWaterfallHook<T extends object> extends SyncHook<[T], CallbackReturnType<T>> {
onerror: (errMsg: string | Error | unknown) => void;
constructor(type: string);
emit(data: T): Promise<T>;
} //#endregion
//#endregion
export { AsyncWaterfallHook };
//# sourceMappingURL=asyncWaterfallHooks.d.ts.map

View File

@@ -0,0 +1,20 @@
import { ModuleFederation } from "../../core.js";
//#region ../runtime-core/dist/utils/hooks/pluginSystem.d.ts
//#region src/utils/hooks/pluginSystem.d.ts
type Plugin<T extends Record<string, any>> = { [k in keyof T]?: Parameters<T[k]['on']>[0] } & {
name: string;
version?: string;
apply?: (instance: ModuleFederation) => void;
};
declare class PluginSystem<T extends Record<string, any>> {
lifecycle: T;
lifecycleKeys: Array<keyof T>;
registerPlugins: Record<string, Plugin<T>>;
constructor(lifecycle: T);
applyPlugin(plugin: Plugin<T>, instance: ModuleFederation): void;
removePlugin(pluginName: string): void;
} //#endregion
//#endregion
export { PluginSystem };
//# sourceMappingURL=pluginSystem.d.ts.map

View File

@@ -0,0 +1,17 @@
//#region ../runtime-core/dist/utils/hooks/syncHook.d.ts
//#region src/utils/hooks/syncHook.d.ts
type Callback<T, K> = (...args: ArgsType<T>) => K;
type ArgsType<T> = T extends Array<any> ? T : Array<any>;
declare class SyncHook<T, K> {
type: string;
listeners: Set<Callback<T, K>>;
constructor(type?: string);
on(fn: Callback<T, K>): void;
once(fn: Callback<T, K>): void;
emit(...data: ArgsType<T>): void | K | Promise<any>;
remove(fn: Callback<T, K>): void;
removeAll(): void;
} //#endregion
//#endregion
export { ArgsType, SyncHook };
//# sourceMappingURL=syncHook.d.ts.map

View File

@@ -0,0 +1,12 @@
import { SyncHook } from "./syncHook.js";
//#region ../runtime-core/dist/utils/hooks/syncWaterfallHook.d.ts
//#region src/utils/hooks/syncWaterfallHook.d.ts
declare class SyncWaterfallHook<T extends Record<string, any>> extends SyncHook<[T], T | void> {
onerror: (errMsg: string | Error | unknown) => void;
constructor(type: string);
emit(data: T): T;
} //#endregion
//#endregion
export { SyncWaterfallHook };
//# sourceMappingURL=syncWaterfallHook.d.ts.map

View File

@@ -0,0 +1,17 @@
import { RemoteEntryExports, RemoteInfo } from "../type/config.js";
import { ResourceLoadContext } from "../type/preload.js";
import { ModuleFederation } from "../core.js";
//#region ../runtime-core/dist/utils/load.d.ts
//#region src/utils/load.d.ts
declare function getRemoteEntry(params: {
origin: ModuleFederation;
remoteInfo: RemoteInfo;
remoteEntryExports?: RemoteEntryExports | undefined;
getEntryUrl?: (url: string) => string;
_inErrorHandling?: boolean;
resourceContext?: ResourceLoadContext;
}): Promise<RemoteEntryExports | false | void>;
//#endregion
export { getRemoteEntry };
//# sourceMappingURL=load.d.ts.map

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1 @@
export { };

View File

@@ -0,0 +1,11 @@
//#region ../sdk/dist/types/plugins/ModuleFederationPlugin.d.ts
/**
* Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
*/
type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'module-import' | 'script' | 'node-commonjs';
/**
* Container location from which modules should be resolved and loaded at runtime.
*/
//#endregion
export { ExternalsType };
//# sourceMappingURL=ModuleFederationPlugin.d.ts.map

View File

@@ -0,0 +1,201 @@
import { initializeSharing } from "./initializeSharing.js";
import { attachShareScopeMap } from "./attachShareScopeMap.js";
import { initContainerEntry } from "./initContainerEntry.js";
import * as runtime from "@module-federation/runtime";
import { moduleFederationPlugin } from "@module-federation/sdk";
import { Remote, RemoteEntryInitOptions, SharedConfig, SharedGetter, TreeShakingArgs } from "@module-federation/runtime/types";
//#region src/types.d.ts
type ExcludeUndefined<T> = T extends undefined ? never : T;
type Shared = InitOptions['shared'];
type NonUndefined<T = Shared> = ExcludeUndefined<T>;
type InitOptions = Omit<Parameters<typeof runtime.init>[0], 'remotes'> & {
remotes: Array<Remote & {
externalType: moduleFederationPlugin.ExternalsType;
}>;
};
type ModuleCache = runtime.ModuleFederation['moduleCache'];
type InferModule<T> = T extends Map<string, infer U> ? U : never;
type InferredModule = InferModule<ModuleCache>;
type ShareScopeMap = runtime.ModuleFederation['shareScopeMap'];
type InitToken = Record<string, Record<string, any>>;
interface InitializeSharingOptions {
shareScopeName: string | string[];
webpackRequire: WebpackRequire;
initPromises: Record<string, Promise<boolean> | boolean>;
initTokens: InitToken;
initScope: InitToken[];
}
type RemoteEntryExports = NonUndefined<InferredModule['remoteEntryExports']>;
type ExtractInitParameters<T> = T extends {
init: (shareScope: infer U, ...args: any[]) => void;
} ? U : never;
type InferredShareScope = ExtractInitParameters<RemoteEntryExports>;
type InferredGlobalShareScope = {
[scope: string]: InferredShareScope;
};
type IdToExternalAndNameMappingItem = [string | string[], string, string | number];
interface IdToExternalAndNameMappingItemWithPromise extends IdToExternalAndNameMappingItem {
p?: Promise<any> | number;
}
type IdToExternalAndNameMapping = Record<string, IdToExternalAndNameMappingItemWithPromise>;
type ModuleId = string | number;
type RemoteDataItem = {
shareScope: string | string[];
name: string;
externalModuleId: ModuleId;
remoteName: string;
};
type ModuleIdToRemoteDataMapping = Record<ModuleId, RemoteDataItem>;
type ModuleIdToConsumeDataMapping = {
fallback: () => Promise<any>;
shareKey: string;
shareScope: string | string[];
treeShakingMode?: 'server-calc' | 'runtime-infer';
} & SharedConfig;
type WithStatus<T> = T & {
_updated: number;
};
type ConsumesLoadingData = WithStatus<{
chunkMapping?: Record<string, Array<string | number>>;
moduleIdToConsumeDataMapping?: Record<string, ModuleIdToConsumeDataMapping>;
initialConsumes?: Array<ModuleId>;
}>;
type RemotesLoadingData = WithStatus<{
chunkMapping?: Record<string, Array<ModuleId>>;
moduleIdToRemoteDataMapping?: ModuleIdToRemoteDataMapping;
}>;
type InitializeSharingData = WithStatus<{
scopeToSharingDataMapping: {
[shareScope: string]: Array<{
name: string;
version: string;
factory: SharedGetter;
eager?: boolean;
singleton?: boolean;
requiredVersion?: string;
strictVersion?: boolean;
}>;
};
uniqueName: string;
}>;
interface WebpackRequire {
(moduleId: string | number): any;
p: string;
o: (obj: Record<string, any>, key: string | number) => boolean;
R: Array<string | number>;
m: Record<string, (mod: any) => any>;
j?: string;
c: Record<string, any>;
I: (scopeName: string | string[], initScope?: InitializeSharingOptions['initScope']) => ReturnType<typeof initializeSharing>;
S?: InferredGlobalShareScope;
federation: Federation;
consumesLoadingData?: ConsumesLoadingData;
remotesLoadingData?: RemotesLoadingData;
initializeSharingData?: InitializeSharingData;
}
interface ShareInfo {
shareConfig: SharedConfig;
scope: Array<string>;
treeShaking?: TreeShakingArgs;
}
interface ModuleToHandlerMappingItem {
getter: () => Promise<any>;
shareInfo: ShareInfo;
shareKey: string;
treeShakingGetter?: () => Promise<any>;
}
interface IdToRemoteMapItem {
externalType: string;
name: string;
}
type IdToRemoteMap = Record<string, IdToRemoteMapItem[]>;
type RemoteInfos = Record<string, Array<IdToRemoteMapItem & {
alias: string;
entry?: string;
shareScope: string;
}>>;
type RemoteChunkMapping = Record<string, Array<ModuleId>>;
type CoreRemotesOptions = {
idToRemoteMap: IdToRemoteMap;
chunkMapping: RemoteChunkMapping;
idToExternalAndNameMapping: IdToExternalAndNameMapping;
};
type RemotesOptions = {
chunkId: string | number;
promises: Promise<any>[];
webpackRequire: WebpackRequire;
} & CoreRemotesOptions;
interface HandleInitialConsumesOptions {
moduleId: string | number;
moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
webpackRequire: WebpackRequire;
asyncLoad?: boolean;
}
interface InstallInitialConsumesOptions {
moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
webpackRequire: WebpackRequire;
installedModules: Record<string, Promise<any> | 0>;
initialConsumes: Array<string | number>;
asyncLoad?: boolean;
}
interface ConsumesOptions {
chunkId: string | number;
promises: Promise<any>[];
chunkMapping: Record<string, Array<string | number>>;
installedModules: Record<string, Promise<any> | 0>;
moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
webpackRequire: WebpackRequire;
}
interface InitContainerEntryOptions {
shareScope: ShareScopeMap[string];
shareScopeKey: string | string[];
webpackRequire: WebpackRequire;
remoteEntryInitOptions?: RemoteEntryInitOptions;
initScope?: InitializeSharingOptions['initScope'];
}
interface GetSharedFallbackGetterOptions {
shareKey: string;
factory: SharedGetter;
version?: string;
webpackRequire: WebpackRequire;
libraryType?: string;
}
interface Federation {
runtime?: typeof runtime;
instance?: runtime.ModuleFederation;
initOptions?: InitOptions;
installInitialConsumes?: (options: InstallInitialConsumesOptions) => any;
bundlerRuntime?: {
remotes: (options: RemotesOptions) => void;
consumes: (options: ConsumesOptions) => void;
I: typeof initializeSharing;
S: InferredGlobalShareScope;
installInitialConsumes: (options: InstallInitialConsumesOptions) => any;
initContainerEntry: typeof initContainerEntry;
init: ({
webpackRequire,
libraryType
}: {
webpackRequire: WebpackRequire;
libraryType: string;
}) => void;
getSharedFallbackGetter: (options: GetSharedFallbackGetterOptions) => SharedGetter;
};
bundlerRuntimeOptions: {
remotes?: Exclude<RemotesOptions, 'chunkId' | 'promises'> & {
remoteInfos?: RemoteInfos;
};
};
attachShareScopeMap?: typeof attachShareScopeMap;
hasAttachShareScopeMap?: boolean;
prefetch?: () => void;
usedExports?: {
[sharedName: string]: string[];
};
libraryType?: string;
sharedFallback?: Record<string, Array<[string, string, string]>>;
}
//#endregion
export { ConsumesLoadingData, ConsumesOptions, CoreRemotesOptions, Federation, GetSharedFallbackGetterOptions, HandleInitialConsumesOptions, IdToExternalAndNameMapping, IdToRemoteMap, IdToRemoteMapItem, InitContainerEntryOptions, InitializeSharingData, InitializeSharingOptions, InstallInitialConsumesOptions, ModuleId, ModuleIdToRemoteDataMapping, RemoteChunkMapping, RemoteDataItem, RemoteEntryExports, RemoteInfos, RemotesLoadingData, RemotesOptions, ShareScopeMap, WebpackRequire };
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1,112 @@
//#region src/updateOptions.ts
function updateConsumeOptions(options) {
const { webpackRequire, moduleToHandlerMapping } = options;
const { consumesLoadingData, initializeSharingData } = webpackRequire;
const { sharedFallback, bundlerRuntime, libraryType } = webpackRequire.federation;
if (consumesLoadingData && !consumesLoadingData._updated) {
const { moduleIdToConsumeDataMapping: updatedModuleIdToConsumeDataMapping = {}, initialConsumes: updatedInitialConsumes = [], chunkMapping: updatedChunkMapping = {} } = consumesLoadingData;
Object.entries(updatedModuleIdToConsumeDataMapping).forEach(([id, data]) => {
if (!moduleToHandlerMapping[id]) moduleToHandlerMapping[id] = {
getter: sharedFallback ? bundlerRuntime?.getSharedFallbackGetter({
shareKey: data.shareKey,
factory: data.fallback,
webpackRequire,
libraryType
}) : data.fallback,
treeShakingGetter: sharedFallback ? data.fallback : void 0,
shareInfo: {
shareConfig: {
requiredVersion: data.requiredVersion,
strictVersion: data.strictVersion,
singleton: data.singleton,
eager: data.eager,
layer: data.layer
},
scope: Array.isArray(data.shareScope) ? data.shareScope : [data.shareScope || "default"],
treeShaking: sharedFallback ? {
get: data.fallback,
mode: data.treeShakingMode
} : void 0
},
shareKey: data.shareKey
};
});
if ("initialConsumes" in options) {
const { initialConsumes = [] } = options;
updatedInitialConsumes.forEach((id) => {
if (!initialConsumes.includes(id)) initialConsumes.push(id);
});
}
if ("chunkMapping" in options) {
const { chunkMapping = {} } = options;
Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
if (!chunkMapping[id]) chunkMapping[id] = [];
chunkModules.forEach((moduleId) => {
if (!chunkMapping[id].includes(moduleId)) chunkMapping[id].push(moduleId);
});
});
}
consumesLoadingData._updated = 1;
}
if (initializeSharingData && !initializeSharingData._updated) {
const { federation } = webpackRequire;
if (!federation.instance || !initializeSharingData.scopeToSharingDataMapping) return;
const shared = {};
for (let [scope, stages] of Object.entries(initializeSharingData.scopeToSharingDataMapping)) for (let stage of stages) if (typeof stage === "object" && stage !== null) {
const { name, version, factory, eager, singleton, requiredVersion, strictVersion } = stage;
const shareConfig = { requiredVersion: `^${version}` };
const isValidValue = function(val) {
return typeof val !== "undefined";
};
if (isValidValue(singleton)) shareConfig.singleton = singleton;
if (isValidValue(requiredVersion)) shareConfig.requiredVersion = requiredVersion;
if (isValidValue(eager)) shareConfig.eager = eager;
if (isValidValue(strictVersion)) shareConfig.strictVersion = strictVersion;
const options = {
version,
scope: [scope],
shareConfig,
get: factory
};
if (shared[name]) shared[name].push(options);
else shared[name] = [options];
}
federation.instance.registerShared(shared);
initializeSharingData._updated = 1;
}
}
function updateRemoteOptions(options) {
const { webpackRequire, idToExternalAndNameMapping = {}, idToRemoteMap = {}, chunkMapping = {} } = options;
const { remotesLoadingData } = webpackRequire;
const remoteInfos = webpackRequire.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;
if (!remotesLoadingData || remotesLoadingData._updated || !remoteInfos) return;
const { chunkMapping: updatedChunkMapping, moduleIdToRemoteDataMapping } = remotesLoadingData;
if (!updatedChunkMapping || !moduleIdToRemoteDataMapping) return;
for (let [moduleId, data] of Object.entries(moduleIdToRemoteDataMapping)) {
if (!idToExternalAndNameMapping[moduleId]) idToExternalAndNameMapping[moduleId] = [
data.shareScope,
data.name,
data.externalModuleId
];
if (!idToRemoteMap[moduleId] && remoteInfos[data.remoteName]) {
const items = remoteInfos[data.remoteName];
idToRemoteMap[moduleId] ||= [];
items.forEach((item) => {
if (!idToRemoteMap[moduleId].includes(item)) idToRemoteMap[moduleId].push(item);
});
}
}
if (chunkMapping) Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
if (!chunkMapping[id]) chunkMapping[id] = [];
chunkModules.forEach((moduleId) => {
if (!chunkMapping[id].includes(moduleId)) chunkMapping[id].push(moduleId);
});
});
remotesLoadingData._updated = 1;
}
//#endregion
exports.updateConsumeOptions = updateConsumeOptions;
exports.updateRemoteOptions = updateRemoteOptions;
//# sourceMappingURL=updateOptions.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,110 @@
//#region src/updateOptions.ts
function updateConsumeOptions(options) {
const { webpackRequire, moduleToHandlerMapping } = options;
const { consumesLoadingData, initializeSharingData } = webpackRequire;
const { sharedFallback, bundlerRuntime, libraryType } = webpackRequire.federation;
if (consumesLoadingData && !consumesLoadingData._updated) {
const { moduleIdToConsumeDataMapping: updatedModuleIdToConsumeDataMapping = {}, initialConsumes: updatedInitialConsumes = [], chunkMapping: updatedChunkMapping = {} } = consumesLoadingData;
Object.entries(updatedModuleIdToConsumeDataMapping).forEach(([id, data]) => {
if (!moduleToHandlerMapping[id]) moduleToHandlerMapping[id] = {
getter: sharedFallback ? bundlerRuntime?.getSharedFallbackGetter({
shareKey: data.shareKey,
factory: data.fallback,
webpackRequire,
libraryType
}) : data.fallback,
treeShakingGetter: sharedFallback ? data.fallback : void 0,
shareInfo: {
shareConfig: {
requiredVersion: data.requiredVersion,
strictVersion: data.strictVersion,
singleton: data.singleton,
eager: data.eager,
layer: data.layer
},
scope: Array.isArray(data.shareScope) ? data.shareScope : [data.shareScope || "default"],
treeShaking: sharedFallback ? {
get: data.fallback,
mode: data.treeShakingMode
} : void 0
},
shareKey: data.shareKey
};
});
if ("initialConsumes" in options) {
const { initialConsumes = [] } = options;
updatedInitialConsumes.forEach((id) => {
if (!initialConsumes.includes(id)) initialConsumes.push(id);
});
}
if ("chunkMapping" in options) {
const { chunkMapping = {} } = options;
Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
if (!chunkMapping[id]) chunkMapping[id] = [];
chunkModules.forEach((moduleId) => {
if (!chunkMapping[id].includes(moduleId)) chunkMapping[id].push(moduleId);
});
});
}
consumesLoadingData._updated = 1;
}
if (initializeSharingData && !initializeSharingData._updated) {
const { federation } = webpackRequire;
if (!federation.instance || !initializeSharingData.scopeToSharingDataMapping) return;
const shared = {};
for (let [scope, stages] of Object.entries(initializeSharingData.scopeToSharingDataMapping)) for (let stage of stages) if (typeof stage === "object" && stage !== null) {
const { name, version, factory, eager, singleton, requiredVersion, strictVersion } = stage;
const shareConfig = { requiredVersion: `^${version}` };
const isValidValue = function(val) {
return typeof val !== "undefined";
};
if (isValidValue(singleton)) shareConfig.singleton = singleton;
if (isValidValue(requiredVersion)) shareConfig.requiredVersion = requiredVersion;
if (isValidValue(eager)) shareConfig.eager = eager;
if (isValidValue(strictVersion)) shareConfig.strictVersion = strictVersion;
const options = {
version,
scope: [scope],
shareConfig,
get: factory
};
if (shared[name]) shared[name].push(options);
else shared[name] = [options];
}
federation.instance.registerShared(shared);
initializeSharingData._updated = 1;
}
}
function updateRemoteOptions(options) {
const { webpackRequire, idToExternalAndNameMapping = {}, idToRemoteMap = {}, chunkMapping = {} } = options;
const { remotesLoadingData } = webpackRequire;
const remoteInfos = webpackRequire.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;
if (!remotesLoadingData || remotesLoadingData._updated || !remoteInfos) return;
const { chunkMapping: updatedChunkMapping, moduleIdToRemoteDataMapping } = remotesLoadingData;
if (!updatedChunkMapping || !moduleIdToRemoteDataMapping) return;
for (let [moduleId, data] of Object.entries(moduleIdToRemoteDataMapping)) {
if (!idToExternalAndNameMapping[moduleId]) idToExternalAndNameMapping[moduleId] = [
data.shareScope,
data.name,
data.externalModuleId
];
if (!idToRemoteMap[moduleId] && remoteInfos[data.remoteName]) {
const items = remoteInfos[data.remoteName];
idToRemoteMap[moduleId] ||= [];
items.forEach((item) => {
if (!idToRemoteMap[moduleId].includes(item)) idToRemoteMap[moduleId].push(item);
});
}
}
if (chunkMapping) Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
if (!chunkMapping[id]) chunkMapping[id] = [];
chunkModules.forEach((moduleId) => {
if (!chunkMapping[id].includes(moduleId)) chunkMapping[id].push(moduleId);
});
});
remotesLoadingData._updated = 1;
}
//#endregion
export { updateConsumeOptions, updateRemoteOptions };
//# sourceMappingURL=updateOptions.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,77 @@
{
"public": true,
"name": "@module-federation/webpack-bundler-runtime",
"version": "2.5.0",
"type": "module",
"license": "MIT",
"description": "Module Federation Runtime for webpack",
"keywords": [
"Module Federation",
"bundler runtime"
],
"files": [
"dist/",
"README.md"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/module-federation/core.git",
"directory": "packages/webpack-bundler-runtime"
},
"author": "zhanghang <hanric.zhang@gmail.com>",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"@module-federation/runtime": "2.5.0",
"@module-federation/error-codes": "2.5.0",
"@module-federation/sdk": "2.5.0"
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
},
"./constant": {
"import": {
"types": "./dist/constant.d.ts",
"default": "./dist/constant.js"
},
"require": {
"types": "./dist/constant.d.ts",
"default": "./dist/constant.cjs"
}
},
"./bundler": "./dist/bundler.js",
"./*": "./*"
},
"typesVersions": {
"*": {
".": [
"./dist/index.d.ts"
],
"constant": [
"./dist/constant.d.ts"
],
"bundler": [
"./dist/bundler.d.ts"
]
}
},
"scripts": {
"build": "tsdown --config tsdown.config.ts --filter webpack-bundler-runtime-build",
"lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
"test": "pnpm exec jest --config jest.config.cjs --passWithNoTests",
"test:ci": "pnpm exec jest --config jest.config.cjs --passWithNoTests --ci --coverage",
"pre-release": "pnpm run test && pnpm run build"
}
}