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