@module-federation/runtime
Advanced tools
Comparing version 0.0.0-next-20241105091216 to 0.0.0-next-20241105094332
@@ -93,2 +93,3 @@ 'use strict'; | ||
const CurrentGlobal = typeof globalThis === 'object' ? globalThis : window; | ||
const nativeGlobal = (()=>{ | ||
@@ -100,3 +101,3 @@ try { | ||
// node env | ||
return globalThis; | ||
return CurrentGlobal; | ||
} | ||
@@ -118,6 +119,6 @@ })(); | ||
// If there is no loading content on the global object, this section defines the loading object. | ||
if (!includeOwnProperty(globalThis, '__GLOBAL_LOADING_REMOTE_ENTRY__')) { | ||
definePropertyGlobalVal(globalThis, '__GLOBAL_LOADING_REMOTE_ENTRY__', {}); | ||
if (!includeOwnProperty(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__')) { | ||
definePropertyGlobalVal(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__', {}); | ||
} | ||
const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__; | ||
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__; | ||
function setGlobalDefaultVal(target) { | ||
@@ -152,14 +153,14 @@ var _target___FEDERATION__, _target___FEDERATION__1, _target___FEDERATION__2, _target___FEDERATION__3, _target___FEDERATION__4, _target___FEDERATION__5; | ||
} | ||
setGlobalDefaultVal(globalThis); | ||
setGlobalDefaultVal(CurrentGlobal); | ||
setGlobalDefaultVal(nativeGlobal); | ||
function resetFederationGlobalInfo() { | ||
globalThis.__FEDERATION__.__GLOBAL_PLUGIN__ = []; | ||
globalThis.__FEDERATION__.__INSTANCES__ = []; | ||
globalThis.__FEDERATION__.moduleInfo = {}; | ||
globalThis.__FEDERATION__.__SHARE__ = {}; | ||
globalThis.__FEDERATION__.__MANIFEST_LOADING__ = {}; | ||
CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = []; | ||
CurrentGlobal.__FEDERATION__.__INSTANCES__ = []; | ||
CurrentGlobal.__FEDERATION__.moduleInfo = {}; | ||
CurrentGlobal.__FEDERATION__.__SHARE__ = {}; | ||
CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {}; | ||
} | ||
function getGlobalFederationInstance(name, version) { | ||
const buildId = getBuilderId(); | ||
return globalThis.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{ | ||
return CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{ | ||
if (buildId && GMInstance.options.id === getBuilderId()) { | ||
@@ -178,11 +179,11 @@ return true; | ||
function setGlobalFederationInstance(FederationInstance) { | ||
globalThis.__FEDERATION__.__INSTANCES__.push(FederationInstance); | ||
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance); | ||
} | ||
function getGlobalFederationConstructor() { | ||
return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__; | ||
return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__; | ||
} | ||
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) { | ||
if (isDebug) { | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.16"; | ||
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; | ||
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.16"; | ||
} | ||
@@ -263,3 +264,3 @@ } | ||
const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`; | ||
const entryExports = globalThis[remoteEntryKey]; | ||
const entryExports = CurrentGlobal[remoteEntryKey]; | ||
return { | ||
@@ -285,4 +286,4 @@ remoteEntryKey, | ||
const getGlobalHostPlugins = ()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__; | ||
const getPreloaded = (id)=>globalThis.__FEDERATION__.__PRELOADED_MAP__.get(id); | ||
const setPreloaded = (id)=>globalThis.__FEDERATION__.__PRELOADED_MAP__.set(id, true); | ||
const getPreloaded = (id)=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id); | ||
const setPreloaded = (id)=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true); | ||
@@ -775,5 +776,2 @@ const DEFAULT_SCOPE = 'default'; | ||
}; | ||
const isLoading = (shared)=>{ | ||
return Boolean(shared.loading); | ||
}; | ||
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) { | ||
@@ -789,7 +787,4 @@ const versions = shareScopeMap[scope][pkgName]; | ||
const callback = function(prev, cur) { | ||
const isLoadingOrLoaded = (shared)=>{ | ||
return isLoaded(shared) || isLoading(shared); | ||
}; | ||
if (isLoadingOrLoaded(versions[cur])) { | ||
if (isLoadingOrLoaded(versions[prev])) { | ||
if (isLoaded(versions[cur])) { | ||
if (isLoaded(versions[prev])) { | ||
return Boolean(versionLt(prev, cur)); | ||
@@ -800,3 +795,3 @@ } else { | ||
} | ||
if (isLoadingOrLoaded(versions[prev])) { | ||
if (isLoaded(versions[prev])) { | ||
return false; | ||
@@ -890,2 +885,3 @@ } | ||
exports.CurrentGlobal = CurrentGlobal; | ||
exports.DEFAULT_REMOTE_TYPE = DEFAULT_REMOTE_TYPE; | ||
@@ -892,0 +888,0 @@ exports.DEFAULT_SCOPE = DEFAULT_SCOPE; |
@@ -15,2 +15,3 @@ import { FederationHost } from './core'; | ||
} | ||
export declare const CurrentGlobal: typeof globalThis; | ||
export declare const nativeGlobal: typeof global; | ||
@@ -17,0 +18,0 @@ export declare const Global: typeof globalThis; |
{ | ||
"name": "@module-federation/runtime", | ||
"version": "0.0.0-next-20241105091216", | ||
"version": "0.0.0-next-20241105094332", | ||
"author": "zhouxiao <codingzx@gmail.com>", | ||
@@ -53,5 +53,5 @@ "main": "./dist/index.cjs.js", | ||
"dependencies": { | ||
"@module-federation/sdk": "0.0.0-next-20241105091216", | ||
"@module-federation/error-codes": "0.0.0-next-20241105091216" | ||
"@module-federation/sdk": "0.0.0-next-20241105094332", | ||
"@module-federation/error-codes": "0.0.0-next-20241105094332" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
323603
7544
+ Added@module-federation/error-codes@0.0.0-next-20241105094332(transitive)
+ Added@module-federation/sdk@0.0.0-next-20241105094332(transitive)
- Removed@module-federation/error-codes@0.0.0-next-20241105091216(transitive)
- Removed@module-federation/sdk@0.0.0-next-20241105091216(transitive)
Updated@module-federation/error-codes@0.0.0-next-20241105094332