@module-federation/runtime 0.1.11 → 0.1.13
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.esm.js +1 -1
- package/dist/index.cjs.js +482 -320
- package/dist/index.esm.js +485 -323
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +22 -6
- package/dist/share.esm.js +23 -7
- package/dist/src/core.d.ts +7 -95
- package/dist/src/remote/index.d.ts +91 -0
- package/dist/src/shared/index.d.ts +56 -0
- package/dist/src/type/plugin.d.ts +11 -1
- package/dist/src/utils/plugin.d.ts +1 -1
- package/dist/src/utils/share.d.ts +7 -2
- package/package.json +2 -2
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -190,7 +190,7 @@ function getGlobalFederationConstructor() {
|
|
|
190
190
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
191
191
|
if (isDebug) {
|
|
192
192
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
193
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
193
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.13";
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -697,11 +697,10 @@ function formatShare(shareArgs, from, name) {
|
|
|
697
697
|
strategy: shareArgs.strategy || 'version-first'
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
|
-
function formatShareConfigs(
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
700
|
+
function formatShareConfigs(globalOptions, userOptions) {
|
|
701
|
+
const shareArgs = userOptions.shared || {};
|
|
702
|
+
const from = userOptions.name;
|
|
703
|
+
const shareInfos = Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
705
704
|
const arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
706
705
|
res[pkgName] = res[pkgName] || [];
|
|
707
706
|
arrayShareArgs.forEach((shareConfig)=>{
|
|
@@ -709,6 +708,23 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
709
708
|
});
|
|
710
709
|
return res;
|
|
711
710
|
}, {});
|
|
711
|
+
const shared = _extends({}, globalOptions.shared);
|
|
712
|
+
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
713
|
+
if (!shared[shareKey]) {
|
|
714
|
+
shared[shareKey] = shareInfos[shareKey];
|
|
715
|
+
} else {
|
|
716
|
+
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
717
|
+
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
718
|
+
if (!isSameVersion) {
|
|
719
|
+
shared[shareKey].push(newUserSharedOptions);
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
return {
|
|
725
|
+
shared,
|
|
726
|
+
shareInfos
|
|
727
|
+
};
|
|
712
728
|
}
|
|
713
729
|
function versionLt(a, b) {
|
|
714
730
|
const transformInvalidVersion = (version)=>{
|
package/dist/share.esm.js
CHANGED
|
@@ -188,7 +188,7 @@ function getGlobalFederationConstructor() {
|
|
|
188
188
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
189
189
|
if (isDebug) {
|
|
190
190
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
191
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
191
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.13";
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -695,11 +695,10 @@ function formatShare(shareArgs, from, name) {
|
|
|
695
695
|
strategy: shareArgs.strategy || 'version-first'
|
|
696
696
|
});
|
|
697
697
|
}
|
|
698
|
-
function formatShareConfigs(
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
return Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
698
|
+
function formatShareConfigs(globalOptions, userOptions) {
|
|
699
|
+
const shareArgs = userOptions.shared || {};
|
|
700
|
+
const from = userOptions.name;
|
|
701
|
+
const shareInfos = Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
703
702
|
const arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
704
703
|
res[pkgName] = res[pkgName] || [];
|
|
705
704
|
arrayShareArgs.forEach((shareConfig)=>{
|
|
@@ -707,6 +706,23 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
707
706
|
});
|
|
708
707
|
return res;
|
|
709
708
|
}, {});
|
|
709
|
+
const shared = _extends({}, globalOptions.shared);
|
|
710
|
+
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
711
|
+
if (!shared[shareKey]) {
|
|
712
|
+
shared[shareKey] = shareInfos[shareKey];
|
|
713
|
+
} else {
|
|
714
|
+
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
715
|
+
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
716
|
+
if (!isSameVersion) {
|
|
717
|
+
shared[shareKey].push(newUserSharedOptions);
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
return {
|
|
723
|
+
shared,
|
|
724
|
+
shareInfos
|
|
725
|
+
};
|
|
710
726
|
}
|
|
711
727
|
function versionLt(a, b) {
|
|
712
728
|
const transformInvalidVersion = (version)=>{
|
|
@@ -854,4 +870,4 @@ function getTargetSharedOptions(options) {
|
|
|
854
870
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
855
871
|
}
|
|
856
872
|
|
|
857
|
-
export {
|
|
873
|
+
export { getBuilderId as A, isBrowserEnv as B, setGlobalFederationConstructor as C, DEFAULT_REMOTE_TYPE as D, getGlobalFederationInstance as E, getGlobalFederationConstructor as F, Global as G, setGlobalFederationInstance as H, registerGlobalPlugins as I, nativeGlobal as J, resetFederationGlobalInfo as K, getTargetSnapshotInfoByModuleInfo as L, globalLoading as a, DEFAULT_SCOPE 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, getInfoWithoutType as l, getPreloaded as m, setPreloaded as n, getRegisteredShare as o, arrayOptions as p, getGlobalSnapshotInfoByModuleInfo as q, addGlobalSnapshot as r, safeToString as s, setGlobalSnapshotInfoByModuleInfo as t, getGlobalSnapshot as u, formatShareConfigs as v, warn as w, getTargetSharedOptions as x, getGlobalShareScope as y, addUniqueItem as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { Module, ModuleOptions } from './module';
|
|
1
|
+
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions } from './type';
|
|
2
|
+
import { Module } from './module';
|
|
4
3
|
import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
|
|
5
|
-
import { Federation } from './global';
|
|
6
4
|
import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
pkgNameOrAlias: string;
|
|
10
|
-
expose: string;
|
|
11
|
-
remote: Remote;
|
|
12
|
-
options: Options;
|
|
13
|
-
origin: FederationHost;
|
|
14
|
-
remoteInfo: RemoteInfo;
|
|
15
|
-
remoteSnapshot?: ModuleInfo;
|
|
16
|
-
}
|
|
5
|
+
import { SharedHandler } from './shared';
|
|
6
|
+
import { RemoteHandler } from './remote';
|
|
17
7
|
export declare class FederationHost {
|
|
18
8
|
options: Options;
|
|
19
9
|
hooks: PluginSystem<{
|
|
@@ -27,12 +17,6 @@ export declare class FederationHost {
|
|
|
27
17
|
options: Options;
|
|
28
18
|
origin: FederationHost;
|
|
29
19
|
}], void>;
|
|
30
|
-
beforeRequest: AsyncWaterfallHook<{
|
|
31
|
-
id: string;
|
|
32
|
-
options: Options;
|
|
33
|
-
origin: FederationHost;
|
|
34
|
-
}>;
|
|
35
|
-
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
|
|
36
20
|
beforeInitContainer: AsyncWaterfallHook<{
|
|
37
21
|
shareScope: ShareScopeMap[string];
|
|
38
22
|
initScope: InitScope;
|
|
@@ -40,11 +24,6 @@ export declare class FederationHost {
|
|
|
40
24
|
remoteInfo: RemoteInfo;
|
|
41
25
|
origin: FederationHost;
|
|
42
26
|
}>;
|
|
43
|
-
initContainerShareScopeMap: AsyncWaterfallHook<{
|
|
44
|
-
shareScope: ShareScopeMap[string];
|
|
45
|
-
options: Options;
|
|
46
|
-
origin: FederationHost;
|
|
47
|
-
}>;
|
|
48
27
|
initContainer: AsyncWaterfallHook<{
|
|
49
28
|
shareScope: ShareScopeMap[string];
|
|
50
29
|
initScope: InitScope;
|
|
@@ -53,69 +32,13 @@ export declare class FederationHost {
|
|
|
53
32
|
remoteEntryExports: RemoteEntryExports;
|
|
54
33
|
origin: FederationHost;
|
|
55
34
|
}>;
|
|
56
|
-
onLoad: AsyncHook<[{
|
|
57
|
-
id: string;
|
|
58
|
-
expose: string;
|
|
59
|
-
pkgNameOrAlias: string;
|
|
60
|
-
remote: Remote;
|
|
61
|
-
options: ModuleOptions;
|
|
62
|
-
origin: FederationHost;
|
|
63
|
-
exposeModule: any;
|
|
64
|
-
exposeModuleFactory: any;
|
|
65
|
-
moduleInstance: Module;
|
|
66
|
-
}], void>;
|
|
67
|
-
handlePreloadModule: SyncHook<{
|
|
68
|
-
id: string;
|
|
69
|
-
name: string;
|
|
70
|
-
remote: Remote;
|
|
71
|
-
remoteSnapshot: ModuleInfo;
|
|
72
|
-
preloadConfig: PreloadRemoteArgs;
|
|
73
|
-
origin: FederationHost;
|
|
74
|
-
}, void>;
|
|
75
|
-
errorLoadRemote: AsyncHook<[{
|
|
76
|
-
id: string;
|
|
77
|
-
error: unknown;
|
|
78
|
-
from: 'build' | 'runtime';
|
|
79
|
-
origin: FederationHost;
|
|
80
|
-
}], unknown>;
|
|
81
|
-
beforeLoadShare: AsyncWaterfallHook<{
|
|
82
|
-
pkgName: string;
|
|
83
|
-
shareInfo?: Shared | undefined;
|
|
84
|
-
shared: Options['shared'];
|
|
85
|
-
origin: FederationHost;
|
|
86
|
-
}>;
|
|
87
|
-
loadShare: AsyncHook<[FederationHost, string, ShareInfos], false | void | Promise<false | void>>;
|
|
88
|
-
resolveShare: SyncWaterfallHook<{
|
|
89
|
-
shareScopeMap: ShareScopeMap;
|
|
90
|
-
scope: string;
|
|
91
|
-
pkgName: string;
|
|
92
|
-
version: string;
|
|
93
|
-
GlobalFederation: Federation;
|
|
94
|
-
resolver: () => Shared | undefined;
|
|
95
|
-
}>;
|
|
96
|
-
beforePreloadRemote: AsyncHook<{
|
|
97
|
-
preloadOps: Array<PreloadRemoteArgs>;
|
|
98
|
-
options: Options;
|
|
99
|
-
origin: FederationHost;
|
|
100
|
-
}, false | void | Promise<false | void>>;
|
|
101
|
-
generatePreloadAssets: AsyncHook<[{
|
|
102
|
-
origin: FederationHost;
|
|
103
|
-
preloadOptions: PreloadOptions[number];
|
|
104
|
-
remote: Remote;
|
|
105
|
-
remoteInfo: RemoteInfo;
|
|
106
|
-
remoteSnapshot: ModuleInfo;
|
|
107
|
-
globalSnapshot: GlobalModuleInfo;
|
|
108
|
-
}], Promise<PreloadAssets>>;
|
|
109
|
-
afterPreloadRemote: AsyncHook<{
|
|
110
|
-
preloadOps: Array<PreloadRemoteArgs>;
|
|
111
|
-
options: Options;
|
|
112
|
-
origin: FederationHost;
|
|
113
|
-
}, false | void | Promise<false | void>>;
|
|
114
35
|
}>;
|
|
115
36
|
version: string;
|
|
116
37
|
name: string;
|
|
117
38
|
moduleCache: Map<string, Module>;
|
|
118
39
|
snapshotHandler: SnapshotHandler;
|
|
40
|
+
sharedHandler: SharedHandler;
|
|
41
|
+
remoteHandler: RemoteHandler;
|
|
119
42
|
shareScopeMap: ShareScopeMap;
|
|
120
43
|
loaderHook: PluginSystem<{
|
|
121
44
|
getModuleInfo: SyncHook<[{
|
|
@@ -134,7 +57,6 @@ export declare class FederationHost {
|
|
|
134
57
|
fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
135
58
|
}>;
|
|
136
59
|
constructor(userOptions: UserOptions);
|
|
137
|
-
private _setGlobalShareScopeMap;
|
|
138
60
|
initOptions(userOptions: UserOptions): Options;
|
|
139
61
|
loadShare<T>(pkgName: string, extraOptions?: {
|
|
140
62
|
customShareInfo?: Partial<Shared>;
|
|
@@ -144,27 +66,17 @@ export declare class FederationHost {
|
|
|
144
66
|
customShareInfo?: Partial<Shared>;
|
|
145
67
|
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
146
68
|
}): () => T | never;
|
|
69
|
+
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
|
|
147
70
|
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module;
|
|
148
|
-
private _getRemoteModuleAndOptions;
|
|
149
71
|
loadRemote<T>(id: string, options?: {
|
|
150
72
|
loadFactory?: boolean;
|
|
151
73
|
from: 'build' | 'runtime';
|
|
152
74
|
}): Promise<T | null>;
|
|
153
75
|
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* This function initializes the sharing sequence (executed only once per share scope).
|
|
156
|
-
* It accepts one argument, the name of the share scope.
|
|
157
|
-
* If the share scope does not exist, it creates one.
|
|
158
|
-
*/
|
|
159
|
-
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
|
|
160
76
|
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string]): void;
|
|
161
77
|
private formatOptions;
|
|
162
78
|
registerPlugins(plugins: UserOptions['plugins']): void;
|
|
163
|
-
private setShared;
|
|
164
|
-
private removeRemote;
|
|
165
|
-
private registerRemote;
|
|
166
79
|
registerRemotes(remotes: Remote[], options?: {
|
|
167
80
|
force?: boolean;
|
|
168
81
|
}): void;
|
|
169
82
|
}
|
|
170
|
-
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type ModuleInfo, type GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
+
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo } from '../type';
|
|
3
|
+
import { FederationHost } from '../core';
|
|
4
|
+
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook } from '../utils/hooks';
|
|
5
|
+
import { Module, ModuleOptions } from '../module';
|
|
6
|
+
export interface LoadRemoteMatch {
|
|
7
|
+
id: string;
|
|
8
|
+
pkgNameOrAlias: string;
|
|
9
|
+
expose: string;
|
|
10
|
+
remote: Remote;
|
|
11
|
+
options: Options;
|
|
12
|
+
origin: FederationHost;
|
|
13
|
+
remoteInfo: RemoteInfo;
|
|
14
|
+
remoteSnapshot?: ModuleInfo;
|
|
15
|
+
}
|
|
16
|
+
export declare class RemoteHandler {
|
|
17
|
+
host: FederationHost;
|
|
18
|
+
hooks: PluginSystem<{
|
|
19
|
+
beforeRequest: AsyncWaterfallHook<{
|
|
20
|
+
id: string;
|
|
21
|
+
options: Options;
|
|
22
|
+
origin: FederationHost;
|
|
23
|
+
}>;
|
|
24
|
+
onLoad: AsyncHook<[{
|
|
25
|
+
id: string;
|
|
26
|
+
expose: string;
|
|
27
|
+
pkgNameOrAlias: string;
|
|
28
|
+
remote: Remote;
|
|
29
|
+
options: ModuleOptions;
|
|
30
|
+
origin: FederationHost;
|
|
31
|
+
exposeModule: any;
|
|
32
|
+
exposeModuleFactory: any;
|
|
33
|
+
moduleInstance: Module;
|
|
34
|
+
}], void>;
|
|
35
|
+
handlePreloadModule: SyncHook<{
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
remote: Remote;
|
|
39
|
+
remoteSnapshot: ModuleInfo;
|
|
40
|
+
preloadConfig: PreloadRemoteArgs;
|
|
41
|
+
origin: FederationHost;
|
|
42
|
+
}, void>;
|
|
43
|
+
errorLoadRemote: AsyncHook<[{
|
|
44
|
+
id: string;
|
|
45
|
+
error: unknown;
|
|
46
|
+
options?: any;
|
|
47
|
+
from: 'build' | 'runtime';
|
|
48
|
+
lifecycle: 'onLoad' | 'beforeRequest';
|
|
49
|
+
origin: FederationHost;
|
|
50
|
+
}], unknown>;
|
|
51
|
+
beforePreloadRemote: AsyncHook<{
|
|
52
|
+
preloadOps: Array<PreloadRemoteArgs>;
|
|
53
|
+
options: Options;
|
|
54
|
+
origin: FederationHost;
|
|
55
|
+
}, false | void | Promise<false | void>>;
|
|
56
|
+
generatePreloadAssets: AsyncHook<[{
|
|
57
|
+
origin: FederationHost;
|
|
58
|
+
preloadOptions: PreloadOptions[number];
|
|
59
|
+
remote: Remote;
|
|
60
|
+
remoteInfo: RemoteInfo;
|
|
61
|
+
remoteSnapshot: ModuleInfo;
|
|
62
|
+
globalSnapshot: GlobalModuleInfo;
|
|
63
|
+
}], Promise<PreloadAssets>>;
|
|
64
|
+
afterPreloadRemote: AsyncHook<{
|
|
65
|
+
preloadOps: Array<PreloadRemoteArgs>;
|
|
66
|
+
options: Options;
|
|
67
|
+
origin: FederationHost;
|
|
68
|
+
}, false | void | Promise<false | void>>;
|
|
69
|
+
}>;
|
|
70
|
+
constructor(host: FederationHost);
|
|
71
|
+
formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
|
|
72
|
+
loadRemote<T>(id: string, options?: {
|
|
73
|
+
loadFactory?: boolean;
|
|
74
|
+
from: 'build' | 'runtime';
|
|
75
|
+
}): Promise<T | null>;
|
|
76
|
+
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
77
|
+
registerRemotes(remotes: Remote[], options?: {
|
|
78
|
+
force?: boolean;
|
|
79
|
+
}): void;
|
|
80
|
+
getRemoteModuleAndOptions(options: {
|
|
81
|
+
id: string;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
module: Module;
|
|
84
|
+
moduleOptions: ModuleOptions;
|
|
85
|
+
remoteMatchInfo: LoadRemoteMatch;
|
|
86
|
+
}>;
|
|
87
|
+
registerRemote(remote: Remote, targetRemotes: Remote[], options?: {
|
|
88
|
+
force?: boolean;
|
|
89
|
+
}): void;
|
|
90
|
+
private removeRemote;
|
|
91
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Federation } from '../global';
|
|
2
|
+
import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions } from '../type';
|
|
3
|
+
import { FederationHost } from '../core';
|
|
4
|
+
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncWaterfallHook } from '../utils/hooks';
|
|
5
|
+
import { LoadRemoteMatch } from '../remote';
|
|
6
|
+
export declare class SharedHandler {
|
|
7
|
+
host: FederationHost;
|
|
8
|
+
shareScopeMap: ShareScopeMap;
|
|
9
|
+
hooks: PluginSystem<{
|
|
10
|
+
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
|
|
11
|
+
beforeLoadShare: AsyncWaterfallHook<{
|
|
12
|
+
pkgName: string;
|
|
13
|
+
shareInfo?: Shared | undefined;
|
|
14
|
+
shared: Options['shared'];
|
|
15
|
+
origin: FederationHost;
|
|
16
|
+
}>;
|
|
17
|
+
loadShare: AsyncHook<[FederationHost, string, ShareInfos], false | void | Promise<false | void>>;
|
|
18
|
+
resolveShare: SyncWaterfallHook<{
|
|
19
|
+
shareScopeMap: ShareScopeMap;
|
|
20
|
+
scope: string;
|
|
21
|
+
pkgName: string;
|
|
22
|
+
version: string;
|
|
23
|
+
GlobalFederation: Federation;
|
|
24
|
+
resolver: () => Shared | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
initContainerShareScopeMap: AsyncWaterfallHook<{
|
|
27
|
+
shareScope: ShareScopeMap[string];
|
|
28
|
+
options: Options;
|
|
29
|
+
origin: FederationHost;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
constructor(host: FederationHost);
|
|
33
|
+
registerShared(globalOptions: Options, userOptions: UserOptions): {
|
|
34
|
+
shareInfos: ShareInfos;
|
|
35
|
+
shared: {
|
|
36
|
+
[x: string]: Shared[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
loadShare<T>(pkgName: string, extraOptions?: {
|
|
40
|
+
customShareInfo?: Partial<Shared>;
|
|
41
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
42
|
+
}): Promise<false | (() => T | undefined)>;
|
|
43
|
+
/**
|
|
44
|
+
* This function initializes the sharing sequence (executed only once per share scope).
|
|
45
|
+
* It accepts one argument, the name of the share scope.
|
|
46
|
+
* If the share scope does not exist, it creates one.
|
|
47
|
+
*/
|
|
48
|
+
initializeSharing(shareScopeName?: string, strategy?: Shared['strategy']): Array<Promise<void>>;
|
|
49
|
+
loadShareSync<T>(pkgName: string, extraOptions?: {
|
|
50
|
+
customShareInfo?: Partial<Shared>;
|
|
51
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
52
|
+
}): () => T | never;
|
|
53
|
+
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string]): void;
|
|
54
|
+
private setShared;
|
|
55
|
+
private _setGlobalShareScopeMap;
|
|
56
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FederationHost } from '../core';
|
|
2
2
|
import { Module } from '../module';
|
|
3
3
|
import { SnapshotHandler } from '../plugins/snapshot/SnapshotHandler';
|
|
4
|
+
import { SharedHandler } from '../shared';
|
|
5
|
+
import { RemoteHandler } from '../remote';
|
|
4
6
|
type CoreLifeCycle = FederationHost['hooks']['lifecycle'];
|
|
5
7
|
type CoreLifeCyclePartial = Partial<{
|
|
6
8
|
[k in keyof CoreLifeCycle]: Parameters<CoreLifeCycle[k]['on']>[0];
|
|
@@ -13,7 +15,15 @@ type ModuleLifeCycle = Module['host']['loaderHook']['lifecycle'];
|
|
|
13
15
|
type ModuleLifeCycleCyclePartial = Partial<{
|
|
14
16
|
[k in keyof ModuleLifeCycle]: Parameters<ModuleLifeCycle[k]['on']>[0];
|
|
15
17
|
}>;
|
|
16
|
-
|
|
18
|
+
type SharedLifeCycle = SharedHandler['hooks']['lifecycle'];
|
|
19
|
+
type SharedLifeCycleCyclePartial = Partial<{
|
|
20
|
+
[k in keyof SharedLifeCycle]: Parameters<SharedLifeCycle[k]['on']>[0];
|
|
21
|
+
}>;
|
|
22
|
+
type RemoteLifeCycle = RemoteHandler['hooks']['lifecycle'];
|
|
23
|
+
type RemoteLifeCycleCyclePartial = Partial<{
|
|
24
|
+
[k in keyof RemoteLifeCycle]: Parameters<RemoteLifeCycle[k]['on']>[0];
|
|
25
|
+
}>;
|
|
26
|
+
export type FederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & {
|
|
17
27
|
name: string;
|
|
18
28
|
version?: string;
|
|
19
29
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FederationHost } from '../core';
|
|
2
2
|
import { UserOptions } from '../type';
|
|
3
3
|
import { Module } from '../module';
|
|
4
|
-
export declare function registerPlugins(plugins: UserOptions['plugins'], hookInstances: Array<FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | Module['host']['loaderHook']>): import("../type").FederationRuntimePlugin[] | undefined;
|
|
4
|
+
export declare function registerPlugins(plugins: UserOptions['plugins'], hookInstances: Array<FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | FederationHost['sharedHandler']['hooks'] | FederationHost['remoteHandler']['hooks'] | Module['host']['loaderHook']>): import("../type").FederationRuntimePlugin[] | undefined;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Federation } from '../global';
|
|
2
|
-
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap, LoadShareExtraOptions, UserOptions } from '../type';
|
|
2
|
+
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap, LoadShareExtraOptions, UserOptions, Options } from '../type';
|
|
3
3
|
import { SyncWaterfallHook } from './hooks';
|
|
4
4
|
export declare function formatShare(shareArgs: ShareArgs, from: string, name: string): Shared;
|
|
5
|
-
export declare function formatShareConfigs(
|
|
5
|
+
export declare function formatShareConfigs(globalOptions: Options, userOptions: UserOptions): {
|
|
6
|
+
shared: {
|
|
7
|
+
[x: string]: Shared[];
|
|
8
|
+
};
|
|
9
|
+
shareInfos: ShareInfos;
|
|
10
|
+
};
|
|
6
11
|
export declare function versionLt(a: string, b: string): boolean;
|
|
7
12
|
export declare const findVersion: (shareVersionMap: ShareScopeMap[string][string], cb?: ((prev: string, cur: string) => boolean) | undefined) => string;
|
|
8
13
|
export declare const isLoaded: (shared: Shared) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@module-federation/sdk": "0.1.
|
|
48
|
+
"@module-federation/sdk": "0.1.13"
|
|
49
49
|
}
|
|
50
50
|
}
|