Files
emaui/node_modules/@module-federation/inject-external-runtime-core-plugin/dist/index.js
2026-05-29 15:23:46 +03:00

29 lines
1.2 KiB
JavaScript

import * as runtimeCore from "@module-federation/runtime-tools/runtime-core";
//#region src/index.ts
function injectExternalRuntimeCorePlugin() {
return {
name: "inject-external-runtime-core-plugin",
version: "2.5.0",
beforeInit(args) {
const globalRef = runtimeCore.Global;
if (!globalRef || typeof globalRef !== "object") return args;
const name = args.options.name;
const version = "2.5.0";
if (globalRef._FEDERATION_RUNTIME_CORE && globalRef._FEDERATION_RUNTIME_CORE_FROM && (globalRef._FEDERATION_RUNTIME_CORE_FROM.name !== name || globalRef._FEDERATION_RUNTIME_CORE_FROM.version !== version)) {
console.warn(`Detect multiple module federation runtime! Injected runtime from ${globalRef._FEDERATION_RUNTIME_CORE_FROM.name}@${globalRef._FEDERATION_RUNTIME_CORE_FROM.version} and current is ${name}@${version}, pleasure ensure there is only one consumer to provider runtime!`);
return args;
}
globalRef._FEDERATION_RUNTIME_CORE = runtimeCore;
globalRef._FEDERATION_RUNTIME_CORE_FROM = {
version,
name
};
return args;
}
};
}
//#endregion
export { injectExternalRuntimeCorePlugin as default };
//# sourceMappingURL=index.js.map