@ice/mf-runtime 0.0.5 → 0.0.6
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/es2017/mf-global-store.js +10 -2
- package/esm/mf-global-store.js +10 -2
- package/package.json +1 -1
|
@@ -6,7 +6,9 @@ export function initGlobalStore(options) {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
const store = window.__MF_GLOBAL_STORE__;
|
|
9
|
-
|
|
9
|
+
// 获取或创建 hostInfo
|
|
10
|
+
const existingHostInfo = store.hostRemotes.get(options.name);
|
|
11
|
+
const hostInfo = existingHostInfo || {
|
|
10
12
|
keys: new Set(),
|
|
11
13
|
nameKeyMap: new Map(),
|
|
12
14
|
conflictingModules: new Set()
|
|
@@ -23,10 +25,16 @@ export function initGlobalStore(options) {
|
|
|
23
25
|
hostName: options.name,
|
|
24
26
|
extraInfo: remote.extraInfo
|
|
25
27
|
};
|
|
28
|
+
// 如果已存在同名的 remote,先移除旧的信息
|
|
29
|
+
const existingKey = hostInfo.nameKeyMap.get(remote.name);
|
|
30
|
+
if (existingKey) {
|
|
31
|
+
hostInfo.keys.delete(existingKey);
|
|
32
|
+
store.remotes.delete(existingKey);
|
|
33
|
+
}
|
|
26
34
|
// 记录这个 host 使用的 remote key 和 name 到 key 的映射
|
|
27
35
|
hostInfo.keys.add(remoteKey);
|
|
28
36
|
hostInfo.nameKeyMap.set(remote.name, remoteKey);
|
|
29
|
-
//
|
|
37
|
+
// 检查是否与其他 host 的模块冲突
|
|
30
38
|
for (const [, info] of store.remotes.entries()){
|
|
31
39
|
if (info.name === remote.name && info.entry !== entry) {
|
|
32
40
|
console.warn(`[Module Federation] Remote module "${remote.name}" has multiple versions:`, `\nHost "${info.hostName}": ${info.entry}`, `\nHost "${options.name}": ${entry}`);
|
package/esm/mf-global-store.js
CHANGED
|
@@ -7,7 +7,9 @@ export function initGlobalStore(options) {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
var store = window.__MF_GLOBAL_STORE__;
|
|
10
|
-
|
|
10
|
+
// 获取或创建 hostInfo
|
|
11
|
+
var existingHostInfo = store.hostRemotes.get(options.name);
|
|
12
|
+
var hostInfo = existingHostInfo || {
|
|
11
13
|
keys: new Set(),
|
|
12
14
|
nameKeyMap: new Map(),
|
|
13
15
|
conflictingModules: new Set()
|
|
@@ -24,12 +26,18 @@ export function initGlobalStore(options) {
|
|
|
24
26
|
hostName: options.name,
|
|
25
27
|
extraInfo: remote.extraInfo
|
|
26
28
|
};
|
|
29
|
+
// 如果已存在同名的 remote,先移除旧的信息
|
|
30
|
+
var existingKey = hostInfo.nameKeyMap.get(remote.name);
|
|
31
|
+
if (existingKey) {
|
|
32
|
+
hostInfo.keys.delete(existingKey);
|
|
33
|
+
store.remotes.delete(existingKey);
|
|
34
|
+
}
|
|
27
35
|
// 记录这个 host 使用的 remote key 和 name 到 key 的映射
|
|
28
36
|
hostInfo.keys.add(remoteKey);
|
|
29
37
|
hostInfo.nameKeyMap.set(remote.name, remoteKey);
|
|
30
38
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
31
39
|
try {
|
|
32
|
-
//
|
|
40
|
+
// 检查是否与其他 host 的模块冲突
|
|
33
41
|
for(var _iterator = store.remotes.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
34
42
|
var _step_value = _sliced_to_array(_step.value, 2), info = _step_value[1];
|
|
35
43
|
if (info.name === remote.name && info.entry !== entry) {
|