@module-federation/runtime 0.0.0-next-20231225064454 → 0.0.0-next-20231225073141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers.cjs.js +1 -1
- package/dist/helpers.esm.js +2 -2
- package/dist/index.cjs.js +137 -68
- package/dist/index.esm.js +136 -70
- package/dist/package.json +2 -2
- package/dist/share.cjs.js +70 -47
- package/dist/share.esm.js +70 -47
- package/dist/src/core.d.ts +15 -5
- package/dist/src/global.d.ts +2 -3
- package/dist/src/helpers.d.ts +2 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/module/index.d.ts +4 -2
- package/dist/src/type/config.d.ts +5 -2
- package/dist/src/utils/share.d.ts +12 -3
- package/dist/types.cjs.d.ts +1 -0
- package/package.json +4 -4
- package/dist/type.cjs.d.ts +0 -1
- /package/dist/{type.cjs.js → types.cjs.js} +0 -0
- /package/dist/{type.esm.js → types.esm.js} +0 -0
package/dist/share.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
function getBuilderId() {
|
|
2
|
+
//@ts-ignore
|
|
2
3
|
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
3
4
|
}
|
|
4
5
|
function isDebugMode() {
|
|
@@ -41,7 +42,7 @@ function isRemoteInfoWithEntry(remote) {
|
|
|
41
42
|
return typeof remote.entry !== 'undefined';
|
|
42
43
|
}
|
|
43
44
|
function isPureRemoteEntry(remote) {
|
|
44
|
-
return
|
|
45
|
+
return remote.entry.endsWith('.js');
|
|
45
46
|
}
|
|
46
47
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
47
48
|
function safeToString(info) {
|
|
@@ -86,7 +87,7 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
86
87
|
}
|
|
87
88
|
return target;
|
|
88
89
|
}
|
|
89
|
-
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5
|
|
90
|
+
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5;
|
|
90
91
|
// export const nativeGlobal: typeof global = new Function('return this')();
|
|
91
92
|
const nativeGlobal = new Function('return this')();
|
|
92
93
|
// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.
|
|
@@ -109,7 +110,6 @@ if (nativeGlobal.__VMOK__) {
|
|
|
109
110
|
moduleInfo: {},
|
|
110
111
|
__SHARE__: {},
|
|
111
112
|
__MANIFEST_LOADING__: {},
|
|
112
|
-
__SHARE_SCOPE_LOADING__: {},
|
|
113
113
|
__PRELOADED_MAP__: new Map()
|
|
114
114
|
};
|
|
115
115
|
nativeGlobal.__VMOK__ = nativeGlobal.__FEDERATION__;
|
|
@@ -124,10 +124,8 @@ var ___SHARE__;
|
|
|
124
124
|
(___SHARE__ = (_nativeGlobal___FEDERATION__3 = nativeGlobal.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _nativeGlobal___FEDERATION__3.__SHARE__ = {};
|
|
125
125
|
var ___MANIFEST_LOADING__;
|
|
126
126
|
(___MANIFEST_LOADING__ = (_nativeGlobal___FEDERATION__4 = nativeGlobal.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _nativeGlobal___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
127
|
-
var ___SHARE_SCOPE_LOADING__;
|
|
128
|
-
(___SHARE_SCOPE_LOADING__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__SHARE_SCOPE_LOADING__) != null ? ___SHARE_SCOPE_LOADING__ : _nativeGlobal___FEDERATION__5.__SHARE_SCOPE_LOADING__ = {};
|
|
129
127
|
var ___PRELOADED_MAP__;
|
|
130
|
-
(___PRELOADED_MAP__ = (
|
|
128
|
+
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__5.__PRELOADED_MAP__ = new Map();
|
|
131
129
|
const Global = {
|
|
132
130
|
get __FEDERATION__ () {
|
|
133
131
|
const globalThisVal = new Function('return globalThis')();
|
|
@@ -140,7 +138,6 @@ function resetFederationGlobalInfo() {
|
|
|
140
138
|
nativeGlobal.__FEDERATION__.moduleInfo = {};
|
|
141
139
|
nativeGlobal.__FEDERATION__.__SHARE__ = {};
|
|
142
140
|
nativeGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
143
|
-
nativeGlobal.__FEDERATION__.__SHARE_SCOPE_LOADING__ = {};
|
|
144
141
|
}
|
|
145
142
|
function getGlobalFederationInstance(name, version) {
|
|
146
143
|
const buildId = getBuilderId();
|
|
@@ -623,6 +620,7 @@ function formatShare(shareArgs, from) {
|
|
|
623
620
|
loading: null
|
|
624
621
|
}, shareArgs, {
|
|
625
622
|
get,
|
|
623
|
+
loaded: 'lib' in shareArgs ? true : undefined,
|
|
626
624
|
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [
|
|
627
625
|
'default'
|
|
628
626
|
],
|
|
@@ -639,15 +637,26 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
639
637
|
}, {});
|
|
640
638
|
}
|
|
641
639
|
function versionLt(a, b) {
|
|
642
|
-
|
|
640
|
+
const transformInvalidVersion = (version)=>{
|
|
641
|
+
const isNumberVersion = !Number.isNaN(Number(version));
|
|
642
|
+
if (isNumberVersion) {
|
|
643
|
+
const splitArr = version.split('.');
|
|
644
|
+
let validVersion = version;
|
|
645
|
+
for(let i = 0; i < 3 - splitArr.length; i++){
|
|
646
|
+
validVersion += '.0';
|
|
647
|
+
}
|
|
648
|
+
return validVersion;
|
|
649
|
+
}
|
|
650
|
+
return version;
|
|
651
|
+
};
|
|
652
|
+
if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) {
|
|
643
653
|
return true;
|
|
644
654
|
} else {
|
|
645
655
|
return false;
|
|
646
656
|
}
|
|
647
657
|
}
|
|
648
|
-
const findVersion = (scope, pkgName, cb)=>{
|
|
649
|
-
const
|
|
650
|
-
const versions = globalShares[scope][pkgName];
|
|
658
|
+
const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
|
|
659
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
651
660
|
const callback = cb || function(prev, cur) {
|
|
652
661
|
return versionLt(prev, cur);
|
|
653
662
|
};
|
|
@@ -658,20 +667,22 @@ const findVersion = (scope, pkgName, cb)=>{
|
|
|
658
667
|
if (callback(prev, cur)) {
|
|
659
668
|
return cur;
|
|
660
669
|
}
|
|
670
|
+
// default version is '0' https://github.com/webpack/webpack/blob/main/lib/sharing/ProvideSharedModule.js#L136
|
|
671
|
+
if (prev === '0') {
|
|
672
|
+
return cur;
|
|
673
|
+
}
|
|
661
674
|
return prev;
|
|
662
675
|
}, 0);
|
|
663
676
|
};
|
|
664
|
-
function findSingletonVersionOrderByVersion(scope, pkgName) {
|
|
665
|
-
const
|
|
666
|
-
const versions = globalShares[scope][pkgName];
|
|
677
|
+
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
|
|
678
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
667
679
|
const callback = function(prev, cur) {
|
|
668
680
|
return !versions[prev].loaded && versionLt(prev, cur);
|
|
669
681
|
};
|
|
670
|
-
return findVersion(scope, pkgName, callback);
|
|
682
|
+
return findVersion(shareScopeMap, scope, pkgName, callback);
|
|
671
683
|
}
|
|
672
|
-
function findSingletonVersionOrderByLoaded(scope, pkgName) {
|
|
673
|
-
const
|
|
674
|
-
const versions = globalShares[scope][pkgName];
|
|
684
|
+
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
685
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
675
686
|
const callback = function(prev, cur) {
|
|
676
687
|
if (versions[cur].loaded) {
|
|
677
688
|
if (versions[prev].loaded) {
|
|
@@ -685,45 +696,57 @@ function findSingletonVersionOrderByLoaded(scope, pkgName) {
|
|
|
685
696
|
}
|
|
686
697
|
return versionLt(prev, cur);
|
|
687
698
|
};
|
|
688
|
-
return findVersion(scope, pkgName, callback);
|
|
699
|
+
return findVersion(shareScopeMap, scope, pkgName, callback);
|
|
700
|
+
}
|
|
701
|
+
function getFindShareFunction(strategy) {
|
|
702
|
+
if (strategy === 'loaded-first') {
|
|
703
|
+
return findSingletonVersionOrderByLoaded;
|
|
704
|
+
}
|
|
705
|
+
return findSingletonVersionOrderByVersion;
|
|
689
706
|
}
|
|
690
707
|
// Details about shared resources
|
|
691
708
|
// TODO: Implement strictVersion for alignment with module federation.
|
|
692
|
-
function
|
|
693
|
-
|
|
709
|
+
function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
|
|
710
|
+
if (!localShareScopeMap) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
694
713
|
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
695
714
|
const scopes = Array.isArray(scope) ? scope : [
|
|
696
715
|
scope
|
|
697
716
|
];
|
|
698
717
|
for (const sc of scopes){
|
|
699
|
-
if (shareConfig &&
|
|
718
|
+
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
700
719
|
const { requiredVersion } = shareConfig;
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
if (
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
// eslint-disable-next-line max-depth
|
|
720
|
-
for (const [versionKey, versionValue] of Object.entries(globalShares[sc][pkgName])){
|
|
721
|
-
// eslint-disable-next-line max-depth
|
|
722
|
-
if (satisfy(versionKey, requiredVersion)) {
|
|
723
|
-
return versionValue;
|
|
720
|
+
const findShareFunction = getFindShareFunction(strategy);
|
|
721
|
+
const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
|
|
722
|
+
//@ts-ignore
|
|
723
|
+
const defaultResolver = ()=>{
|
|
724
|
+
if (shareConfig.singleton) {
|
|
725
|
+
if (typeof requiredVersion === 'string' && !satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
726
|
+
warn(`Version ${maxOrSingletonVersion} from ${maxOrSingletonVersion && localShareScopeMap[sc][pkgName][maxOrSingletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`);
|
|
727
|
+
}
|
|
728
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
729
|
+
} else {
|
|
730
|
+
if (requiredVersion === false || requiredVersion === '*') {
|
|
731
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
732
|
+
}
|
|
733
|
+
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])){
|
|
734
|
+
if (satisfy(versionKey, requiredVersion)) {
|
|
735
|
+
return versionValue;
|
|
736
|
+
}
|
|
724
737
|
}
|
|
725
738
|
}
|
|
726
|
-
}
|
|
739
|
+
};
|
|
740
|
+
const params = {
|
|
741
|
+
shareScopeMap: localShareScopeMap,
|
|
742
|
+
scope: sc,
|
|
743
|
+
pkgName,
|
|
744
|
+
version: maxOrSingletonVersion,
|
|
745
|
+
GlobalFederation: Global.__FEDERATION__,
|
|
746
|
+
resolver: defaultResolver
|
|
747
|
+
};
|
|
748
|
+
const resolveShared = resolveShare.emit(params) || params;
|
|
749
|
+
return resolveShared.resolver();
|
|
727
750
|
}
|
|
728
751
|
}
|
|
729
752
|
}
|
|
@@ -731,4 +754,4 @@ function getGlobalShareScope() {
|
|
|
731
754
|
return Global.__FEDERATION__.__SHARE__;
|
|
732
755
|
}
|
|
733
756
|
|
|
734
|
-
export { getGlobalFederationInstance as A, getGlobalFederationConstructor as B, setGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, registerGlobalPlugins as E, nativeGlobal as F, Global as G, resetFederationGlobalInfo as H, getTargetSnapshotInfoByModuleInfo as I, addGlobalSnapshot as J, DEFAULT_SCOPE as a, globalLoading as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k,
|
|
757
|
+
export { getGlobalFederationInstance as A, getGlobalFederationConstructor as B, setGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, registerGlobalPlugins as E, nativeGlobal as F, Global as G, resetFederationGlobalInfo as H, getTargetSnapshotInfoByModuleInfo as I, addGlobalSnapshot as J, DEFAULT_SCOPE as a, globalLoading as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRegisteredShare as l, getInfoWithoutType as m, getPreloaded as n, setPreloaded as o, getGlobalSnapshotInfoByModuleInfo as p, setGlobalSnapshotInfoByModuleInfo as q, getGlobalSnapshot as r, safeToString as s, getGlobalShareScope as t, addUniqueItem as u, formatShareConfigs as v, warn as w, isBrowserEnv as x, getBuilderId as y, setGlobalFederationConstructor as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { Options, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, Shared, ShareInfos, UserOptions, RemoteInfo } from './type';
|
|
2
|
+
import { Options, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap } from './type';
|
|
3
3
|
import { Module, ModuleOptions } from './module';
|
|
4
4
|
import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
|
|
5
|
+
import { Federation } from './global';
|
|
5
6
|
import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
|
|
6
7
|
interface LoadRemoteMatch {
|
|
7
8
|
id: string;
|
|
@@ -60,6 +61,14 @@ export declare class FederationHost {
|
|
|
60
61
|
origin: FederationHost;
|
|
61
62
|
}>;
|
|
62
63
|
loadShare: AsyncHook<[FederationHost, string, ShareInfos], false | void | Promise<false | void>>;
|
|
64
|
+
resolveShare: SyncWaterfallHook<{
|
|
65
|
+
shareScopeMap: ShareScopeMap;
|
|
66
|
+
scope: string;
|
|
67
|
+
pkgName: string;
|
|
68
|
+
version: string;
|
|
69
|
+
GlobalFederation: Federation;
|
|
70
|
+
resolver: () => Shared | undefined;
|
|
71
|
+
}>;
|
|
63
72
|
beforePreloadRemote: AsyncHook<{
|
|
64
73
|
preloadOps: Array<PreloadRemoteArgs>;
|
|
65
74
|
options: Options;
|
|
@@ -79,10 +88,12 @@ export declare class FederationHost {
|
|
|
79
88
|
origin: FederationHost;
|
|
80
89
|
}, false | void | Promise<false | void>>;
|
|
81
90
|
}>;
|
|
91
|
+
releaseNumber: string;
|
|
82
92
|
version: string;
|
|
83
93
|
name: string;
|
|
84
94
|
moduleCache: Map<string, Module>;
|
|
85
95
|
snapshotHandler: SnapshotHandler;
|
|
96
|
+
shareScopeMap: ShareScopeMap;
|
|
86
97
|
loaderHook: PluginSystem<{
|
|
87
98
|
getModuleInfo: SyncHook<[{
|
|
88
99
|
target: Record<string, any>;
|
|
@@ -96,10 +107,8 @@ export declare class FederationHost {
|
|
|
96
107
|
}], void | HTMLScriptElement>;
|
|
97
108
|
fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
98
109
|
}>;
|
|
99
|
-
loadingShare: {
|
|
100
|
-
[key: string]: Promise<any>;
|
|
101
|
-
};
|
|
102
110
|
constructor(userOptions: UserOptions);
|
|
111
|
+
private _setGlobalShareScopeMap;
|
|
103
112
|
initOptions(userOptions: UserOptions): Options;
|
|
104
113
|
loadShare<T>(pkgName: string, customShareInfo?: Partial<Shared>): Promise<false | (() => T | undefined)>;
|
|
105
114
|
loadShareSync<T>(pkgName: string): () => T | never;
|
|
@@ -113,7 +122,8 @@ export declare class FederationHost {
|
|
|
113
122
|
* It accepts one argument, the name of the share scope.
|
|
114
123
|
* If the share scope does not exist, it creates one.
|
|
115
124
|
*/
|
|
116
|
-
initializeSharing(shareScopeName?: string):
|
|
125
|
+
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
|
|
126
|
+
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string]): void;
|
|
117
127
|
private formatOptions;
|
|
118
128
|
private registerPlugins;
|
|
119
129
|
private setShared;
|
package/dist/src/global.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { FederationHost } from './core';
|
|
3
|
-
import { RemoteEntryExports,
|
|
3
|
+
import { RemoteEntryExports, GlobalShareScopeMap, Remote, Optional } from './type';
|
|
4
4
|
import { GlobalModuleInfo, ModuleInfo } from '@module-federation/sdk';
|
|
5
5
|
import { FederationRuntimePlugin } from './type/plugin';
|
|
6
6
|
export interface Federation {
|
|
@@ -9,9 +9,8 @@ export interface Federation {
|
|
|
9
9
|
moduleInfo: GlobalModuleInfo;
|
|
10
10
|
__DEBUG_CONSTRUCTOR__?: typeof FederationHost;
|
|
11
11
|
__INSTANCES__: Array<FederationHost>;
|
|
12
|
-
__SHARE__:
|
|
12
|
+
__SHARE__: GlobalShareScopeMap;
|
|
13
13
|
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
|
|
14
|
-
__SHARE_SCOPE_LOADING__: Record<string, boolean | Promise<boolean>>;
|
|
15
14
|
__PRELOADED_MAP__: Map<string, boolean>;
|
|
16
15
|
}
|
|
17
16
|
export declare const nativeGlobal: typeof global;
|
package/dist/src/helpers.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded } from './global';
|
|
3
|
-
import {
|
|
3
|
+
import { getRegisteredShare, getGlobalShareScope } from './utils/share';
|
|
4
4
|
interface IShareUtils {
|
|
5
|
-
|
|
5
|
+
getRegisteredShare: typeof getRegisteredShare;
|
|
6
6
|
getGlobalShareScope: typeof getGlobalShareScope;
|
|
7
7
|
}
|
|
8
8
|
interface IGlobalUtils {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { FederationHost } from './core';
|
|
|
2
2
|
import { UserOptions } from './type';
|
|
3
3
|
export { FederationHost } from './core';
|
|
4
4
|
export { registerGlobalPlugins } from './global';
|
|
5
|
+
export { loadScript } from '@module-federation/sdk';
|
|
5
6
|
export type { Federation } from './global';
|
|
6
7
|
export declare function init(options: UserOptions): FederationHost;
|
|
7
8
|
export declare function loadRemote(...args: Parameters<FederationHost['loadRemote']>): ReturnType<FederationHost['loadRemote']>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FederationHost } from '../core';
|
|
2
|
-
import { RemoteEntryExports, Options, Remote, ShareInfos, RemoteInfo } from '../type';
|
|
2
|
+
import { RemoteEntryExports, Options, Remote, ShareInfos, RemoteInfo, ShareScopeMap } from '../type';
|
|
3
3
|
export type ModuleOptions = ConstructorParameters<typeof Module>[0];
|
|
4
4
|
type HostInfo = Remote;
|
|
5
5
|
declare class Module {
|
|
@@ -10,12 +10,14 @@ declare class Module {
|
|
|
10
10
|
remoteEntryExports?: RemoteEntryExports;
|
|
11
11
|
lib: RemoteEntryExports | undefined;
|
|
12
12
|
loaderHook: FederationHost['loaderHook'];
|
|
13
|
-
|
|
13
|
+
shareScopeMap: ShareScopeMap;
|
|
14
|
+
constructor({ hostInfo, remoteInfo, shared, loaderHook, shareScopeMap, }: {
|
|
14
15
|
hostInfo: HostInfo;
|
|
15
16
|
remoteInfo: RemoteInfo;
|
|
16
17
|
shared: ShareInfos;
|
|
17
18
|
plugins: Options['plugins'];
|
|
18
19
|
loaderHook: FederationHost['loaderHook'];
|
|
20
|
+
shareScopeMap: ShareScopeMap;
|
|
19
21
|
});
|
|
20
22
|
getEntry(): Promise<RemoteEntryExports>;
|
|
21
23
|
get(expose: string, options?: {
|
|
@@ -57,13 +57,16 @@ export type Shared = {
|
|
|
57
57
|
eager?: boolean;
|
|
58
58
|
strategy: 'version-first' | 'loaded-first';
|
|
59
59
|
};
|
|
60
|
-
export type
|
|
60
|
+
export type ShareScopeMap = {
|
|
61
61
|
[scope: string]: {
|
|
62
62
|
[pkgName: string]: {
|
|
63
63
|
[sharedVersion: string]: Shared;
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
+
export type GlobalShareScopeMap = {
|
|
68
|
+
[instanceName: string]: ShareScopeMap;
|
|
69
|
+
};
|
|
67
70
|
export type ShareInfos = {
|
|
68
71
|
[pkgName: string]: Shared;
|
|
69
72
|
};
|
|
@@ -89,6 +92,6 @@ export type RemoteEntryInitOptions = {
|
|
|
89
92
|
};
|
|
90
93
|
export type RemoteEntryExports = {
|
|
91
94
|
get: (id: string) => () => Promise<Module>;
|
|
92
|
-
init: (shareScope:
|
|
95
|
+
init: (shareScope: ShareScopeMap[string], initScope?: Array<Record<string, any>>, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void;
|
|
93
96
|
};
|
|
94
97
|
export {};
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Federation } from '../global';
|
|
2
|
+
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap } from '../type';
|
|
3
|
+
import { SyncWaterfallHook } from './hooks';
|
|
2
4
|
export declare function formatShare(shareArgs: ShareArgs, from: string): Shared;
|
|
3
5
|
export declare function formatShareConfigs(shareArgs: {
|
|
4
6
|
[pkgName: string]: ShareArgs;
|
|
5
7
|
}, from: string): ShareInfos;
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
8
|
+
export declare function getRegisteredShare(localShareScopeMap: ShareScopeMap, pkgName: string, shareInfo: ShareInfos[keyof ShareInfos], resolveShare: SyncWaterfallHook<{
|
|
9
|
+
shareScopeMap: ShareScopeMap;
|
|
10
|
+
scope: string;
|
|
11
|
+
pkgName: string;
|
|
12
|
+
version: string;
|
|
13
|
+
GlobalFederation: Federation;
|
|
14
|
+
resolver: () => Shared | undefined;
|
|
15
|
+
}>): Shared | void;
|
|
16
|
+
export declare function getGlobalShareScope(): GlobalShareScopeMap;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20231225073141",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"helpers": [
|
|
40
40
|
"./dist/helpers.cjs.d.ts"
|
|
41
41
|
],
|
|
42
|
-
"
|
|
43
|
-
"./dist/
|
|
42
|
+
"types": [
|
|
43
|
+
"./dist/types.cjs.d.ts"
|
|
44
44
|
]
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
48
|
+
"@module-federation/sdk": "0.0.0-next-20231225073141"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/dist/type.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/type/index";
|
|
File without changes
|
|
File without changes
|