@ice/mf-runtime 0.0.8-beta.3 → 0.0.8-beta.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/index.d.ts +1 -0
- package/es2017/index.js +26 -0
- package/es2017/mf-global-store.js +4 -3
- package/esm/index.d.ts +1 -0
- package/esm/index.js +26 -0
- package/esm/mf-global-store.js +4 -3
- package/package.json +3 -2
package/es2017/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { loadRemote, registerPlugins } from '@module-federation/runtime';
|
|
|
3
3
|
export * from './FallBack';
|
|
4
4
|
export * from './RemoteModule';
|
|
5
5
|
export declare function init(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
|
6
|
+
export declare function initByMicroMods(microMods: MicroMod[]): void;
|
package/es2017/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBasename } from '@ice/stark-app';
|
|
1
2
|
import { registerPlugins, init as mfInit } from '@module-federation/runtime';
|
|
2
3
|
import { runtimePlugin } from './runtime-plugin';
|
|
3
4
|
import { initGlobalStore } from './mf-global-store';
|
|
@@ -11,3 +12,28 @@ export function init(options, microMods) {
|
|
|
11
12
|
runtimePlugin()
|
|
12
13
|
]);
|
|
13
14
|
}
|
|
15
|
+
// 需要一个稳定的,微应用唯一的 ID
|
|
16
|
+
function generateUniqueId() {
|
|
17
|
+
const prefix = 'ice_standard';
|
|
18
|
+
const baseName = getBasename().split('/').join('_');
|
|
19
|
+
return `${prefix}_${baseName}`;
|
|
20
|
+
}
|
|
21
|
+
export function initByMicroMods(microMods) {
|
|
22
|
+
const remotes = microMods.map((microMod)=>{
|
|
23
|
+
var _microMod_remoteEntry;
|
|
24
|
+
const isLegacy = !((_microMod_remoteEntry = microMod.remoteEntry) === null || _microMod_remoteEntry === void 0 ? void 0 : _microMod_remoteEntry.match(/\/mf\/remoteEntry\.js$/));
|
|
25
|
+
const remote = {
|
|
26
|
+
name: microMod.moduleFederatedName,
|
|
27
|
+
entry: microMod.remoteEntry,
|
|
28
|
+
alias: microMod.appName,
|
|
29
|
+
extraInfo: Object.assign(microMod.extraInfo || {}, {
|
|
30
|
+
legacy: isLegacy
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
return remote;
|
|
34
|
+
});
|
|
35
|
+
init({
|
|
36
|
+
remotes,
|
|
37
|
+
name: generateUniqueId()
|
|
38
|
+
}, microMods);
|
|
39
|
+
}
|
|
@@ -3,13 +3,13 @@ export function getCurrentModuleName() {
|
|
|
3
3
|
return (_window___MF_GLOBAL_STORE__ = window.__MF_GLOBAL_STORE__) === null || _window___MF_GLOBAL_STORE__ === void 0 ? void 0 : _window___MF_GLOBAL_STORE__.currentModuleName;
|
|
4
4
|
}
|
|
5
5
|
export function getMicroMod(scope) {
|
|
6
|
-
var _microMods;
|
|
6
|
+
var _store_microMods, _microMods;
|
|
7
7
|
const store = window.__MF_GLOBAL_STORE__;
|
|
8
8
|
const currentModuleName = getCurrentModuleName();
|
|
9
9
|
if (!currentModuleName) {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
|
-
const microMods = store.microMods.get(currentModuleName);
|
|
12
|
+
const microMods = (_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName);
|
|
13
13
|
return (_microMods = microMods) === null || _microMods === void 0 ? void 0 : _microMods.find((microMod)=>microMod.appName === scope);
|
|
14
14
|
}
|
|
15
15
|
export function initGlobalStore(options, microMods) {
|
|
@@ -29,11 +29,12 @@ export function initGlobalStore(options, microMods) {
|
|
|
29
29
|
const store = window.__MF_GLOBAL_STORE__;
|
|
30
30
|
if (!window.getCurrentIceMicroMods) {
|
|
31
31
|
window.getCurrentIceMicroMods = ()=>{
|
|
32
|
+
var _store_microMods;
|
|
32
33
|
const currentModuleName = getCurrentModuleName();
|
|
33
34
|
if (!currentModuleName) {
|
|
34
35
|
return [];
|
|
35
36
|
}
|
|
36
|
-
return store.microMods.get(currentModuleName) || [];
|
|
37
|
+
return ((_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName)) || [];
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
// 获取或创建 hostInfo
|
package/esm/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { loadRemote, registerPlugins } from '@module-federation/runtime';
|
|
|
3
3
|
export * from './FallBack';
|
|
4
4
|
export * from './RemoteModule';
|
|
5
5
|
export declare function init(options: ExtendedUserOptions, microMods?: MicroMod[]): void;
|
|
6
|
+
export declare function initByMicroMods(microMods: MicroMod[]): void;
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBasename } from "@ice/stark-app";
|
|
1
2
|
import { registerPlugins, init as mfInit } from "@module-federation/runtime";
|
|
2
3
|
import { runtimePlugin } from "./runtime-plugin";
|
|
3
4
|
import { initGlobalStore } from "./mf-global-store";
|
|
@@ -11,3 +12,28 @@ export function init(options, microMods) {
|
|
|
11
12
|
runtimePlugin()
|
|
12
13
|
]);
|
|
13
14
|
}
|
|
15
|
+
// 需要一个稳定的,微应用唯一的 ID
|
|
16
|
+
function generateUniqueId() {
|
|
17
|
+
var prefix = "ice_standard";
|
|
18
|
+
var baseName = getBasename().split("/").join("_");
|
|
19
|
+
return "".concat(prefix, "_").concat(baseName);
|
|
20
|
+
}
|
|
21
|
+
export function initByMicroMods(microMods) {
|
|
22
|
+
var remotes = microMods.map(function(microMod) {
|
|
23
|
+
var _microMod_remoteEntry;
|
|
24
|
+
var isLegacy = !((_microMod_remoteEntry = microMod.remoteEntry) === null || _microMod_remoteEntry === void 0 ? void 0 : _microMod_remoteEntry.match(/\/mf\/remoteEntry\.js$/));
|
|
25
|
+
var remote = {
|
|
26
|
+
name: microMod.moduleFederatedName,
|
|
27
|
+
entry: microMod.remoteEntry,
|
|
28
|
+
alias: microMod.appName,
|
|
29
|
+
extraInfo: Object.assign(microMod.extraInfo || {}, {
|
|
30
|
+
legacy: isLegacy
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
return remote;
|
|
34
|
+
});
|
|
35
|
+
init({
|
|
36
|
+
remotes: remotes,
|
|
37
|
+
name: generateUniqueId()
|
|
38
|
+
}, microMods);
|
|
39
|
+
}
|
package/esm/mf-global-store.js
CHANGED
|
@@ -4,13 +4,13 @@ export function getCurrentModuleName() {
|
|
|
4
4
|
return (_window___MF_GLOBAL_STORE__ = window.__MF_GLOBAL_STORE__) === null || _window___MF_GLOBAL_STORE__ === void 0 ? void 0 : _window___MF_GLOBAL_STORE__.currentModuleName;
|
|
5
5
|
}
|
|
6
6
|
export function getMicroMod(scope) {
|
|
7
|
-
var _microMods;
|
|
7
|
+
var _store_microMods, _microMods;
|
|
8
8
|
var store = window.__MF_GLOBAL_STORE__;
|
|
9
9
|
var currentModuleName = getCurrentModuleName();
|
|
10
10
|
if (!currentModuleName) {
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
|
-
var microMods = store.microMods.get(currentModuleName);
|
|
13
|
+
var microMods = (_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName);
|
|
14
14
|
return (_microMods = microMods) === null || _microMods === void 0 ? void 0 : _microMods.find(function(microMod) {
|
|
15
15
|
return microMod.appName === scope;
|
|
16
16
|
});
|
|
@@ -32,11 +32,12 @@ export function initGlobalStore(options, microMods) {
|
|
|
32
32
|
var store = window.__MF_GLOBAL_STORE__;
|
|
33
33
|
if (!window.getCurrentIceMicroMods) {
|
|
34
34
|
window.getCurrentIceMicroMods = function() {
|
|
35
|
+
var _store_microMods;
|
|
35
36
|
var currentModuleName = getCurrentModuleName();
|
|
36
37
|
if (!currentModuleName) {
|
|
37
38
|
return [];
|
|
38
39
|
}
|
|
39
|
-
return store.microMods.get(currentModuleName) || [];
|
|
40
|
+
return ((_store_microMods = store.microMods) === null || _store_microMods === void 0 ? void 0 : _store_microMods.get(currentModuleName)) || [];
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
// 获取或创建 hostInfo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ice/mf-runtime",
|
|
3
|
-
"version": "0.0.8-beta.
|
|
3
|
+
"version": "0.0.8-beta.6",
|
|
4
4
|
"description": "ice mf runtime",
|
|
5
5
|
"files": [
|
|
6
6
|
"esm",
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
"registry": "https://registry.npmjs.org"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"react": "^16 || ^17 || ^18"
|
|
72
|
+
"react": "^16 || ^17 || ^18",
|
|
73
|
+
"@ice/stark-app": "^1.5.0"
|
|
73
74
|
},
|
|
74
75
|
"license": "MIT"
|
|
75
76
|
}
|