@module-federation/runtime 0.0.0-canary-1702522677984 → 0.0.0-codex-node24-dev-node20-compat-ci-20260713063237

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.
Files changed (75) hide show
  1. package/README.md +13 -0
  2. package/dist/LICENSE +21 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/bundler.cjs +52 -0
  5. package/dist/bundler.d.ts +2 -0
  6. package/dist/bundler.js +3 -0
  7. package/dist/core.cjs +18 -0
  8. package/dist/core.cjs.map +1 -0
  9. package/dist/core.d.ts +3 -0
  10. package/dist/core.js +10 -0
  11. package/dist/core.js.map +1 -0
  12. package/dist/helpers.cjs +24 -0
  13. package/dist/helpers.cjs.map +1 -0
  14. package/dist/helpers.d.ts +24 -0
  15. package/dist/helpers.js +19 -0
  16. package/dist/helpers.js.map +1 -0
  17. package/dist/index.cjs +114 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +17 -0
  20. package/dist/index.js +66 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/types.cjs +10 -0
  23. package/dist/types.d.ts +1 -0
  24. package/dist/types.js +3 -0
  25. package/dist/utils.cjs +20 -0
  26. package/dist/utils.cjs.map +1 -0
  27. package/dist/utils.d.ts +7 -0
  28. package/dist/utils.js +19 -0
  29. package/dist/utils.js.map +1 -0
  30. package/package.json +75 -15
  31. package/helpers.cjs.d.ts +0 -2
  32. package/helpers.cjs.js +0 -33
  33. package/helpers.esm.js +0 -31
  34. package/index.cjs.d.ts +0 -1
  35. package/index.cjs.js +0 -1635
  36. package/index.esm.js +0 -1626
  37. package/share.cjs.js +0 -771
  38. package/share.esm.js +0 -734
  39. package/src/constant.d.ts +0 -2
  40. package/src/core.d.ts +0 -125
  41. package/src/global.d.ts +0 -57
  42. package/src/helpers.d.ts +0 -32
  43. package/src/index.d.ts +0 -10
  44. package/src/module/index.d.ts +0 -25
  45. package/src/plugins/generate-preload-assets.d.ts +0 -8
  46. package/src/plugins/snapshot/SnapshotHandler.d.ts +0 -43
  47. package/src/plugins/snapshot/index.d.ts +0 -5
  48. package/src/type/config.d.ts +0 -94
  49. package/src/type/index.d.ts +0 -3
  50. package/src/type/plugin.d.ts +0 -20
  51. package/src/type/preload.d.ts +0 -26
  52. package/src/types.d.ts +0 -1
  53. package/src/utils/env.d.ts +0 -4
  54. package/src/utils/hooks/asyncHook.d.ts +0 -6
  55. package/src/utils/hooks/asyncWaterfallHooks.d.ts +0 -10
  56. package/src/utils/hooks/index.d.ts +0 -6
  57. package/src/utils/hooks/pluginSystem.d.ts +0 -15
  58. package/src/utils/hooks/syncHook.d.ts +0 -12
  59. package/src/utils/hooks/syncWaterfallHook.d.ts +0 -9
  60. package/src/utils/index.d.ts +0 -5
  61. package/src/utils/load.d.ts +0 -17
  62. package/src/utils/logger.d.ts +0 -3
  63. package/src/utils/manifest.d.ts +0 -7
  64. package/src/utils/plugin.d.ts +0 -4
  65. package/src/utils/preload.d.ts +0 -6
  66. package/src/utils/semver/compare.d.ts +0 -9
  67. package/src/utils/semver/constants.d.ts +0 -10
  68. package/src/utils/semver/index.d.ts +0 -2
  69. package/src/utils/semver/parser.d.ts +0 -9
  70. package/src/utils/semver/utils.d.ts +0 -11
  71. package/src/utils/share.d.ts +0 -7
  72. package/src/utils/tool.d.ts +0 -12
  73. package/type.cjs.d.ts +0 -1
  74. package/type.cjs.js +0 -2
  75. package/type.esm.js +0 -1
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @module-federation/runtime
2
+
3
+ - Can be combined with the build plug-in to share basic dependencies according to policies to reduce the number of module downloads and improve the loading speed of modules.
4
+ - Only consume part of the export of the remote module and will not fully download the remote module
5
+ - The runtime calling process can be extended through the module-runtime plug-in mechanism
6
+
7
+ ## Documentation
8
+
9
+ See [https://module-federation.io/guide/runtime/index.html](https://module-federation.io/guide/runtime/index.html) for details.
10
+
11
+ ## License
12
+
13
+ `@module-federation/runtime` is [MIT licensed](https://github.com/module-federation/core/blob/main/packages/runtime/LICENSE).
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present zhouxiao(zhoushaw)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -0,0 +1,52 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_index = require('./index.cjs');
4
+ let _module_federation_runtime_core = require("@module-federation/runtime-core");
5
+
6
+ Object.defineProperty(exports, 'Module', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _module_federation_runtime_core.Module;
10
+ }
11
+ });
12
+ exports.ModuleFederation = _module_federation_runtime_core.ModuleFederation;
13
+ exports.createInstance = require_index.createInstance;
14
+ exports.getInstance = require_index.getInstance;
15
+ Object.defineProperty(exports, 'getRemoteEntry', {
16
+ enumerable: true,
17
+ get: function () {
18
+ return _module_federation_runtime_core.getRemoteEntry;
19
+ }
20
+ });
21
+ Object.defineProperty(exports, 'getRemoteInfo', {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _module_federation_runtime_core.getRemoteInfo;
25
+ }
26
+ });
27
+ exports.init = require_index.init;
28
+ exports.loadRemote = require_index.loadRemote;
29
+ Object.defineProperty(exports, 'loadScript', {
30
+ enumerable: true,
31
+ get: function () {
32
+ return _module_federation_runtime_core.loadScript;
33
+ }
34
+ });
35
+ Object.defineProperty(exports, 'loadScriptNode', {
36
+ enumerable: true,
37
+ get: function () {
38
+ return _module_federation_runtime_core.loadScriptNode;
39
+ }
40
+ });
41
+ exports.loadShare = require_index.loadShare;
42
+ exports.loadShareSync = require_index.loadShareSync;
43
+ exports.preloadRemote = require_index.preloadRemote;
44
+ Object.defineProperty(exports, 'registerGlobalPlugins', {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _module_federation_runtime_core.registerGlobalPlugins;
48
+ }
49
+ });
50
+ exports.registerPlugins = require_index.registerPlugins;
51
+ exports.registerRemotes = require_index.registerRemotes;
52
+ exports.registerShared = require_index.registerShared;
@@ -0,0 +1,2 @@
1
+ import { Federation, Module, ModuleFederation, ModuleFederationRuntimePlugin, createInstance, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes, registerShared } from "./index.js";
2
+ export { Federation, Module, ModuleFederation, ModuleFederationRuntimePlugin, createInstance, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes, registerShared };
@@ -0,0 +1,3 @@
1
+ import { Module, ModuleFederation, createInstance, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes, registerShared } from "./index.js";
2
+
3
+ export { Module, ModuleFederation, createInstance, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes, registerShared };
package/dist/core.cjs ADDED
@@ -0,0 +1,18 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ let _module_federation_runtime_core = require("@module-federation/runtime-core");
4
+ _module_federation_runtime_core = require_runtime.__toESM(_module_federation_runtime_core);
5
+
6
+ //#region src/core.ts
7
+ var core_default = _module_federation_runtime_core;
8
+
9
+ //#endregion
10
+ exports.default = core_default;
11
+ Object.keys(_module_federation_runtime_core).forEach(function (k) {
12
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
13
+ enumerable: true,
14
+ get: function () { return _module_federation_runtime_core[k]; }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.cjs","names":["runtimeCore"],"sources":["../src/core.ts"],"sourcesContent":["import * as runtimeCore from '@module-federation/runtime-core';\n\nexport * from '@module-federation/runtime-core';\n\nexport default runtimeCore;\n"],"mappings":";;;;;;AAIA,mBAAeA"}
package/dist/core.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import * as runtimeCore from "@module-federation/runtime-core";
2
+ export * from "@module-federation/runtime-core";
3
+ export = runtimeCore;
package/dist/core.js ADDED
@@ -0,0 +1,10 @@
1
+ import * as runtimeCore from "@module-federation/runtime-core";
2
+
3
+ export * from "@module-federation/runtime-core"
4
+
5
+ //#region src/core.ts
6
+ var core_default = runtimeCore;
7
+
8
+ //#endregion
9
+ export { core_default as default };
10
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","names":[],"sources":["../src/core.ts"],"sourcesContent":["import * as runtimeCore from '@module-federation/runtime-core';\n\nexport * from '@module-federation/runtime-core';\n\nexport default runtimeCore;\n"],"mappings":";;;;;AAIA,mBAAe"}
@@ -0,0 +1,24 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_utils = require('./utils.cjs');
4
+ let _module_federation_runtime_core = require("@module-federation/runtime-core");
5
+
6
+ //#region src/helpers.ts
7
+ const global = {
8
+ ..._module_federation_runtime_core.helpers.global,
9
+ getGlobalFederationInstance: require_utils.getGlobalFederationInstance
10
+ };
11
+ const share = _module_federation_runtime_core.helpers.share;
12
+ const utils = _module_federation_runtime_core.helpers.utils;
13
+ const runtimeHelpers = {
14
+ global,
15
+ share,
16
+ utils
17
+ };
18
+
19
+ //#endregion
20
+ exports.default = runtimeHelpers;
21
+ exports.global = global;
22
+ exports.share = share;
23
+ exports.utils = utils;
24
+ //# sourceMappingURL=helpers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs","names":["helpers"],"sources":["../src/helpers.ts"],"sourcesContent":["import {\n helpers,\n type IGlobalUtils,\n type IShareUtils,\n} from '@module-federation/runtime-core';\nimport { getGlobalFederationInstance } from './utils';\n\nexport type {\n IGlobalUtils,\n IShareUtils,\n} from '@module-federation/runtime-core';\n\ntype RuntimeGlobalUtils = IGlobalUtils & {\n getGlobalFederationInstance: typeof getGlobalFederationInstance;\n};\n\nexport const global: RuntimeGlobalUtils = {\n ...helpers.global,\n getGlobalFederationInstance,\n};\n\nexport const share: IShareUtils = helpers.share;\n\nexport interface IRuntimeUtils {\n matchRemoteWithNameAndExpose: typeof import('@module-federation/runtime-core').matchRemoteWithNameAndExpose;\n preloadAssets: (...args: any[]) => void;\n getRemoteInfo: typeof import('@module-federation/runtime-core').getRemoteInfo;\n}\n\nexport const utils: IRuntimeUtils = helpers.utils;\n\nconst runtimeHelpers: {\n global: RuntimeGlobalUtils;\n share: IShareUtils;\n utils: IRuntimeUtils;\n} = {\n global,\n share,\n utils,\n};\n\nexport default runtimeHelpers;\n"],"mappings":";;;;;;AAgBA,MAAa,SAA6B;CACxC,GAAGA,wCAAQ;CACX;CACD;AAED,MAAa,QAAqBA,wCAAQ;AAQ1C,MAAa,QAAuBA,wCAAQ;AAE5C,MAAM,iBAIF;CACF;CACA;CACA;CACD"}
@@ -0,0 +1,24 @@
1
+ import { getGlobalFederationInstance } from "./utils.js";
2
+ import * as _module_federation_runtime_core0 from "@module-federation/runtime-core";
3
+ import { IGlobalUtils, IGlobalUtils as IGlobalUtils$1, IShareUtils, IShareUtils as IShareUtils$1 } from "@module-federation/runtime-core";
4
+
5
+ //#region src/helpers.d.ts
6
+ type RuntimeGlobalUtils = IGlobalUtils$1 & {
7
+ getGlobalFederationInstance: typeof getGlobalFederationInstance;
8
+ };
9
+ declare const global: RuntimeGlobalUtils;
10
+ declare const share: IShareUtils$1;
11
+ interface IRuntimeUtils {
12
+ matchRemoteWithNameAndExpose: typeof _module_federation_runtime_core0.matchRemoteWithNameAndExpose;
13
+ preloadAssets: (...args: any[]) => void;
14
+ getRemoteInfo: typeof _module_federation_runtime_core0.getRemoteInfo;
15
+ }
16
+ declare const utils: IRuntimeUtils;
17
+ declare const runtimeHelpers: {
18
+ global: RuntimeGlobalUtils;
19
+ share: IShareUtils$1;
20
+ utils: IRuntimeUtils;
21
+ };
22
+ //#endregion
23
+ export { type IGlobalUtils, IRuntimeUtils, type IShareUtils, runtimeHelpers as default, global, share, utils };
24
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { getGlobalFederationInstance } from "./utils.js";
2
+ import { helpers } from "@module-federation/runtime-core";
3
+
4
+ //#region src/helpers.ts
5
+ const global = {
6
+ ...helpers.global,
7
+ getGlobalFederationInstance
8
+ };
9
+ const share = helpers.share;
10
+ const utils = helpers.utils;
11
+ const runtimeHelpers = {
12
+ global,
13
+ share,
14
+ utils
15
+ };
16
+
17
+ //#endregion
18
+ export { runtimeHelpers as default, global, share, utils };
19
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import {\n helpers,\n type IGlobalUtils,\n type IShareUtils,\n} from '@module-federation/runtime-core';\nimport { getGlobalFederationInstance } from './utils';\n\nexport type {\n IGlobalUtils,\n IShareUtils,\n} from '@module-federation/runtime-core';\n\ntype RuntimeGlobalUtils = IGlobalUtils & {\n getGlobalFederationInstance: typeof getGlobalFederationInstance;\n};\n\nexport const global: RuntimeGlobalUtils = {\n ...helpers.global,\n getGlobalFederationInstance,\n};\n\nexport const share: IShareUtils = helpers.share;\n\nexport interface IRuntimeUtils {\n matchRemoteWithNameAndExpose: typeof import('@module-federation/runtime-core').matchRemoteWithNameAndExpose;\n preloadAssets: (...args: any[]) => void;\n getRemoteInfo: typeof import('@module-federation/runtime-core').getRemoteInfo;\n}\n\nexport const utils: IRuntimeUtils = helpers.utils;\n\nconst runtimeHelpers: {\n global: RuntimeGlobalUtils;\n share: IShareUtils;\n utils: IRuntimeUtils;\n} = {\n global,\n share,\n utils,\n};\n\nexport default runtimeHelpers;\n"],"mappings":";;;;AAgBA,MAAa,SAA6B;CACxC,GAAG,QAAQ;CACX;CACD;AAED,MAAa,QAAqB,QAAQ;AAQ1C,MAAa,QAAuB,QAAQ;AAE5C,MAAM,iBAIF;CACF;CACA;CACA;CACD"}
package/dist/index.cjs ADDED
@@ -0,0 +1,114 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_utils = require('./utils.cjs');
4
+ let _module_federation_runtime_core = require("@module-federation/runtime-core");
5
+ let _module_federation_error_codes = require("@module-federation/error-codes");
6
+
7
+ //#region src/index.ts
8
+ function createInstance(options) {
9
+ const instance = new (((0, _module_federation_runtime_core.getGlobalFederationConstructor)()) || _module_federation_runtime_core.ModuleFederation)({
10
+ id: `${options.name}@${options.version || Date.now()}`,
11
+ ...options
12
+ });
13
+ (0, _module_federation_runtime_core.setGlobalFederationInstance)(instance);
14
+ return instance;
15
+ }
16
+ let FederationInstance = null;
17
+ function init(options) {
18
+ const instance = require_utils.getGlobalFederationInstance(options.name, options.version);
19
+ const normalizedOptions = {
20
+ ...options,
21
+ id: options.id || ""
22
+ };
23
+ if (!instance) {
24
+ FederationInstance = createInstance(normalizedOptions);
25
+ return FederationInstance;
26
+ } else {
27
+ instance.initOptions(normalizedOptions);
28
+ if (!FederationInstance) FederationInstance = instance;
29
+ return instance;
30
+ }
31
+ }
32
+ function loadRemote(...args) {
33
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
34
+ return FederationInstance.loadRemote.apply(FederationInstance, args);
35
+ }
36
+ function loadShare(...args) {
37
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
38
+ return FederationInstance.loadShare.apply(FederationInstance, args);
39
+ }
40
+ function loadShareSync(...args) {
41
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
42
+ return FederationInstance.loadShareSync.apply(FederationInstance, args);
43
+ }
44
+ function preloadRemote(...args) {
45
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
46
+ return FederationInstance.preloadRemote.apply(FederationInstance, args);
47
+ }
48
+ function registerRemotes(...args) {
49
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
50
+ return FederationInstance.registerRemotes.apply(FederationInstance, args);
51
+ }
52
+ function registerPlugins(...args) {
53
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
54
+ return FederationInstance.registerPlugins.apply(FederationInstance, args);
55
+ }
56
+ function getInstance(finder) {
57
+ if (!finder) return FederationInstance;
58
+ return _module_federation_runtime_core.CurrentGlobal.__FEDERATION__.__INSTANCES__.find(finder) || null;
59
+ }
60
+ function registerShared(...args) {
61
+ (0, _module_federation_runtime_core.assert)(FederationInstance, _module_federation_error_codes.RUNTIME_009, _module_federation_error_codes.runtimeDescMap);
62
+ return FederationInstance.registerShared.apply(FederationInstance, args);
63
+ }
64
+ (0, _module_federation_runtime_core.setGlobalFederationConstructor)(_module_federation_runtime_core.ModuleFederation);
65
+
66
+ //#endregion
67
+ Object.defineProperty(exports, 'Module', {
68
+ enumerable: true,
69
+ get: function () {
70
+ return _module_federation_runtime_core.Module;
71
+ }
72
+ });
73
+ exports.ModuleFederation = _module_federation_runtime_core.ModuleFederation;
74
+ exports.createInstance = createInstance;
75
+ exports.getInstance = getInstance;
76
+ Object.defineProperty(exports, 'getRemoteEntry', {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _module_federation_runtime_core.getRemoteEntry;
80
+ }
81
+ });
82
+ Object.defineProperty(exports, 'getRemoteInfo', {
83
+ enumerable: true,
84
+ get: function () {
85
+ return _module_federation_runtime_core.getRemoteInfo;
86
+ }
87
+ });
88
+ exports.init = init;
89
+ exports.loadRemote = loadRemote;
90
+ Object.defineProperty(exports, 'loadScript', {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _module_federation_runtime_core.loadScript;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, 'loadScriptNode', {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _module_federation_runtime_core.loadScriptNode;
100
+ }
101
+ });
102
+ exports.loadShare = loadShare;
103
+ exports.loadShareSync = loadShareSync;
104
+ exports.preloadRemote = preloadRemote;
105
+ Object.defineProperty(exports, 'registerGlobalPlugins', {
106
+ enumerable: true,
107
+ get: function () {
108
+ return _module_federation_runtime_core.registerGlobalPlugins;
109
+ }
110
+ });
111
+ exports.registerPlugins = registerPlugins;
112
+ exports.registerRemotes = registerRemotes;
113
+ exports.registerShared = registerShared;
114
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["ModuleFederation","getGlobalFederationInstance","RUNTIME_009","runtimeDescMap","CurrentGlobal"],"sources":["../src/index.ts"],"sourcesContent":["import {\n ModuleFederation,\n type UserOptions,\n CurrentGlobal,\n getGlobalFederationConstructor,\n setGlobalFederationInstance,\n assert,\n setGlobalFederationConstructor,\n} from '@module-federation/runtime-core';\nimport { runtimeDescMap, RUNTIME_009 } from '@module-federation/error-codes';\nimport { getGlobalFederationInstance } from './utils';\n\nexport {\n loadScript,\n loadScriptNode,\n Module,\n getRemoteEntry,\n getRemoteInfo,\n registerGlobalPlugins,\n type ModuleFederationRuntimePlugin,\n type Federation,\n} from '@module-federation/runtime-core';\n\nexport { ModuleFederation };\n\nexport function createInstance(options: UserOptions) {\n // Retrieve debug constructor\n const ModuleFederationConstructor =\n getGlobalFederationConstructor() || ModuleFederation;\n const instance = new ModuleFederationConstructor({\n id: `${options.name}@${options.version || Date.now()}`,\n ...options,\n });\n setGlobalFederationInstance(instance);\n return instance;\n}\n\nlet FederationInstance: ModuleFederation | null = null;\nexport function init(options: UserOptions): ModuleFederation {\n // Retrieve the same instance with the same name\n const instance = getGlobalFederationInstance(options.name, options.version);\n const normalizedOptions = { ...options, id: options.id || '' };\n if (!instance) {\n FederationInstance = createInstance(normalizedOptions);\n return FederationInstance;\n } else {\n // Merge options\n instance.initOptions(normalizedOptions);\n if (!FederationInstance) {\n FederationInstance = instance;\n }\n return instance;\n }\n}\n\nexport function loadRemote<T>(\n ...args: Parameters<ModuleFederation['loadRemote']>\n): Promise<T | null> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n const loadRemote: typeof FederationInstance.loadRemote<T> =\n FederationInstance.loadRemote;\n // eslint-disable-next-line prefer-spread\n return loadRemote.apply(FederationInstance, args);\n}\n\nexport function loadShare<T>(\n ...args: Parameters<ModuleFederation['loadShare']>\n): Promise<false | (() => T | undefined)> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n const loadShare: typeof FederationInstance.loadShare<T> =\n FederationInstance.loadShare;\n return loadShare.apply(FederationInstance, args);\n}\n\nexport function loadShareSync<T>(\n ...args: Parameters<ModuleFederation['loadShareSync']>\n): () => T | never {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n const loadShareSync: typeof FederationInstance.loadShareSync<T> =\n FederationInstance.loadShareSync;\n // eslint-disable-next-line prefer-spread\n return loadShareSync.apply(FederationInstance, args);\n}\n\nexport function preloadRemote(\n ...args: Parameters<ModuleFederation['preloadRemote']>\n): ReturnType<ModuleFederation['preloadRemote']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.preloadRemote.apply(FederationInstance, args);\n}\n\nexport function registerRemotes(\n ...args: Parameters<ModuleFederation['registerRemotes']>\n): ReturnType<ModuleFederation['registerRemotes']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.registerRemotes.apply(FederationInstance, args);\n}\n\nexport function registerPlugins(\n ...args: Parameters<ModuleFederation['registerPlugins']>\n): ReturnType<ModuleFederation['registerRemotes']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.registerPlugins.apply(FederationInstance, args);\n}\n\nexport function getInstance(): ModuleFederation | null;\nexport function getInstance(\n finder: (instance: ModuleFederation) => boolean,\n): ModuleFederation | null;\nexport function getInstance(finder?: (instance: ModuleFederation) => boolean) {\n if (!finder) {\n return FederationInstance;\n }\n\n return CurrentGlobal.__FEDERATION__.__INSTANCES__.find(finder) || null;\n}\n\nexport function registerShared(\n ...args: Parameters<ModuleFederation['registerShared']>\n): ReturnType<ModuleFederation['registerShared']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.registerShared.apply(FederationInstance, args);\n}\n\n// Inject for debug\nsetGlobalFederationConstructor(ModuleFederation);\n"],"mappings":";;;;;;;AAyBA,SAAgB,eAAe,SAAsB;CAInD,MAAM,WAAW,2EADiB,KAAIA,kDACW;EAC/C,IAAI,GAAG,QAAQ,KAAK,GAAG,QAAQ,WAAW,KAAK,KAAK;EACpD,GAAG;EACJ,CAAC;AACF,kEAA4B,SAAS;AACrC,QAAO;;AAGT,IAAI,qBAA8C;AAClD,SAAgB,KAAK,SAAwC;CAE3D,MAAM,WAAWC,0CAA4B,QAAQ,MAAM,QAAQ,QAAQ;CAC3E,MAAM,oBAAoB;EAAE,GAAG;EAAS,IAAI,QAAQ,MAAM;EAAI;AAC9D,KAAI,CAAC,UAAU;AACb,uBAAqB,eAAe,kBAAkB;AACtD,SAAO;QACF;AAEL,WAAS,YAAY,kBAAkB;AACvC,MAAI,CAAC,mBACH,sBAAqB;AAEvB,SAAO;;;AAIX,SAAgB,WACd,GAAG,MACgB;AACnB,6CAAO,oBAAoBC,4CAAaC,8CAAe;AAIvD,QAFE,mBAAmB,WAEH,MAAM,oBAAoB,KAAK;;AAGnD,SAAgB,UACd,GAAG,MACqC;AACxC,6CAAO,oBAAoBD,4CAAaC,8CAAe;AAIvD,QADE,mBAAmB,UACJ,MAAM,oBAAoB,KAAK;;AAGlD,SAAgB,cACd,GAAG,MACc;AACjB,6CAAO,oBAAoBD,4CAAaC,8CAAe;AAIvD,QAFE,mBAAmB,cAEA,MAAM,oBAAoB,KAAK;;AAGtD,SAAgB,cACd,GAAG,MAC4C;AAC/C,6CAAO,oBAAoBD,4CAAaC,8CAAe;AAEvD,QAAO,mBAAmB,cAAc,MAAM,oBAAoB,KAAK;;AAGzE,SAAgB,gBACd,GAAG,MAC8C;AACjD,6CAAO,oBAAoBD,4CAAaC,8CAAe;AAEvD,QAAO,mBAAmB,gBAAgB,MAAM,oBAAoB,KAAK;;AAG3E,SAAgB,gBACd,GAAG,MAC8C;AACjD,6CAAO,oBAAoBD,4CAAaC,8CAAe;AAEvD,QAAO,mBAAmB,gBAAgB,MAAM,oBAAoB,KAAK;;AAO3E,SAAgB,YAAY,QAAkD;AAC5E,KAAI,CAAC,OACH,QAAO;AAGT,QAAOC,8CAAc,eAAe,cAAc,KAAK,OAAO,IAAI;;AAGpE,SAAgB,eACd,GAAG,MAC6C;AAChD,6CAAO,oBAAoBF,4CAAaC,8CAAe;AAEvD,QAAO,mBAAmB,eAAe,MAAM,oBAAoB,KAAK;;oEAI3CH,iDAAiB"}
@@ -0,0 +1,17 @@
1
+ import { Federation, Module, ModuleFederation, ModuleFederationRuntimePlugin, UserOptions, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, registerGlobalPlugins } from "@module-federation/runtime-core";
2
+
3
+ //#region src/index.d.ts
4
+ declare function createInstance(options: UserOptions): ModuleFederation;
5
+ declare function init(options: UserOptions): ModuleFederation;
6
+ declare function loadRemote<T>(...args: Parameters<ModuleFederation['loadRemote']>): Promise<T | null>;
7
+ declare function loadShare<T>(...args: Parameters<ModuleFederation['loadShare']>): Promise<false | (() => T | undefined)>;
8
+ declare function loadShareSync<T>(...args: Parameters<ModuleFederation['loadShareSync']>): () => T | never;
9
+ declare function preloadRemote(...args: Parameters<ModuleFederation['preloadRemote']>): ReturnType<ModuleFederation['preloadRemote']>;
10
+ declare function registerRemotes(...args: Parameters<ModuleFederation['registerRemotes']>): ReturnType<ModuleFederation['registerRemotes']>;
11
+ declare function registerPlugins(...args: Parameters<ModuleFederation['registerPlugins']>): ReturnType<ModuleFederation['registerRemotes']>;
12
+ declare function getInstance(): ModuleFederation | null;
13
+ declare function getInstance(finder: (instance: ModuleFederation) => boolean): ModuleFederation | null;
14
+ declare function registerShared(...args: Parameters<ModuleFederation['registerShared']>): ReturnType<ModuleFederation['registerShared']>;
15
+ //#endregion
16
+ export { type Federation, Module, ModuleFederation, type ModuleFederationRuntimePlugin, createInstance, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes, registerShared };
17
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ import { getGlobalFederationInstance } from "./utils.js";
2
+ import { CurrentGlobal, Module, ModuleFederation, assert, getGlobalFederationConstructor, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, registerGlobalPlugins, setGlobalFederationConstructor, setGlobalFederationInstance } from "@module-federation/runtime-core";
3
+ import { RUNTIME_009, runtimeDescMap } from "@module-federation/error-codes";
4
+
5
+ //#region src/index.ts
6
+ function createInstance(options) {
7
+ const instance = new ((getGlobalFederationConstructor()) || ModuleFederation)({
8
+ id: `${options.name}@${options.version || Date.now()}`,
9
+ ...options
10
+ });
11
+ setGlobalFederationInstance(instance);
12
+ return instance;
13
+ }
14
+ let FederationInstance = null;
15
+ function init(options) {
16
+ const instance = getGlobalFederationInstance(options.name, options.version);
17
+ const normalizedOptions = {
18
+ ...options,
19
+ id: options.id || ""
20
+ };
21
+ if (!instance) {
22
+ FederationInstance = createInstance(normalizedOptions);
23
+ return FederationInstance;
24
+ } else {
25
+ instance.initOptions(normalizedOptions);
26
+ if (!FederationInstance) FederationInstance = instance;
27
+ return instance;
28
+ }
29
+ }
30
+ function loadRemote(...args) {
31
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
32
+ return FederationInstance.loadRemote.apply(FederationInstance, args);
33
+ }
34
+ function loadShare(...args) {
35
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
36
+ return FederationInstance.loadShare.apply(FederationInstance, args);
37
+ }
38
+ function loadShareSync(...args) {
39
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
40
+ return FederationInstance.loadShareSync.apply(FederationInstance, args);
41
+ }
42
+ function preloadRemote(...args) {
43
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
44
+ return FederationInstance.preloadRemote.apply(FederationInstance, args);
45
+ }
46
+ function registerRemotes(...args) {
47
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
48
+ return FederationInstance.registerRemotes.apply(FederationInstance, args);
49
+ }
50
+ function registerPlugins(...args) {
51
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
52
+ return FederationInstance.registerPlugins.apply(FederationInstance, args);
53
+ }
54
+ function getInstance(finder) {
55
+ if (!finder) return FederationInstance;
56
+ return CurrentGlobal.__FEDERATION__.__INSTANCES__.find(finder) || null;
57
+ }
58
+ function registerShared(...args) {
59
+ assert(FederationInstance, RUNTIME_009, runtimeDescMap);
60
+ return FederationInstance.registerShared.apply(FederationInstance, args);
61
+ }
62
+ setGlobalFederationConstructor(ModuleFederation);
63
+
64
+ //#endregion
65
+ export { Module, ModuleFederation, createInstance, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes, registerShared };
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n ModuleFederation,\n type UserOptions,\n CurrentGlobal,\n getGlobalFederationConstructor,\n setGlobalFederationInstance,\n assert,\n setGlobalFederationConstructor,\n} from '@module-federation/runtime-core';\nimport { runtimeDescMap, RUNTIME_009 } from '@module-federation/error-codes';\nimport { getGlobalFederationInstance } from './utils';\n\nexport {\n loadScript,\n loadScriptNode,\n Module,\n getRemoteEntry,\n getRemoteInfo,\n registerGlobalPlugins,\n type ModuleFederationRuntimePlugin,\n type Federation,\n} from '@module-federation/runtime-core';\n\nexport { ModuleFederation };\n\nexport function createInstance(options: UserOptions) {\n // Retrieve debug constructor\n const ModuleFederationConstructor =\n getGlobalFederationConstructor() || ModuleFederation;\n const instance = new ModuleFederationConstructor({\n id: `${options.name}@${options.version || Date.now()}`,\n ...options,\n });\n setGlobalFederationInstance(instance);\n return instance;\n}\n\nlet FederationInstance: ModuleFederation | null = null;\nexport function init(options: UserOptions): ModuleFederation {\n // Retrieve the same instance with the same name\n const instance = getGlobalFederationInstance(options.name, options.version);\n const normalizedOptions = { ...options, id: options.id || '' };\n if (!instance) {\n FederationInstance = createInstance(normalizedOptions);\n return FederationInstance;\n } else {\n // Merge options\n instance.initOptions(normalizedOptions);\n if (!FederationInstance) {\n FederationInstance = instance;\n }\n return instance;\n }\n}\n\nexport function loadRemote<T>(\n ...args: Parameters<ModuleFederation['loadRemote']>\n): Promise<T | null> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n const loadRemote: typeof FederationInstance.loadRemote<T> =\n FederationInstance.loadRemote;\n // eslint-disable-next-line prefer-spread\n return loadRemote.apply(FederationInstance, args);\n}\n\nexport function loadShare<T>(\n ...args: Parameters<ModuleFederation['loadShare']>\n): Promise<false | (() => T | undefined)> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n const loadShare: typeof FederationInstance.loadShare<T> =\n FederationInstance.loadShare;\n return loadShare.apply(FederationInstance, args);\n}\n\nexport function loadShareSync<T>(\n ...args: Parameters<ModuleFederation['loadShareSync']>\n): () => T | never {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n const loadShareSync: typeof FederationInstance.loadShareSync<T> =\n FederationInstance.loadShareSync;\n // eslint-disable-next-line prefer-spread\n return loadShareSync.apply(FederationInstance, args);\n}\n\nexport function preloadRemote(\n ...args: Parameters<ModuleFederation['preloadRemote']>\n): ReturnType<ModuleFederation['preloadRemote']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.preloadRemote.apply(FederationInstance, args);\n}\n\nexport function registerRemotes(\n ...args: Parameters<ModuleFederation['registerRemotes']>\n): ReturnType<ModuleFederation['registerRemotes']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.registerRemotes.apply(FederationInstance, args);\n}\n\nexport function registerPlugins(\n ...args: Parameters<ModuleFederation['registerPlugins']>\n): ReturnType<ModuleFederation['registerRemotes']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.registerPlugins.apply(FederationInstance, args);\n}\n\nexport function getInstance(): ModuleFederation | null;\nexport function getInstance(\n finder: (instance: ModuleFederation) => boolean,\n): ModuleFederation | null;\nexport function getInstance(finder?: (instance: ModuleFederation) => boolean) {\n if (!finder) {\n return FederationInstance;\n }\n\n return CurrentGlobal.__FEDERATION__.__INSTANCES__.find(finder) || null;\n}\n\nexport function registerShared(\n ...args: Parameters<ModuleFederation['registerShared']>\n): ReturnType<ModuleFederation['registerShared']> {\n assert(FederationInstance, RUNTIME_009, runtimeDescMap);\n // eslint-disable-next-line prefer-spread\n return FederationInstance.registerShared.apply(FederationInstance, args);\n}\n\n// Inject for debug\nsetGlobalFederationConstructor(ModuleFederation);\n"],"mappings":";;;;;AAyBA,SAAgB,eAAe,SAAsB;CAInD,MAAM,WAAW,MADf,gCAAgC,KAAI,kBACW;EAC/C,IAAI,GAAG,QAAQ,KAAK,GAAG,QAAQ,WAAW,KAAK,KAAK;EACpD,GAAG;EACJ,CAAC;AACF,6BAA4B,SAAS;AACrC,QAAO;;AAGT,IAAI,qBAA8C;AAClD,SAAgB,KAAK,SAAwC;CAE3D,MAAM,WAAW,4BAA4B,QAAQ,MAAM,QAAQ,QAAQ;CAC3E,MAAM,oBAAoB;EAAE,GAAG;EAAS,IAAI,QAAQ,MAAM;EAAI;AAC9D,KAAI,CAAC,UAAU;AACb,uBAAqB,eAAe,kBAAkB;AACtD,SAAO;QACF;AAEL,WAAS,YAAY,kBAAkB;AACvC,MAAI,CAAC,mBACH,sBAAqB;AAEvB,SAAO;;;AAIX,SAAgB,WACd,GAAG,MACgB;AACnB,QAAO,oBAAoB,aAAa,eAAe;AAIvD,QAFE,mBAAmB,WAEH,MAAM,oBAAoB,KAAK;;AAGnD,SAAgB,UACd,GAAG,MACqC;AACxC,QAAO,oBAAoB,aAAa,eAAe;AAIvD,QADE,mBAAmB,UACJ,MAAM,oBAAoB,KAAK;;AAGlD,SAAgB,cACd,GAAG,MACc;AACjB,QAAO,oBAAoB,aAAa,eAAe;AAIvD,QAFE,mBAAmB,cAEA,MAAM,oBAAoB,KAAK;;AAGtD,SAAgB,cACd,GAAG,MAC4C;AAC/C,QAAO,oBAAoB,aAAa,eAAe;AAEvD,QAAO,mBAAmB,cAAc,MAAM,oBAAoB,KAAK;;AAGzE,SAAgB,gBACd,GAAG,MAC8C;AACjD,QAAO,oBAAoB,aAAa,eAAe;AAEvD,QAAO,mBAAmB,gBAAgB,MAAM,oBAAoB,KAAK;;AAG3E,SAAgB,gBACd,GAAG,MAC8C;AACjD,QAAO,oBAAoB,aAAa,eAAe;AAEvD,QAAO,mBAAmB,gBAAgB,MAAM,oBAAoB,KAAK;;AAO3E,SAAgB,YAAY,QAAkD;AAC5E,KAAI,CAAC,OACH,QAAO;AAGT,QAAO,cAAc,eAAe,cAAc,KAAK,OAAO,IAAI;;AAGpE,SAAgB,eACd,GAAG,MAC6C;AAChD,QAAO,oBAAoB,aAAa,eAAe;AAEvD,QAAO,mBAAmB,eAAe,MAAM,oBAAoB,KAAK;;AAI1E,+BAA+B,iBAAiB"}
package/dist/types.cjs ADDED
@@ -0,0 +1,10 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+
4
+ var _module_federation_runtime_core_types = require("@module-federation/runtime-core/types");
5
+ Object.keys(_module_federation_runtime_core_types).forEach(function (k) {
6
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: function () { return _module_federation_runtime_core_types[k]; }
9
+ });
10
+ });
@@ -0,0 +1 @@
1
+ export * from "@module-federation/runtime-core/types";
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "@module-federation/runtime-core/types"
2
+
3
+ export { };
package/dist/utils.cjs ADDED
@@ -0,0 +1,20 @@
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ let _module_federation_runtime_core = require("@module-federation/runtime-core");
3
+
4
+ //#region src/utils.ts
5
+ function getBuilderId() {
6
+ return typeof FEDERATION_BUILD_IDENTIFIER !== "undefined" ? FEDERATION_BUILD_IDENTIFIER : "";
7
+ }
8
+ function getGlobalFederationInstance(name, version) {
9
+ const buildId = getBuilderId();
10
+ return _module_federation_runtime_core.CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance) => {
11
+ if (buildId && GMInstance.options.id === buildId) return true;
12
+ if (GMInstance.options.name === name && !GMInstance.options.version && !version) return true;
13
+ if (GMInstance.options.name === name && version && GMInstance.options.version === version) return true;
14
+ return false;
15
+ });
16
+ }
17
+
18
+ //#endregion
19
+ exports.getGlobalFederationInstance = getGlobalFederationInstance;
20
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","names":["CurrentGlobal"],"sources":["../src/utils.ts"],"sourcesContent":["import type { ModuleFederation } from '@module-federation/runtime-core';\nimport { CurrentGlobal } from '@module-federation/runtime-core';\n\n// injected by bundler, so it can not use runtime-core stuff\nexport function getBuilderId(): string {\n //@ts-ignore\n return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined'\n ? //@ts-ignore\n FEDERATION_BUILD_IDENTIFIER\n : '';\n}\n\nexport function getGlobalFederationInstance(\n name: string,\n version: string | undefined,\n): ModuleFederation | undefined {\n const buildId = getBuilderId();\n return CurrentGlobal.__FEDERATION__.__INSTANCES__.find(\n (GMInstance: ModuleFederation) => {\n if (buildId && GMInstance.options.id === buildId) {\n return true;\n }\n\n if (\n GMInstance.options.name === name &&\n !GMInstance.options.version &&\n !version\n ) {\n return true;\n }\n\n if (\n GMInstance.options.name === name &&\n version &&\n GMInstance.options.version === version\n ) {\n return true;\n }\n return false;\n },\n );\n}\n"],"mappings":";;;;AAIA,SAAgB,eAAuB;AAErC,QAAO,OAAO,gCAAgC,cAE1C,8BACA;;AAGN,SAAgB,4BACd,MACA,SAC8B;CAC9B,MAAM,UAAU,cAAc;AAC9B,QAAOA,8CAAc,eAAe,cAAc,MAC/C,eAAiC;AAChC,MAAI,WAAW,WAAW,QAAQ,OAAO,QACvC,QAAO;AAGT,MACE,WAAW,QAAQ,SAAS,QAC5B,CAAC,WAAW,QAAQ,WACpB,CAAC,QAED,QAAO;AAGT,MACE,WAAW,QAAQ,SAAS,QAC5B,WACA,WAAW,QAAQ,YAAY,QAE/B,QAAO;AAET,SAAO;GAEV"}
@@ -0,0 +1,7 @@
1
+ import { ModuleFederation } from "@module-federation/runtime-core";
2
+
3
+ //#region src/utils.d.ts
4
+ declare function getGlobalFederationInstance(name: string, version: string | undefined): ModuleFederation | undefined;
5
+ //#endregion
6
+ export { getGlobalFederationInstance };
7
+ //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js ADDED
@@ -0,0 +1,19 @@
1
+ import { CurrentGlobal } from "@module-federation/runtime-core";
2
+
3
+ //#region src/utils.ts
4
+ function getBuilderId() {
5
+ return typeof FEDERATION_BUILD_IDENTIFIER !== "undefined" ? FEDERATION_BUILD_IDENTIFIER : "";
6
+ }
7
+ function getGlobalFederationInstance(name, version) {
8
+ const buildId = getBuilderId();
9
+ return CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance) => {
10
+ if (buildId && GMInstance.options.id === buildId) return true;
11
+ if (GMInstance.options.name === name && !GMInstance.options.version && !version) return true;
12
+ if (GMInstance.options.name === name && version && GMInstance.options.version === version) return true;
13
+ return false;
14
+ });
15
+ }
16
+
17
+ //#endregion
18
+ export { getGlobalFederationInstance };
19
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { ModuleFederation } from '@module-federation/runtime-core';\nimport { CurrentGlobal } from '@module-federation/runtime-core';\n\n// injected by bundler, so it can not use runtime-core stuff\nexport function getBuilderId(): string {\n //@ts-ignore\n return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined'\n ? //@ts-ignore\n FEDERATION_BUILD_IDENTIFIER\n : '';\n}\n\nexport function getGlobalFederationInstance(\n name: string,\n version: string | undefined,\n): ModuleFederation | undefined {\n const buildId = getBuilderId();\n return CurrentGlobal.__FEDERATION__.__INSTANCES__.find(\n (GMInstance: ModuleFederation) => {\n if (buildId && GMInstance.options.id === buildId) {\n return true;\n }\n\n if (\n GMInstance.options.name === name &&\n !GMInstance.options.version &&\n !version\n ) {\n return true;\n }\n\n if (\n GMInstance.options.name === name &&\n version &&\n GMInstance.options.version === version\n ) {\n return true;\n }\n return false;\n },\n );\n}\n"],"mappings":";;;AAIA,SAAgB,eAAuB;AAErC,QAAO,OAAO,gCAAgC,cAE1C,8BACA;;AAGN,SAAgB,4BACd,MACA,SAC8B;CAC9B,MAAM,UAAU,cAAc;AAC9B,QAAO,cAAc,eAAe,cAAc,MAC/C,eAAiC;AAChC,MAAI,WAAW,WAAW,QAAQ,OAAO,QACvC,QAAO;AAGT,MACE,WAAW,QAAQ,SAAS,QAC5B,CAAC,WAAW,QAAQ,WACpB,CAAC,QAED,QAAO;AAGT,MACE,WAAW,QAAQ,SAAS,QAC5B,WACA,WAAW,QAAQ,YAAY,QAE/B,QAAO;AAET,SAAO;GAEV"}