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

31 lines
1.4 KiB
JavaScript

const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
let _module_federation_runtime_tools_runtime_core = require("@module-federation/runtime-tools/runtime-core");
_module_federation_runtime_tools_runtime_core = require_runtime.__toESM(_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 = _module_federation_runtime_tools_runtime_core.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 = _module_federation_runtime_tools_runtime_core;
globalRef._FEDERATION_RUNTIME_CORE_FROM = {
version,
name
};
return args;
}
};
}
//#endregion
module.exports = injectExternalRuntimeCorePlugin;
//# sourceMappingURL=index.cjs.map