@module-federation/runtime 0.0.0-next-20231222101023 → 0.0.0-next-20231225064454
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 +68 -137
- package/dist/index.esm.js +70 -136
- package/dist/package.json +2 -2
- package/dist/share.cjs.js +47 -70
- package/dist/share.esm.js +47 -70
- package/dist/src/core.d.ts +5 -15
- package/dist/src/global.d.ts +3 -2
- package/dist/src/helpers.d.ts +2 -2
- package/dist/src/index.d.ts +0 -1
- package/dist/src/module/index.d.ts +2 -4
- package/dist/src/type/config.d.ts +2 -5
- package/dist/src/utils/share.d.ts +3 -12
- package/dist/type.cjs.d.ts +1 -0
- package/package.json +4 -4
- package/dist/types.cjs.d.ts +0 -1
- /package/dist/{types.cjs.js → type.cjs.js} +0 -0
- /package/dist/{types.esm.js → type.esm.js} +0 -0
package/dist/share.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function getBuilderId() {
|
|
2
|
-
//@ts-ignore
|
|
3
2
|
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
4
3
|
}
|
|
5
4
|
function isDebugMode() {
|
|
@@ -42,7 +41,7 @@ function isRemoteInfoWithEntry(remote) {
|
|
|
42
41
|
return typeof remote.entry !== 'undefined';
|
|
43
42
|
}
|
|
44
43
|
function isPureRemoteEntry(remote) {
|
|
45
|
-
return remote.entry.
|
|
44
|
+
return !remote.entry.includes('.json') && remote.entry.includes('.js');
|
|
46
45
|
}
|
|
47
46
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
48
47
|
function safeToString(info) {
|
|
@@ -87,7 +86,7 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
87
86
|
}
|
|
88
87
|
return target;
|
|
89
88
|
}
|
|
90
|
-
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5;
|
|
89
|
+
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5, _nativeGlobal___FEDERATION__6;
|
|
91
90
|
// export const nativeGlobal: typeof global = new Function('return this')();
|
|
92
91
|
const nativeGlobal = new Function('return this')();
|
|
93
92
|
// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.
|
|
@@ -110,6 +109,7 @@ if (nativeGlobal.__VMOK__) {
|
|
|
110
109
|
moduleInfo: {},
|
|
111
110
|
__SHARE__: {},
|
|
112
111
|
__MANIFEST_LOADING__: {},
|
|
112
|
+
__SHARE_SCOPE_LOADING__: {},
|
|
113
113
|
__PRELOADED_MAP__: new Map()
|
|
114
114
|
};
|
|
115
115
|
nativeGlobal.__VMOK__ = nativeGlobal.__FEDERATION__;
|
|
@@ -124,8 +124,10 @@ 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__ = {};
|
|
127
129
|
var ___PRELOADED_MAP__;
|
|
128
|
-
(___PRELOADED_MAP__ = (
|
|
130
|
+
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__6 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__6.__PRELOADED_MAP__ = new Map();
|
|
129
131
|
const Global = {
|
|
130
132
|
get __FEDERATION__ () {
|
|
131
133
|
const globalThisVal = new Function('return globalThis')();
|
|
@@ -138,6 +140,7 @@ function resetFederationGlobalInfo() {
|
|
|
138
140
|
nativeGlobal.__FEDERATION__.moduleInfo = {};
|
|
139
141
|
nativeGlobal.__FEDERATION__.__SHARE__ = {};
|
|
140
142
|
nativeGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
143
|
+
nativeGlobal.__FEDERATION__.__SHARE_SCOPE_LOADING__ = {};
|
|
141
144
|
}
|
|
142
145
|
function getGlobalFederationInstance(name, version) {
|
|
143
146
|
const buildId = getBuilderId();
|
|
@@ -620,7 +623,6 @@ function formatShare(shareArgs, from) {
|
|
|
620
623
|
loading: null
|
|
621
624
|
}, shareArgs, {
|
|
622
625
|
get,
|
|
623
|
-
loaded: 'lib' in shareArgs ? true : undefined,
|
|
624
626
|
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [
|
|
625
627
|
'default'
|
|
626
628
|
],
|
|
@@ -637,26 +639,15 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
637
639
|
}, {});
|
|
638
640
|
}
|
|
639
641
|
function versionLt(a, b) {
|
|
640
|
-
|
|
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)}`)) {
|
|
642
|
+
if (satisfy(a, `<=${b}`)) {
|
|
653
643
|
return true;
|
|
654
644
|
} else {
|
|
655
645
|
return false;
|
|
656
646
|
}
|
|
657
647
|
}
|
|
658
|
-
const findVersion = (
|
|
659
|
-
const
|
|
648
|
+
const findVersion = (scope, pkgName, cb)=>{
|
|
649
|
+
const globalShares = Global.__FEDERATION__.__SHARE__;
|
|
650
|
+
const versions = globalShares[scope][pkgName];
|
|
660
651
|
const callback = cb || function(prev, cur) {
|
|
661
652
|
return versionLt(prev, cur);
|
|
662
653
|
};
|
|
@@ -667,22 +658,20 @@ const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
|
|
|
667
658
|
if (callback(prev, cur)) {
|
|
668
659
|
return cur;
|
|
669
660
|
}
|
|
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
|
-
}
|
|
674
661
|
return prev;
|
|
675
662
|
}, 0);
|
|
676
663
|
};
|
|
677
|
-
function findSingletonVersionOrderByVersion(
|
|
678
|
-
const
|
|
664
|
+
function findSingletonVersionOrderByVersion(scope, pkgName) {
|
|
665
|
+
const globalShares = Global.__FEDERATION__.__SHARE__;
|
|
666
|
+
const versions = globalShares[scope][pkgName];
|
|
679
667
|
const callback = function(prev, cur) {
|
|
680
668
|
return !versions[prev].loaded && versionLt(prev, cur);
|
|
681
669
|
};
|
|
682
|
-
return findVersion(
|
|
670
|
+
return findVersion(scope, pkgName, callback);
|
|
683
671
|
}
|
|
684
|
-
function findSingletonVersionOrderByLoaded(
|
|
685
|
-
const
|
|
672
|
+
function findSingletonVersionOrderByLoaded(scope, pkgName) {
|
|
673
|
+
const globalShares = Global.__FEDERATION__.__SHARE__;
|
|
674
|
+
const versions = globalShares[scope][pkgName];
|
|
686
675
|
const callback = function(prev, cur) {
|
|
687
676
|
if (versions[cur].loaded) {
|
|
688
677
|
if (versions[prev].loaded) {
|
|
@@ -696,57 +685,45 @@ function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
|
696
685
|
}
|
|
697
686
|
return versionLt(prev, cur);
|
|
698
687
|
};
|
|
699
|
-
return findVersion(
|
|
700
|
-
}
|
|
701
|
-
function getFindShareFunction(strategy) {
|
|
702
|
-
if (strategy === 'loaded-first') {
|
|
703
|
-
return findSingletonVersionOrderByLoaded;
|
|
704
|
-
}
|
|
705
|
-
return findSingletonVersionOrderByVersion;
|
|
688
|
+
return findVersion(scope, pkgName, callback);
|
|
706
689
|
}
|
|
707
690
|
// Details about shared resources
|
|
708
691
|
// TODO: Implement strictVersion for alignment with module federation.
|
|
709
|
-
function
|
|
710
|
-
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
692
|
+
function getGlobalShare(pkgName, shareInfo) {
|
|
693
|
+
const globalShares = Global.__FEDERATION__.__SHARE__;
|
|
713
694
|
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
714
695
|
const scopes = Array.isArray(scope) ? scope : [
|
|
715
696
|
scope
|
|
716
697
|
];
|
|
717
698
|
for (const sc of scopes){
|
|
718
|
-
if (shareConfig &&
|
|
699
|
+
if (shareConfig && globalShares[sc] && globalShares[sc][pkgName]) {
|
|
719
700
|
const { requiredVersion } = shareConfig;
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
if (
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
701
|
+
// eslint-disable-next-line max-depth
|
|
702
|
+
if (shareConfig.singleton) {
|
|
703
|
+
const singletonVersion = strategy === 'loaded-first' ? findSingletonVersionOrderByLoaded(sc, pkgName) : findSingletonVersionOrderByVersion(sc, pkgName);
|
|
704
|
+
// eslint-disable-next-line max-depth
|
|
705
|
+
if (typeof requiredVersion === 'string' && !satisfy(singletonVersion, requiredVersion)) {
|
|
706
|
+
warn(`Version ${singletonVersion} from ${singletonVersion && globalShares[sc][pkgName][singletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`);
|
|
707
|
+
}
|
|
708
|
+
return globalShares[sc][pkgName][singletonVersion];
|
|
709
|
+
} else {
|
|
710
|
+
const maxVersion = findSingletonVersionOrderByLoaded(sc, pkgName);
|
|
711
|
+
// eslint-disable-next-line max-depth
|
|
712
|
+
if (requiredVersion === false || requiredVersion === '*') {
|
|
713
|
+
return globalShares[sc][pkgName][maxVersion];
|
|
714
|
+
}
|
|
715
|
+
// eslint-disable-next-line max-depth
|
|
716
|
+
if (satisfy(maxVersion, requiredVersion)) {
|
|
717
|
+
return globalShares[sc][pkgName][maxVersion];
|
|
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;
|
|
737
724
|
}
|
|
738
725
|
}
|
|
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();
|
|
726
|
+
}
|
|
750
727
|
}
|
|
751
728
|
}
|
|
752
729
|
}
|
|
@@ -754,4 +731,4 @@ function getGlobalShareScope() {
|
|
|
754
731
|
return Global.__FEDERATION__.__SHARE__;
|
|
755
732
|
}
|
|
756
733
|
|
|
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,
|
|
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, getGlobalShare as l, getInfoWithoutType as m, getPreloaded as n, setPreloaded as o, getGlobalSnapshotInfoByModuleInfo as p, setGlobalSnapshotInfoByModuleInfo as q, getGlobalSnapshot as r, safeToString as s, addUniqueItem as t, formatShareConfigs as u, isBrowserEnv as v, warn as w, getGlobalShareScope as x, getBuilderId as y, setGlobalFederationConstructor as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { Options, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, Shared, ShareInfos, UserOptions, RemoteInfo
|
|
2
|
+
import { Options, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, Shared, ShareInfos, UserOptions, RemoteInfo } 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';
|
|
6
5
|
import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
|
|
7
6
|
interface LoadRemoteMatch {
|
|
8
7
|
id: string;
|
|
@@ -61,14 +60,6 @@ export declare class FederationHost {
|
|
|
61
60
|
origin: FederationHost;
|
|
62
61
|
}>;
|
|
63
62
|
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
|
-
}>;
|
|
72
63
|
beforePreloadRemote: AsyncHook<{
|
|
73
64
|
preloadOps: Array<PreloadRemoteArgs>;
|
|
74
65
|
options: Options;
|
|
@@ -88,12 +79,10 @@ export declare class FederationHost {
|
|
|
88
79
|
origin: FederationHost;
|
|
89
80
|
}, false | void | Promise<false | void>>;
|
|
90
81
|
}>;
|
|
91
|
-
releaseNumber: string;
|
|
92
82
|
version: string;
|
|
93
83
|
name: string;
|
|
94
84
|
moduleCache: Map<string, Module>;
|
|
95
85
|
snapshotHandler: SnapshotHandler;
|
|
96
|
-
shareScopeMap: ShareScopeMap;
|
|
97
86
|
loaderHook: PluginSystem<{
|
|
98
87
|
getModuleInfo: SyncHook<[{
|
|
99
88
|
target: Record<string, any>;
|
|
@@ -107,8 +96,10 @@ export declare class FederationHost {
|
|
|
107
96
|
}], void | HTMLScriptElement>;
|
|
108
97
|
fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
109
98
|
}>;
|
|
99
|
+
loadingShare: {
|
|
100
|
+
[key: string]: Promise<any>;
|
|
101
|
+
};
|
|
110
102
|
constructor(userOptions: UserOptions);
|
|
111
|
-
private _setGlobalShareScopeMap;
|
|
112
103
|
initOptions(userOptions: UserOptions): Options;
|
|
113
104
|
loadShare<T>(pkgName: string, customShareInfo?: Partial<Shared>): Promise<false | (() => T | undefined)>;
|
|
114
105
|
loadShareSync<T>(pkgName: string): () => T | never;
|
|
@@ -122,8 +113,7 @@ export declare class FederationHost {
|
|
|
122
113
|
* It accepts one argument, the name of the share scope.
|
|
123
114
|
* If the share scope does not exist, it creates one.
|
|
124
115
|
*/
|
|
125
|
-
initializeSharing(shareScopeName?: string
|
|
126
|
-
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string]): void;
|
|
116
|
+
initializeSharing(shareScopeName?: string): boolean | Promise<boolean>;
|
|
127
117
|
private formatOptions;
|
|
128
118
|
private registerPlugins;
|
|
129
119
|
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, GlobalShareScope, 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,8 +9,9 @@ export interface Federation {
|
|
|
9
9
|
moduleInfo: GlobalModuleInfo;
|
|
10
10
|
__DEBUG_CONSTRUCTOR__?: typeof FederationHost;
|
|
11
11
|
__INSTANCES__: Array<FederationHost>;
|
|
12
|
-
__SHARE__:
|
|
12
|
+
__SHARE__: GlobalShareScope;
|
|
13
13
|
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
|
|
14
|
+
__SHARE_SCOPE_LOADING__: Record<string, boolean | Promise<boolean>>;
|
|
14
15
|
__PRELOADED_MAP__: Map<string, boolean>;
|
|
15
16
|
}
|
|
16
17
|
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 { getGlobalShare, getGlobalShareScope } from './utils/share';
|
|
4
4
|
interface IShareUtils {
|
|
5
|
-
|
|
5
|
+
getGlobalShare: typeof getGlobalShare;
|
|
6
6
|
getGlobalShareScope: typeof getGlobalShareScope;
|
|
7
7
|
}
|
|
8
8
|
interface IGlobalUtils {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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';
|
|
6
5
|
export type { Federation } from './global';
|
|
7
6
|
export declare function init(options: UserOptions): FederationHost;
|
|
8
7
|
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
|
|
2
|
+
import { RemoteEntryExports, Options, Remote, ShareInfos, RemoteInfo } from '../type';
|
|
3
3
|
export type ModuleOptions = ConstructorParameters<typeof Module>[0];
|
|
4
4
|
type HostInfo = Remote;
|
|
5
5
|
declare class Module {
|
|
@@ -10,14 +10,12 @@ declare class Module {
|
|
|
10
10
|
remoteEntryExports?: RemoteEntryExports;
|
|
11
11
|
lib: RemoteEntryExports | undefined;
|
|
12
12
|
loaderHook: FederationHost['loaderHook'];
|
|
13
|
-
|
|
14
|
-
constructor({ hostInfo, remoteInfo, shared, loaderHook, shareScopeMap, }: {
|
|
13
|
+
constructor({ hostInfo, remoteInfo, shared, loaderHook, }: {
|
|
15
14
|
hostInfo: HostInfo;
|
|
16
15
|
remoteInfo: RemoteInfo;
|
|
17
16
|
shared: ShareInfos;
|
|
18
17
|
plugins: Options['plugins'];
|
|
19
18
|
loaderHook: FederationHost['loaderHook'];
|
|
20
|
-
shareScopeMap: ShareScopeMap;
|
|
21
19
|
});
|
|
22
20
|
getEntry(): Promise<RemoteEntryExports>;
|
|
23
21
|
get(expose: string, options?: {
|
|
@@ -57,16 +57,13 @@ export type Shared = {
|
|
|
57
57
|
eager?: boolean;
|
|
58
58
|
strategy: 'version-first' | 'loaded-first';
|
|
59
59
|
};
|
|
60
|
-
export type
|
|
60
|
+
export type GlobalShareScope = {
|
|
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
|
-
};
|
|
70
67
|
export type ShareInfos = {
|
|
71
68
|
[pkgName: string]: Shared;
|
|
72
69
|
};
|
|
@@ -92,6 +89,6 @@ export type RemoteEntryInitOptions = {
|
|
|
92
89
|
};
|
|
93
90
|
export type RemoteEntryExports = {
|
|
94
91
|
get: (id: string) => () => Promise<Module>;
|
|
95
|
-
init: (shareScope:
|
|
92
|
+
init: (shareScope: GlobalShareScope[string], initScope?: Array<Record<string, never>>, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void;
|
|
96
93
|
};
|
|
97
94
|
export {};
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap } from '../type';
|
|
3
|
-
import { SyncWaterfallHook } from './hooks';
|
|
1
|
+
import { GlobalShareScope, Shared, ShareArgs, ShareInfos } from '../type';
|
|
4
2
|
export declare function formatShare(shareArgs: ShareArgs, from: string): Shared;
|
|
5
3
|
export declare function formatShareConfigs(shareArgs: {
|
|
6
4
|
[pkgName: string]: ShareArgs;
|
|
7
5
|
}, from: string): ShareInfos;
|
|
8
|
-
export declare function
|
|
9
|
-
|
|
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;
|
|
6
|
+
export declare function getGlobalShare(pkgName: string, shareInfo: ShareInfos[keyof ShareInfos]): Shared | void;
|
|
7
|
+
export declare function getGlobalShareScope(): GlobalShareScope;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/type/index";
|
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-20231225064454",
|
|
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
|
+
"type": [
|
|
43
|
+
"./dist/type.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-20231225064454"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/dist/types.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/types";
|
|
File without changes
|
|
File without changes
|