@module-federation/runtime 0.15.0 → 0.17.0
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 +1 -1
- package/dist/helpers.cjs.cjs +3 -4
- package/dist/helpers.esm.js +3 -4
- package/dist/index.cjs.cjs +25 -12
- package/dist/index.esm.js +25 -14
- package/dist/src/helpers.d.ts +4 -19
- package/dist/src/index.d.ts +16 -11
- package/dist/src/utils.d.ts +2 -2
- package/dist/utils.cjs.cjs +1 -1
- package/dist/utils.esm.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
|
9
|
-
See [https://module-federation.io/guide/basic/runtime.html](https://module-federation.io/guide/basic/runtime.html) for details.
|
|
9
|
+
See [https://module-federation.io/guide/basic/runtime/runtime.html](https://module-federation.io/guide/basic/runtime/runtime.html) for details.
|
|
10
10
|
|
|
11
11
|
## License
|
|
12
12
|
|
package/dist/helpers.cjs.cjs
CHANGED
|
@@ -4,11 +4,10 @@ var polyfills = require('./polyfills.cjs.cjs');
|
|
|
4
4
|
var runtimeCore = require('@module-federation/runtime-core');
|
|
5
5
|
var utils = require('./utils.cjs.cjs');
|
|
6
6
|
|
|
7
|
-
var helpers = {
|
|
7
|
+
var helpers = polyfills._extends({}, runtimeCore.helpers, {
|
|
8
8
|
global: polyfills._extends({}, runtimeCore.helpers.global, {
|
|
9
9
|
getGlobalFederationInstance: utils.getGlobalFederationInstance
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
};
|
|
10
|
+
})
|
|
11
|
+
});
|
|
13
12
|
|
|
14
13
|
module.exports = helpers;
|
package/dist/helpers.esm.js
CHANGED
|
@@ -2,11 +2,10 @@ import { _ as _extends } from './polyfills.esm.js';
|
|
|
2
2
|
import { helpers as helpers$1 } from '@module-federation/runtime-core';
|
|
3
3
|
import { g as getGlobalFederationInstance } from './utils.esm.js';
|
|
4
4
|
|
|
5
|
-
var helpers = {
|
|
5
|
+
var helpers = _extends({}, helpers$1, {
|
|
6
6
|
global: _extends({}, helpers$1.global, {
|
|
7
7
|
getGlobalFederationInstance
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
};
|
|
8
|
+
})
|
|
9
|
+
});
|
|
11
10
|
|
|
12
11
|
export { helpers as default };
|
package/dist/index.cjs.cjs
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var runtimeCore = require('@module-federation/runtime-core');
|
|
4
|
+
var errorCodes = require('@module-federation/error-codes');
|
|
4
5
|
var utils = require('./utils.cjs.cjs');
|
|
5
6
|
|
|
7
|
+
function createInstance(options) {
|
|
8
|
+
// Retrieve debug constructor
|
|
9
|
+
const ModuleFederationConstructor = runtimeCore.getGlobalFederationConstructor() || runtimeCore.ModuleFederation;
|
|
10
|
+
return new ModuleFederationConstructor(options);
|
|
11
|
+
}
|
|
6
12
|
let FederationInstance = null;
|
|
7
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use createInstance or getInstance instead
|
|
15
|
+
*/ function init(options) {
|
|
8
16
|
// Retrieve the same instance with the same name
|
|
9
17
|
const instance = utils.getGlobalFederationInstance(options.name, options.version);
|
|
10
18
|
if (!instance) {
|
|
11
|
-
|
|
12
|
-
const FederationConstructor = runtimeCore.getGlobalFederationConstructor() || runtimeCore.FederationHost;
|
|
13
|
-
FederationInstance = new FederationConstructor(options);
|
|
19
|
+
FederationInstance = createInstance(options);
|
|
14
20
|
runtimeCore.setGlobalFederationInstance(FederationInstance);
|
|
15
21
|
return FederationInstance;
|
|
16
22
|
} else {
|
|
@@ -23,51 +29,57 @@ function init(options) {
|
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
function loadRemote(...args) {
|
|
26
|
-
runtimeCore.assert(FederationInstance,
|
|
32
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
27
33
|
const loadRemote1 = FederationInstance.loadRemote;
|
|
28
34
|
// eslint-disable-next-line prefer-spread
|
|
29
35
|
return loadRemote1.apply(FederationInstance, args);
|
|
30
36
|
}
|
|
31
37
|
function loadShare(...args) {
|
|
32
|
-
runtimeCore.assert(FederationInstance,
|
|
38
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
33
39
|
// eslint-disable-next-line prefer-spread
|
|
34
40
|
const loadShare1 = FederationInstance.loadShare;
|
|
35
41
|
return loadShare1.apply(FederationInstance, args);
|
|
36
42
|
}
|
|
37
43
|
function loadShareSync(...args) {
|
|
38
|
-
runtimeCore.assert(FederationInstance,
|
|
44
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
39
45
|
const loadShareSync1 = FederationInstance.loadShareSync;
|
|
40
46
|
// eslint-disable-next-line prefer-spread
|
|
41
47
|
return loadShareSync1.apply(FederationInstance, args);
|
|
42
48
|
}
|
|
43
49
|
function preloadRemote(...args) {
|
|
44
|
-
runtimeCore.assert(FederationInstance,
|
|
50
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
45
51
|
// eslint-disable-next-line prefer-spread
|
|
46
52
|
return FederationInstance.preloadRemote.apply(FederationInstance, args);
|
|
47
53
|
}
|
|
48
54
|
function registerRemotes(...args) {
|
|
49
|
-
runtimeCore.assert(FederationInstance,
|
|
55
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
50
56
|
// eslint-disable-next-line prefer-spread
|
|
51
57
|
return FederationInstance.registerRemotes.apply(FederationInstance, args);
|
|
52
58
|
}
|
|
53
59
|
function registerPlugins(...args) {
|
|
54
|
-
runtimeCore.assert(FederationInstance,
|
|
60
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
55
61
|
// eslint-disable-next-line prefer-spread
|
|
56
62
|
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
57
63
|
}
|
|
58
64
|
function getInstance() {
|
|
59
65
|
return FederationInstance;
|
|
60
66
|
}
|
|
67
|
+
function registerShared(...args) {
|
|
68
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
69
|
+
// eslint-disable-next-line prefer-spread
|
|
70
|
+
return FederationInstance.registerShared.apply(FederationInstance, args);
|
|
71
|
+
}
|
|
61
72
|
// Inject for debug
|
|
62
|
-
runtimeCore.setGlobalFederationConstructor(runtimeCore.
|
|
73
|
+
runtimeCore.setGlobalFederationConstructor(runtimeCore.ModuleFederation);
|
|
63
74
|
|
|
64
|
-
exports.FederationHost = runtimeCore.FederationHost;
|
|
65
75
|
exports.Module = runtimeCore.Module;
|
|
76
|
+
exports.ModuleFederation = runtimeCore.ModuleFederation;
|
|
66
77
|
exports.getRemoteEntry = runtimeCore.getRemoteEntry;
|
|
67
78
|
exports.getRemoteInfo = runtimeCore.getRemoteInfo;
|
|
68
79
|
exports.loadScript = runtimeCore.loadScript;
|
|
69
80
|
exports.loadScriptNode = runtimeCore.loadScriptNode;
|
|
70
81
|
exports.registerGlobalPlugins = runtimeCore.registerGlobalPlugins;
|
|
82
|
+
exports.createInstance = createInstance;
|
|
71
83
|
exports.getInstance = getInstance;
|
|
72
84
|
exports.init = init;
|
|
73
85
|
exports.loadRemote = loadRemote;
|
|
@@ -76,3 +88,4 @@ exports.loadShareSync = loadShareSync;
|
|
|
76
88
|
exports.preloadRemote = preloadRemote;
|
|
77
89
|
exports.registerPlugins = registerPlugins;
|
|
78
90
|
exports.registerRemotes = registerRemotes;
|
|
91
|
+
exports.registerShared = registerShared;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { setGlobalFederationConstructor,
|
|
2
|
-
export {
|
|
1
|
+
import { setGlobalFederationConstructor, ModuleFederation, getGlobalFederationConstructor, setGlobalFederationInstance, assert } from '@module-federation/runtime-core';
|
|
2
|
+
export { Module, ModuleFederation, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, registerGlobalPlugins } from '@module-federation/runtime-core';
|
|
3
|
+
import { getShortErrorMsg, RUNTIME_009, runtimeDescMap } from '@module-federation/error-codes';
|
|
3
4
|
import { g as getGlobalFederationInstance } from './utils.esm.js';
|
|
4
5
|
|
|
6
|
+
function createInstance(options) {
|
|
7
|
+
// Retrieve debug constructor
|
|
8
|
+
const ModuleFederationConstructor = getGlobalFederationConstructor() || ModuleFederation;
|
|
9
|
+
return new ModuleFederationConstructor(options);
|
|
10
|
+
}
|
|
5
11
|
let FederationInstance = null;
|
|
6
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use createInstance or getInstance instead
|
|
14
|
+
*/ function init(options) {
|
|
7
15
|
// Retrieve the same instance with the same name
|
|
8
16
|
const instance = getGlobalFederationInstance(options.name, options.version);
|
|
9
17
|
if (!instance) {
|
|
10
|
-
|
|
11
|
-
const FederationConstructor = getGlobalFederationConstructor() || FederationHost;
|
|
12
|
-
FederationInstance = new FederationConstructor(options);
|
|
18
|
+
FederationInstance = createInstance(options);
|
|
13
19
|
setGlobalFederationInstance(FederationInstance);
|
|
14
20
|
return FederationInstance;
|
|
15
21
|
} else {
|
|
@@ -22,42 +28,47 @@ function init(options) {
|
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
function loadRemote(...args) {
|
|
25
|
-
assert(FederationInstance,
|
|
31
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
26
32
|
const loadRemote1 = FederationInstance.loadRemote;
|
|
27
33
|
// eslint-disable-next-line prefer-spread
|
|
28
34
|
return loadRemote1.apply(FederationInstance, args);
|
|
29
35
|
}
|
|
30
36
|
function loadShare(...args) {
|
|
31
|
-
assert(FederationInstance,
|
|
37
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
32
38
|
// eslint-disable-next-line prefer-spread
|
|
33
39
|
const loadShare1 = FederationInstance.loadShare;
|
|
34
40
|
return loadShare1.apply(FederationInstance, args);
|
|
35
41
|
}
|
|
36
42
|
function loadShareSync(...args) {
|
|
37
|
-
assert(FederationInstance,
|
|
43
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
38
44
|
const loadShareSync1 = FederationInstance.loadShareSync;
|
|
39
45
|
// eslint-disable-next-line prefer-spread
|
|
40
46
|
return loadShareSync1.apply(FederationInstance, args);
|
|
41
47
|
}
|
|
42
48
|
function preloadRemote(...args) {
|
|
43
|
-
assert(FederationInstance,
|
|
49
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
44
50
|
// eslint-disable-next-line prefer-spread
|
|
45
51
|
return FederationInstance.preloadRemote.apply(FederationInstance, args);
|
|
46
52
|
}
|
|
47
53
|
function registerRemotes(...args) {
|
|
48
|
-
assert(FederationInstance,
|
|
54
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
49
55
|
// eslint-disable-next-line prefer-spread
|
|
50
56
|
return FederationInstance.registerRemotes.apply(FederationInstance, args);
|
|
51
57
|
}
|
|
52
58
|
function registerPlugins(...args) {
|
|
53
|
-
assert(FederationInstance,
|
|
59
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
54
60
|
// eslint-disable-next-line prefer-spread
|
|
55
61
|
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
56
62
|
}
|
|
57
63
|
function getInstance() {
|
|
58
64
|
return FederationInstance;
|
|
59
65
|
}
|
|
66
|
+
function registerShared(...args) {
|
|
67
|
+
assert(FederationInstance, getShortErrorMsg(RUNTIME_009, runtimeDescMap));
|
|
68
|
+
// eslint-disable-next-line prefer-spread
|
|
69
|
+
return FederationInstance.registerShared.apply(FederationInstance, args);
|
|
70
|
+
}
|
|
60
71
|
// Inject for debug
|
|
61
|
-
setGlobalFederationConstructor(
|
|
72
|
+
setGlobalFederationConstructor(ModuleFederation);
|
|
62
73
|
|
|
63
|
-
export { getInstance, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
|
|
74
|
+
export { createInstance, getInstance, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes, registerShared };
|
package/dist/src/helpers.d.ts
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
+
import { helpers } from '@module-federation/runtime-core';
|
|
1
2
|
import { getGlobalFederationInstance } from './utils';
|
|
2
3
|
export type { IGlobalUtils, IShareUtils, } from '@module-federation/runtime-core';
|
|
3
4
|
declare const _default: {
|
|
4
|
-
global: {
|
|
5
|
+
global: typeof helpers.global & {
|
|
5
6
|
getGlobalFederationInstance: typeof getGlobalFederationInstance;
|
|
6
|
-
Global: typeof import("@module-federation/runtime-core").Global;
|
|
7
|
-
nativeGlobal: typeof global;
|
|
8
|
-
resetFederationGlobalInfo: typeof import("@module-federation/runtime-core").resetFederationGlobalInfo;
|
|
9
|
-
setGlobalFederationInstance: typeof import("@module-federation/runtime-core").setGlobalFederationInstance;
|
|
10
|
-
getGlobalFederationConstructor: typeof import("@module-federation/runtime-core").getGlobalFederationConstructor;
|
|
11
|
-
setGlobalFederationConstructor: typeof import("@module-federation/runtime-core").setGlobalFederationConstructor;
|
|
12
|
-
getInfoWithoutType: typeof import("@module-federation/runtime-core").getInfoWithoutType;
|
|
13
|
-
getGlobalSnapshot: typeof import("@module-federation/runtime-core").getGlobalSnapshot;
|
|
14
|
-
getTargetSnapshotInfoByModuleInfo: typeof import("packages/runtime-core/dist/src/global").getTargetSnapshotInfoByModuleInfo;
|
|
15
|
-
getGlobalSnapshotInfoByModuleInfo: typeof import("packages/runtime-core/dist/src/global").getGlobalSnapshotInfoByModuleInfo;
|
|
16
|
-
setGlobalSnapshotInfoByModuleInfo: typeof import("packages/runtime-core/dist/src/global").setGlobalSnapshotInfoByModuleInfo;
|
|
17
|
-
addGlobalSnapshot: typeof import("@module-federation/runtime-core").addGlobalSnapshot;
|
|
18
|
-
getRemoteEntryExports: typeof import("packages/runtime-core/dist/src/global").getRemoteEntryExports;
|
|
19
|
-
registerGlobalPlugins: typeof import("@module-federation/runtime-core").registerGlobalPlugins;
|
|
20
|
-
getGlobalHostPlugins: typeof import("packages/runtime-core/dist/src/global").getGlobalHostPlugins;
|
|
21
|
-
getPreloaded: typeof import("packages/runtime-core/dist/src/global").getPreloaded;
|
|
22
|
-
setPreloaded: typeof import("packages/runtime-core/dist/src/global").setPreloaded;
|
|
23
7
|
};
|
|
24
|
-
share:
|
|
8
|
+
share: typeof helpers.share;
|
|
9
|
+
utils: typeof helpers.utils;
|
|
25
10
|
};
|
|
26
11
|
export default _default;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { loadScript, loadScriptNode, Module, getRemoteEntry, getRemoteInfo, registerGlobalPlugins, type
|
|
3
|
-
export {
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
1
|
+
import { ModuleFederation, type UserOptions } from '@module-federation/runtime-core';
|
|
2
|
+
export { loadScript, loadScriptNode, Module, getRemoteEntry, getRemoteInfo, registerGlobalPlugins, type ModuleFederationRuntimePlugin, type Federation, } from '@module-federation/runtime-core';
|
|
3
|
+
export { ModuleFederation };
|
|
4
|
+
export declare function createInstance(options: UserOptions): ModuleFederation;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use createInstance or getInstance instead
|
|
7
|
+
*/
|
|
8
|
+
export declare function init(options: UserOptions): ModuleFederation;
|
|
9
|
+
export declare function loadRemote<T>(...args: Parameters<ModuleFederation['loadRemote']>): Promise<T | null>;
|
|
10
|
+
export declare function loadShare<T>(...args: Parameters<ModuleFederation['loadShare']>): Promise<false | (() => T | undefined)>;
|
|
11
|
+
export declare function loadShareSync<T>(...args: Parameters<ModuleFederation['loadShareSync']>): () => T | never;
|
|
12
|
+
export declare function preloadRemote(...args: Parameters<ModuleFederation['preloadRemote']>): ReturnType<ModuleFederation['preloadRemote']>;
|
|
13
|
+
export declare function registerRemotes(...args: Parameters<ModuleFederation['registerRemotes']>): ReturnType<ModuleFederation['registerRemotes']>;
|
|
14
|
+
export declare function registerPlugins(...args: Parameters<ModuleFederation['registerPlugins']>): ReturnType<ModuleFederation['registerRemotes']>;
|
|
15
|
+
export declare function getInstance(): ModuleFederation | null;
|
|
16
|
+
export declare function registerShared(...args: Parameters<ModuleFederation['registerShared']>): ReturnType<ModuleFederation['registerShared']>;
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleFederation } from '@module-federation/runtime-core';
|
|
2
2
|
export declare function getBuilderId(): string;
|
|
3
|
-
export declare function getGlobalFederationInstance(name: string, version: string | undefined):
|
|
3
|
+
export declare function getGlobalFederationInstance(name: string, version: string | undefined): ModuleFederation | undefined;
|
package/dist/utils.cjs.cjs
CHANGED
|
@@ -10,7 +10,7 @@ function getBuilderId() {
|
|
|
10
10
|
function getGlobalFederationInstance(name, version) {
|
|
11
11
|
const buildId = getBuilderId();
|
|
12
12
|
return runtimeCore.CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{
|
|
13
|
-
if (buildId && GMInstance.options.id ===
|
|
13
|
+
if (buildId && GMInstance.options.id === buildId) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
package/dist/utils.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ function getBuilderId() {
|
|
|
8
8
|
function getGlobalFederationInstance(name, version) {
|
|
9
9
|
const buildId = getBuilderId();
|
|
10
10
|
return CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{
|
|
11
|
-
if (buildId && GMInstance.options.id ===
|
|
11
|
+
if (buildId && GMInstance.options.id === buildId) {
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
14
|
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
6
6
|
"main": "./dist/index.cjs.cjs",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@module-federation/sdk": "0.
|
|
83
|
-
"@module-federation/
|
|
84
|
-
"@module-federation/
|
|
82
|
+
"@module-federation/sdk": "0.17.0",
|
|
83
|
+
"@module-federation/error-codes": "0.17.0",
|
|
84
|
+
"@module-federation/runtime-core": "0.17.0"
|
|
85
85
|
}
|
|
86
86
|
}
|