@module-federation/runtime 0.0.6 → 0.0.8
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/README.md +513 -124
- package/dist/helpers.cjs.js +2 -1
- package/dist/helpers.esm.js +3 -2
- package/dist/index.cjs.js +208 -104
- package/dist/index.esm.js +207 -106
- package/dist/package.json +3 -3
- package/dist/share.cjs.js +147 -111
- package/dist/share.esm.js +147 -111
- package/dist/src/core.d.ts +39 -7
- package/dist/src/global.d.ts +3 -6
- package/dist/src/helpers.d.ts +4 -3
- package/dist/src/index.d.ts +3 -1
- package/dist/src/module/index.d.ts +4 -10
- package/dist/src/type/config.d.ts +8 -2
- package/dist/src/type/plugin.d.ts +1 -1
- package/dist/src/utils/plugin.d.ts +1 -1
- 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.cjs.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
function getBuilderId() {
|
|
4
|
+
//@ts-ignore
|
|
4
5
|
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
5
6
|
}
|
|
6
7
|
function isDebugMode() {
|
|
7
|
-
return Boolean(
|
|
8
|
+
return Boolean("");
|
|
8
9
|
}
|
|
9
10
|
function isBrowserEnv() {
|
|
10
11
|
return typeof window !== 'undefined';
|
|
@@ -88,69 +89,71 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
88
89
|
}
|
|
89
90
|
return target;
|
|
90
91
|
}
|
|
91
|
-
var _nativeGlobal___FEDERATION__, _nativeGlobal___FEDERATION__1, _nativeGlobal___FEDERATION__2, _nativeGlobal___FEDERATION__3, _nativeGlobal___FEDERATION__4, _nativeGlobal___FEDERATION__5, _nativeGlobal___FEDERATION__6;
|
|
92
92
|
// export const nativeGlobal: typeof global = new Function('return this')();
|
|
93
93
|
const nativeGlobal = new Function('return this')();
|
|
94
|
+
const Global = nativeGlobal;
|
|
95
|
+
function definePropertyGlobalVal(target, key, val) {
|
|
96
|
+
Object.defineProperty(target, key, {
|
|
97
|
+
value: val,
|
|
98
|
+
configurable: false,
|
|
99
|
+
writable: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function includeOwnProperty(target, key) {
|
|
103
|
+
return Object.hasOwnProperty.call(target, key);
|
|
104
|
+
}
|
|
94
105
|
// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.
|
|
95
106
|
// The sandbox in the microfrontend does not replicate the value of 'configurable'.
|
|
96
107
|
// If there is no loading content on the global object, this section defines the loading object.
|
|
97
|
-
if (!
|
|
98
|
-
|
|
99
|
-
value: {},
|
|
100
|
-
configurable: false
|
|
101
|
-
});
|
|
108
|
+
if (!includeOwnProperty(globalThis, '__GLOBAL_LOADING_REMOTE_ENTRY__')) {
|
|
109
|
+
definePropertyGlobalVal(globalThis, '__GLOBAL_LOADING_REMOTE_ENTRY__', {});
|
|
102
110
|
}
|
|
103
111
|
const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
nativeGlobal.__FEDERATION__ = {
|
|
109
|
-
__GLOBAL_PLUGIN__: [],
|
|
110
|
-
__INSTANCES__: [],
|
|
111
|
-
moduleInfo: {},
|
|
112
|
-
__SHARE__: {},
|
|
113
|
-
__MANIFEST_LOADING__: {},
|
|
114
|
-
__SHARE_SCOPE_LOADING__: {},
|
|
115
|
-
__PRELOADED_MAP__: new Map()
|
|
116
|
-
};
|
|
117
|
-
nativeGlobal.__VMOK__ = nativeGlobal.__FEDERATION__;
|
|
118
|
-
}
|
|
119
|
-
var ___GLOBAL_PLUGIN__;
|
|
120
|
-
(___GLOBAL_PLUGIN__ = (_nativeGlobal___FEDERATION__ = nativeGlobal.__FEDERATION__).__GLOBAL_PLUGIN__) != null ? ___GLOBAL_PLUGIN__ : _nativeGlobal___FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
121
|
-
var ___INSTANCES__;
|
|
122
|
-
(___INSTANCES__ = (_nativeGlobal___FEDERATION__1 = nativeGlobal.__FEDERATION__).__INSTANCES__) != null ? ___INSTANCES__ : _nativeGlobal___FEDERATION__1.__INSTANCES__ = [];
|
|
123
|
-
var _moduleInfo;
|
|
124
|
-
(_moduleInfo = (_nativeGlobal___FEDERATION__2 = nativeGlobal.__FEDERATION__).moduleInfo) != null ? _moduleInfo : _nativeGlobal___FEDERATION__2.moduleInfo = {};
|
|
125
|
-
var ___SHARE__;
|
|
126
|
-
(___SHARE__ = (_nativeGlobal___FEDERATION__3 = nativeGlobal.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _nativeGlobal___FEDERATION__3.__SHARE__ = {};
|
|
127
|
-
var ___MANIFEST_LOADING__;
|
|
128
|
-
(___MANIFEST_LOADING__ = (_nativeGlobal___FEDERATION__4 = nativeGlobal.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _nativeGlobal___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
129
|
-
var ___SHARE_SCOPE_LOADING__;
|
|
130
|
-
(___SHARE_SCOPE_LOADING__ = (_nativeGlobal___FEDERATION__5 = nativeGlobal.__FEDERATION__).__SHARE_SCOPE_LOADING__) != null ? ___SHARE_SCOPE_LOADING__ : _nativeGlobal___FEDERATION__5.__SHARE_SCOPE_LOADING__ = {};
|
|
131
|
-
var ___PRELOADED_MAP__;
|
|
132
|
-
(___PRELOADED_MAP__ = (_nativeGlobal___FEDERATION__6 = nativeGlobal.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _nativeGlobal___FEDERATION__6.__PRELOADED_MAP__ = new Map();
|
|
133
|
-
const Global = {
|
|
134
|
-
get __FEDERATION__ () {
|
|
135
|
-
const globalThisVal = new Function('return globalThis')();
|
|
136
|
-
return globalThisVal.__FEDERATION__;
|
|
112
|
+
function setGlobalDefaultVal(target) {
|
|
113
|
+
var _target___FEDERATION__, _target___FEDERATION__1, _target___FEDERATION__2, _target___FEDERATION__3, _target___FEDERATION__4, _target___FEDERATION__5;
|
|
114
|
+
if (includeOwnProperty(target, '__VMOK__') && !includeOwnProperty(target, '__FEDERATION__')) {
|
|
115
|
+
definePropertyGlobalVal(target, '__FEDERATION__', target.__VMOK__);
|
|
137
116
|
}
|
|
138
|
-
|
|
117
|
+
if (!includeOwnProperty(target, '__FEDERATION__')) {
|
|
118
|
+
definePropertyGlobalVal(target, '__FEDERATION__', {
|
|
119
|
+
__GLOBAL_PLUGIN__: [],
|
|
120
|
+
__INSTANCES__: [],
|
|
121
|
+
moduleInfo: {},
|
|
122
|
+
__SHARE__: {},
|
|
123
|
+
__MANIFEST_LOADING__: {},
|
|
124
|
+
__PRELOADED_MAP__: new Map()
|
|
125
|
+
});
|
|
126
|
+
definePropertyGlobalVal(target, '__VMOK__', target.__FEDERATION__);
|
|
127
|
+
}
|
|
128
|
+
var ___GLOBAL_PLUGIN__;
|
|
129
|
+
(___GLOBAL_PLUGIN__ = (_target___FEDERATION__ = target.__FEDERATION__).__GLOBAL_PLUGIN__) != null ? ___GLOBAL_PLUGIN__ : _target___FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
130
|
+
var ___INSTANCES__;
|
|
131
|
+
(___INSTANCES__ = (_target___FEDERATION__1 = target.__FEDERATION__).__INSTANCES__) != null ? ___INSTANCES__ : _target___FEDERATION__1.__INSTANCES__ = [];
|
|
132
|
+
var _moduleInfo;
|
|
133
|
+
(_moduleInfo = (_target___FEDERATION__2 = target.__FEDERATION__).moduleInfo) != null ? _moduleInfo : _target___FEDERATION__2.moduleInfo = {};
|
|
134
|
+
var ___SHARE__;
|
|
135
|
+
(___SHARE__ = (_target___FEDERATION__3 = target.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _target___FEDERATION__3.__SHARE__ = {};
|
|
136
|
+
var ___MANIFEST_LOADING__;
|
|
137
|
+
(___MANIFEST_LOADING__ = (_target___FEDERATION__4 = target.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _target___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
138
|
+
var ___PRELOADED_MAP__;
|
|
139
|
+
(___PRELOADED_MAP__ = (_target___FEDERATION__5 = target.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _target___FEDERATION__5.__PRELOADED_MAP__ = new Map();
|
|
140
|
+
}
|
|
141
|
+
setGlobalDefaultVal(globalThis);
|
|
142
|
+
setGlobalDefaultVal(nativeGlobal);
|
|
139
143
|
function resetFederationGlobalInfo() {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
nativeGlobal.__FEDERATION__.__SHARE_SCOPE_LOADING__ = {};
|
|
144
|
+
globalThis.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
145
|
+
globalThis.__FEDERATION__.__INSTANCES__ = [];
|
|
146
|
+
globalThis.__FEDERATION__.moduleInfo = {};
|
|
147
|
+
globalThis.__FEDERATION__.__SHARE__ = {};
|
|
148
|
+
globalThis.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
146
149
|
}
|
|
147
150
|
function getGlobalFederationInstance(name, version) {
|
|
148
151
|
const buildId = getBuilderId();
|
|
149
|
-
return
|
|
152
|
+
return globalThis.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{
|
|
150
153
|
if (buildId && GMInstance.options.id === getBuilderId()) {
|
|
151
154
|
return true;
|
|
152
155
|
}
|
|
153
|
-
if (GMInstance.options.name === name && !version) {
|
|
156
|
+
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
|
154
157
|
return true;
|
|
155
158
|
}
|
|
156
159
|
if (GMInstance.options.name === name && version && GMInstance.options.version === version) {
|
|
@@ -160,15 +163,15 @@ function getGlobalFederationInstance(name, version) {
|
|
|
160
163
|
});
|
|
161
164
|
}
|
|
162
165
|
function setGlobalFederationInstance(FederationInstance) {
|
|
163
|
-
|
|
166
|
+
globalThis.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
164
167
|
}
|
|
165
168
|
function getGlobalFederationConstructor() {
|
|
166
|
-
return
|
|
169
|
+
return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
167
170
|
}
|
|
168
171
|
function setGlobalFederationConstructor(FederationConstructor) {
|
|
169
172
|
if (isDebugMode()) {
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
174
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -183,7 +186,7 @@ function getInfoWithoutType(target, key, getModuleInfoHook) {
|
|
|
183
186
|
}
|
|
184
187
|
return res;
|
|
185
188
|
}
|
|
186
|
-
const getGlobalSnapshot = ()=>
|
|
189
|
+
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
|
|
187
190
|
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot, getModuleInfoHook)=>{
|
|
188
191
|
// Check if the remote is included in the hostSnapshot
|
|
189
192
|
const moduleKey = getFMId(moduleInfo);
|
|
@@ -201,25 +204,25 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot, getModuleInfoHo
|
|
|
201
204
|
"version"
|
|
202
205
|
]);
|
|
203
206
|
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
204
|
-
const getModuleInfoWithoutVersion = getInfoWithoutType(
|
|
207
|
+
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value;
|
|
205
208
|
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
|
|
206
209
|
return getModuleInfoWithoutVersion;
|
|
207
210
|
}
|
|
208
211
|
}
|
|
209
212
|
return;
|
|
210
213
|
};
|
|
211
|
-
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo,
|
|
214
|
+
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook);
|
|
212
215
|
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
|
|
213
216
|
const moduleKey = getFMId(remoteInfo);
|
|
214
|
-
|
|
215
|
-
return
|
|
217
|
+
nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
|
|
218
|
+
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
216
219
|
};
|
|
217
220
|
const addGlobalSnapshot = (moduleInfos)=>{
|
|
218
|
-
|
|
221
|
+
nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
|
|
219
222
|
return ()=>{
|
|
220
223
|
const keys = Object.keys(moduleInfos);
|
|
221
224
|
for (const key of keys){
|
|
222
|
-
delete
|
|
225
|
+
delete nativeGlobal.__FEDERATION__.moduleInfo[key];
|
|
223
226
|
}
|
|
224
227
|
};
|
|
225
228
|
};
|
|
@@ -236,7 +239,7 @@ const getRemoteEntryExports = (name, globalName)=>{
|
|
|
236
239
|
// If a plugin is not registered, it is added to the global plugins.
|
|
237
240
|
// If a plugin is already registered, a warning message is logged.
|
|
238
241
|
const registerGlobalPlugins = (plugins)=>{
|
|
239
|
-
const { __GLOBAL_PLUGIN__ } =
|
|
242
|
+
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
240
243
|
plugins.forEach((plugin)=>{
|
|
241
244
|
if (__GLOBAL_PLUGIN__.findIndex((p)=>p.name === plugin.name) === -1) {
|
|
242
245
|
__GLOBAL_PLUGIN__.push(plugin);
|
|
@@ -245,9 +248,9 @@ const registerGlobalPlugins = (plugins)=>{
|
|
|
245
248
|
}
|
|
246
249
|
});
|
|
247
250
|
};
|
|
248
|
-
const getGlobalHostPlugins = ()=>
|
|
249
|
-
const getPreloaded = (id)=>
|
|
250
|
-
const setPreloaded = (id)=>
|
|
251
|
+
const getGlobalHostPlugins = ()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
|
|
252
|
+
const getPreloaded = (id)=>globalThis.__FEDERATION__.__PRELOADED_MAP__.get(id);
|
|
253
|
+
const setPreloaded = (id)=>globalThis.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
|
|
251
254
|
|
|
252
255
|
const DEFAULT_SCOPE = 'default';
|
|
253
256
|
const DEFAULT_REMOTE_TYPE = 'global';
|
|
@@ -617,14 +620,16 @@ function formatShare(shareArgs, from) {
|
|
|
617
620
|
deps: [],
|
|
618
621
|
useIn: [],
|
|
619
622
|
from,
|
|
620
|
-
shareConfig: {
|
|
621
|
-
requiredVersion: `^${shareArgs.version}`,
|
|
622
|
-
singleton: false,
|
|
623
|
-
eager: false
|
|
624
|
-
},
|
|
625
623
|
loading: null
|
|
626
624
|
}, shareArgs, {
|
|
625
|
+
shareConfig: _extends({
|
|
626
|
+
requiredVersion: `^${shareArgs.version}`,
|
|
627
|
+
singleton: false,
|
|
628
|
+
eager: false,
|
|
629
|
+
strictVersion: false
|
|
630
|
+
}, shareArgs.shareConfig),
|
|
627
631
|
get,
|
|
632
|
+
loaded: 'lib' in shareArgs ? true : undefined,
|
|
628
633
|
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [
|
|
629
634
|
'default'
|
|
630
635
|
],
|
|
@@ -641,15 +646,26 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
641
646
|
}, {});
|
|
642
647
|
}
|
|
643
648
|
function versionLt(a, b) {
|
|
644
|
-
|
|
649
|
+
const transformInvalidVersion = (version)=>{
|
|
650
|
+
const isNumberVersion = !Number.isNaN(Number(version));
|
|
651
|
+
if (isNumberVersion) {
|
|
652
|
+
const splitArr = version.split('.');
|
|
653
|
+
let validVersion = version;
|
|
654
|
+
for(let i = 0; i < 3 - splitArr.length; i++){
|
|
655
|
+
validVersion += '.0';
|
|
656
|
+
}
|
|
657
|
+
return validVersion;
|
|
658
|
+
}
|
|
659
|
+
return version;
|
|
660
|
+
};
|
|
661
|
+
if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) {
|
|
645
662
|
return true;
|
|
646
663
|
} else {
|
|
647
664
|
return false;
|
|
648
665
|
}
|
|
649
666
|
}
|
|
650
|
-
const findVersion = (scope, pkgName, cb)=>{
|
|
651
|
-
const
|
|
652
|
-
const versions = globalShares[scope][pkgName];
|
|
667
|
+
const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
|
|
668
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
653
669
|
const callback = cb || function(prev, cur) {
|
|
654
670
|
return versionLt(prev, cur);
|
|
655
671
|
};
|
|
@@ -660,20 +676,22 @@ const findVersion = (scope, pkgName, cb)=>{
|
|
|
660
676
|
if (callback(prev, cur)) {
|
|
661
677
|
return cur;
|
|
662
678
|
}
|
|
679
|
+
// default version is '0' https://github.com/webpack/webpack/blob/main/lib/sharing/ProvideSharedModule.js#L136
|
|
680
|
+
if (prev === '0') {
|
|
681
|
+
return cur;
|
|
682
|
+
}
|
|
663
683
|
return prev;
|
|
664
684
|
}, 0);
|
|
665
685
|
};
|
|
666
|
-
function findSingletonVersionOrderByVersion(scope, pkgName) {
|
|
667
|
-
const
|
|
668
|
-
const versions = globalShares[scope][pkgName];
|
|
686
|
+
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
|
|
687
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
669
688
|
const callback = function(prev, cur) {
|
|
670
689
|
return !versions[prev].loaded && versionLt(prev, cur);
|
|
671
690
|
};
|
|
672
|
-
return findVersion(scope, pkgName, callback);
|
|
691
|
+
return findVersion(shareScopeMap, scope, pkgName, callback);
|
|
673
692
|
}
|
|
674
|
-
function findSingletonVersionOrderByLoaded(scope, pkgName) {
|
|
675
|
-
const
|
|
676
|
-
const versions = globalShares[scope][pkgName];
|
|
693
|
+
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
694
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
677
695
|
const callback = function(prev, cur) {
|
|
678
696
|
if (versions[cur].loaded) {
|
|
679
697
|
if (versions[prev].loaded) {
|
|
@@ -687,45 +705,63 @@ function findSingletonVersionOrderByLoaded(scope, pkgName) {
|
|
|
687
705
|
}
|
|
688
706
|
return versionLt(prev, cur);
|
|
689
707
|
};
|
|
690
|
-
return findVersion(scope, pkgName, callback);
|
|
708
|
+
return findVersion(shareScopeMap, scope, pkgName, callback);
|
|
709
|
+
}
|
|
710
|
+
function getFindShareFunction(strategy) {
|
|
711
|
+
if (strategy === 'loaded-first') {
|
|
712
|
+
return findSingletonVersionOrderByLoaded;
|
|
713
|
+
}
|
|
714
|
+
return findSingletonVersionOrderByVersion;
|
|
691
715
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
716
|
+
function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
|
|
717
|
+
if (!localShareScopeMap) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
696
720
|
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
697
721
|
const scopes = Array.isArray(scope) ? scope : [
|
|
698
722
|
scope
|
|
699
723
|
];
|
|
700
724
|
for (const sc of scopes){
|
|
701
|
-
if (shareConfig &&
|
|
725
|
+
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
702
726
|
const { requiredVersion } = shareConfig;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
727
|
+
const findShareFunction = getFindShareFunction(strategy);
|
|
728
|
+
const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
|
|
729
|
+
//@ts-ignore
|
|
730
|
+
const defaultResolver = ()=>{
|
|
731
|
+
if (shareConfig.singleton) {
|
|
732
|
+
if (typeof requiredVersion === 'string' && !satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
733
|
+
const msg = `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})`;
|
|
734
|
+
if (shareConfig.strictVersion) {
|
|
735
|
+
error(msg);
|
|
736
|
+
} else {
|
|
737
|
+
warn(msg);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
741
|
+
} else {
|
|
742
|
+
if (requiredVersion === false || requiredVersion === '*') {
|
|
743
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
744
|
+
}
|
|
745
|
+
if (satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
746
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
747
|
+
}
|
|
748
|
+
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])){
|
|
749
|
+
if (satisfy(versionKey, requiredVersion)) {
|
|
750
|
+
return versionValue;
|
|
751
|
+
}
|
|
726
752
|
}
|
|
727
753
|
}
|
|
728
|
-
}
|
|
754
|
+
};
|
|
755
|
+
const params = {
|
|
756
|
+
shareScopeMap: localShareScopeMap,
|
|
757
|
+
scope: sc,
|
|
758
|
+
pkgName,
|
|
759
|
+
version: maxOrSingletonVersion,
|
|
760
|
+
GlobalFederation: Global.__FEDERATION__,
|
|
761
|
+
resolver: defaultResolver
|
|
762
|
+
};
|
|
763
|
+
const resolveShared = resolveShare.emit(params) || params;
|
|
764
|
+
return resolveShared.resolver();
|
|
729
765
|
}
|
|
730
766
|
}
|
|
731
767
|
}
|
|
@@ -746,12 +782,12 @@ exports.getFMId = getFMId;
|
|
|
746
782
|
exports.getGlobalFederationConstructor = getGlobalFederationConstructor;
|
|
747
783
|
exports.getGlobalFederationInstance = getGlobalFederationInstance;
|
|
748
784
|
exports.getGlobalHostPlugins = getGlobalHostPlugins;
|
|
749
|
-
exports.getGlobalShare = getGlobalShare;
|
|
750
785
|
exports.getGlobalShareScope = getGlobalShareScope;
|
|
751
786
|
exports.getGlobalSnapshot = getGlobalSnapshot;
|
|
752
787
|
exports.getGlobalSnapshotInfoByModuleInfo = getGlobalSnapshotInfoByModuleInfo;
|
|
753
788
|
exports.getInfoWithoutType = getInfoWithoutType;
|
|
754
789
|
exports.getPreloaded = getPreloaded;
|
|
790
|
+
exports.getRegisteredShare = getRegisteredShare;
|
|
755
791
|
exports.getRemoteEntryExports = getRemoteEntryExports;
|
|
756
792
|
exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo;
|
|
757
793
|
exports.globalLoading = globalLoading;
|