@module-federation/runtime-core 0.0.0-chore-bump-node-22-20260710161714

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 (166) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/_virtual/_rolldown/runtime.cjs +19 -0
  5. package/dist/_virtual/_rolldown/runtime.js +18 -0
  6. package/dist/constant.cjs +9 -0
  7. package/dist/constant.cjs.map +1 -0
  8. package/dist/constant.js +7 -0
  9. package/dist/constant.js.map +1 -0
  10. package/dist/core.cjs +161 -0
  11. package/dist/core.cjs.map +1 -0
  12. package/dist/core.d.ts +197 -0
  13. package/dist/core.js +161 -0
  14. package/dist/core.js.map +1 -0
  15. package/dist/global.cjs +160 -0
  16. package/dist/global.cjs.map +1 -0
  17. package/dist/global.d.ts +45 -0
  18. package/dist/global.js +142 -0
  19. package/dist/global.js.map +1 -0
  20. package/dist/helpers.cjs +44 -0
  21. package/dist/helpers.cjs.map +1 -0
  22. package/dist/helpers.d.ts +30 -0
  23. package/dist/helpers.js +44 -0
  24. package/dist/helpers.js.map +1 -0
  25. package/dist/index.cjs +60 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.ts +29 -0
  28. package/dist/index.js +20 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/module/index.cjs +266 -0
  31. package/dist/module/index.cjs.map +1 -0
  32. package/dist/module/index.d.ts +32 -0
  33. package/dist/module/index.js +266 -0
  34. package/dist/module/index.js.map +1 -0
  35. package/dist/plugins/generate-preload-assets.cjs +182 -0
  36. package/dist/plugins/generate-preload-assets.cjs.map +1 -0
  37. package/dist/plugins/generate-preload-assets.js +182 -0
  38. package/dist/plugins/generate-preload-assets.js.map +1 -0
  39. package/dist/plugins/snapshot/SnapshotHandler.cjs +215 -0
  40. package/dist/plugins/snapshot/SnapshotHandler.cjs.map +1 -0
  41. package/dist/plugins/snapshot/SnapshotHandler.d.ts +69 -0
  42. package/dist/plugins/snapshot/SnapshotHandler.js +214 -0
  43. package/dist/plugins/snapshot/SnapshotHandler.js.map +1 -0
  44. package/dist/plugins/snapshot/index.cjs +67 -0
  45. package/dist/plugins/snapshot/index.cjs.map +1 -0
  46. package/dist/plugins/snapshot/index.js +66 -0
  47. package/dist/plugins/snapshot/index.js.map +1 -0
  48. package/dist/remote/index.cjs +445 -0
  49. package/dist/remote/index.cjs.map +1 -0
  50. package/dist/remote/index.d.ts +145 -0
  51. package/dist/remote/index.js +445 -0
  52. package/dist/remote/index.js.map +1 -0
  53. package/dist/shared/index.cjs +418 -0
  54. package/dist/shared/index.cjs.map +1 -0
  55. package/dist/shared/index.d.ts +104 -0
  56. package/dist/shared/index.js +418 -0
  57. package/dist/shared/index.js.map +1 -0
  58. package/dist/type/config.d.ts +130 -0
  59. package/dist/type/index.cjs +13 -0
  60. package/dist/type/index.cjs.map +1 -0
  61. package/dist/type/index.d.ts +11 -0
  62. package/dist/type/index.js +8 -0
  63. package/dist/type/index.js.map +1 -0
  64. package/dist/type/plugin.d.ts +27 -0
  65. package/dist/type/preload.d.ts +54 -0
  66. package/dist/types.cjs +0 -0
  67. package/dist/types.d.ts +4 -0
  68. package/dist/types.js +1 -0
  69. package/dist/utils/context.cjs +45 -0
  70. package/dist/utils/context.cjs.map +1 -0
  71. package/dist/utils/context.d.ts +1 -0
  72. package/dist/utils/context.js +44 -0
  73. package/dist/utils/context.js.map +1 -0
  74. package/dist/utils/env.cjs +10 -0
  75. package/dist/utils/env.cjs.map +1 -0
  76. package/dist/utils/env.d.ts +1 -0
  77. package/dist/utils/env.js +10 -0
  78. package/dist/utils/env.js.map +1 -0
  79. package/dist/utils/hooks/asyncHook.cjs +26 -0
  80. package/dist/utils/hooks/asyncHook.cjs.map +1 -0
  81. package/dist/utils/hooks/asyncHook.d.ts +10 -0
  82. package/dist/utils/hooks/asyncHook.js +26 -0
  83. package/dist/utils/hooks/asyncHook.js.map +1 -0
  84. package/dist/utils/hooks/asyncWaterfallHooks.cjs +44 -0
  85. package/dist/utils/hooks/asyncWaterfallHooks.cjs.map +1 -0
  86. package/dist/utils/hooks/asyncWaterfallHooks.d.ts +12 -0
  87. package/dist/utils/hooks/asyncWaterfallHooks.js +44 -0
  88. package/dist/utils/hooks/asyncWaterfallHooks.js.map +1 -0
  89. package/dist/utils/hooks/index.cjs +5 -0
  90. package/dist/utils/hooks/index.d.ts +5 -0
  91. package/dist/utils/hooks/index.js +7 -0
  92. package/dist/utils/hooks/pluginSystem.cjs +37 -0
  93. package/dist/utils/hooks/pluginSystem.cjs.map +1 -0
  94. package/dist/utils/hooks/pluginSystem.d.ts +19 -0
  95. package/dist/utils/hooks/pluginSystem.js +37 -0
  96. package/dist/utils/hooks/pluginSystem.js.map +1 -0
  97. package/dist/utils/hooks/syncHook.cjs +37 -0
  98. package/dist/utils/hooks/syncHook.cjs.map +1 -0
  99. package/dist/utils/hooks/syncHook.d.ts +16 -0
  100. package/dist/utils/hooks/syncHook.js +36 -0
  101. package/dist/utils/hooks/syncHook.js.map +1 -0
  102. package/dist/utils/hooks/syncWaterfallHook.cjs +40 -0
  103. package/dist/utils/hooks/syncWaterfallHook.cjs.map +1 -0
  104. package/dist/utils/hooks/syncWaterfallHook.d.ts +11 -0
  105. package/dist/utils/hooks/syncWaterfallHook.js +39 -0
  106. package/dist/utils/hooks/syncWaterfallHook.js.map +1 -0
  107. package/dist/utils/index.cjs +8 -0
  108. package/dist/utils/index.d.ts +4 -0
  109. package/dist/utils/index.js +9 -0
  110. package/dist/utils/load.cjs +214 -0
  111. package/dist/utils/load.cjs.map +1 -0
  112. package/dist/utils/load.d.ts +16 -0
  113. package/dist/utils/load.js +212 -0
  114. package/dist/utils/load.js.map +1 -0
  115. package/dist/utils/logger.cjs +34 -0
  116. package/dist/utils/logger.cjs.map +1 -0
  117. package/dist/utils/logger.d.ts +10 -0
  118. package/dist/utils/logger.js +31 -0
  119. package/dist/utils/logger.js.map +1 -0
  120. package/dist/utils/manifest.cjs +56 -0
  121. package/dist/utils/manifest.cjs.map +1 -0
  122. package/dist/utils/manifest.d.ts +10 -0
  123. package/dist/utils/manifest.js +53 -0
  124. package/dist/utils/manifest.js.map +1 -0
  125. package/dist/utils/plugin.cjs +27 -0
  126. package/dist/utils/plugin.cjs.map +1 -0
  127. package/dist/utils/plugin.d.ts +1 -0
  128. package/dist/utils/plugin.js +27 -0
  129. package/dist/utils/plugin.js.map +1 -0
  130. package/dist/utils/preload.cjs +212 -0
  131. package/dist/utils/preload.cjs.map +1 -0
  132. package/dist/utils/preload.d.ts +8 -0
  133. package/dist/utils/preload.js +209 -0
  134. package/dist/utils/preload.js.map +1 -0
  135. package/dist/utils/semver/compare.cjs +48 -0
  136. package/dist/utils/semver/compare.cjs.map +1 -0
  137. package/dist/utils/semver/compare.js +47 -0
  138. package/dist/utils/semver/compare.js.map +1 -0
  139. package/dist/utils/semver/constants.cjs +41 -0
  140. package/dist/utils/semver/constants.cjs.map +1 -0
  141. package/dist/utils/semver/constants.js +31 -0
  142. package/dist/utils/semver/constants.js.map +1 -0
  143. package/dist/utils/semver/index.cjs +68 -0
  144. package/dist/utils/semver/index.cjs.map +1 -0
  145. package/dist/utils/semver/index.d.ts +5 -0
  146. package/dist/utils/semver/index.js +68 -0
  147. package/dist/utils/semver/index.js.map +1 -0
  148. package/dist/utils/semver/parser.cjs +104 -0
  149. package/dist/utils/semver/parser.cjs.map +1 -0
  150. package/dist/utils/semver/parser.js +96 -0
  151. package/dist/utils/semver/parser.js.map +1 -0
  152. package/dist/utils/semver/utils.cjs +28 -0
  153. package/dist/utils/semver/utils.cjs.map +1 -0
  154. package/dist/utils/semver/utils.js +24 -0
  155. package/dist/utils/semver/utils.js.map +1 -0
  156. package/dist/utils/share.cjs +284 -0
  157. package/dist/utils/share.cjs.map +1 -0
  158. package/dist/utils/share.d.ts +23 -0
  159. package/dist/utils/share.js +278 -0
  160. package/dist/utils/share.js.map +1 -0
  161. package/dist/utils/tool.cjs +82 -0
  162. package/dist/utils/tool.cjs.map +1 -0
  163. package/dist/utils/tool.d.ts +8 -0
  164. package/dist/utils/tool.js +71 -0
  165. package/dist/utils/tool.js.map +1 -0
  166. package/package.json +65 -0
package/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.
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,19 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+
19
+ exports.__exportAll = __exportAll;
@@ -0,0 +1,18 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll };
@@ -0,0 +1,9 @@
1
+
2
+ //#region src/constant.ts
3
+ const DEFAULT_SCOPE = "default";
4
+ const DEFAULT_REMOTE_TYPE = "global";
5
+
6
+ //#endregion
7
+ exports.DEFAULT_REMOTE_TYPE = DEFAULT_REMOTE_TYPE;
8
+ exports.DEFAULT_SCOPE = DEFAULT_SCOPE;
9
+ //# sourceMappingURL=constant.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.cjs","names":[],"sources":["../src/constant.ts"],"sourcesContent":["export const DEFAULT_SCOPE = 'default';\nexport const DEFAULT_REMOTE_TYPE = 'global';\n"],"mappings":";;AAAA,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB"}
@@ -0,0 +1,7 @@
1
+ //#region src/constant.ts
2
+ const DEFAULT_SCOPE = "default";
3
+ const DEFAULT_REMOTE_TYPE = "global";
4
+
5
+ //#endregion
6
+ export { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE };
7
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","names":[],"sources":["../src/constant.ts"],"sourcesContent":["export const DEFAULT_SCOPE = 'default';\nexport const DEFAULT_REMOTE_TYPE = 'global';\n"],"mappings":";AAAA,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB"}
package/dist/core.cjs ADDED
@@ -0,0 +1,161 @@
1
+ const require_logger = require('./utils/logger.cjs');
2
+ const require_constant = require('./constant.cjs');
3
+ const require_share = require('./utils/share.cjs');
4
+ const require_env = require('./utils/env.cjs');
5
+ const require_plugin = require('./utils/plugin.cjs');
6
+ const require_load = require('./utils/load.cjs');
7
+ require('./utils/index.cjs');
8
+ const require_index$1 = require('./module/index.cjs');
9
+ const require_syncHook = require('./utils/hooks/syncHook.cjs');
10
+ const require_asyncHook = require('./utils/hooks/asyncHook.cjs');
11
+ const require_syncWaterfallHook = require('./utils/hooks/syncWaterfallHook.cjs');
12
+ const require_asyncWaterfallHooks = require('./utils/hooks/asyncWaterfallHooks.cjs');
13
+ const require_pluginSystem = require('./utils/hooks/pluginSystem.cjs');
14
+ require('./utils/hooks/index.cjs');
15
+ const require_index$3 = require('./plugins/snapshot/index.cjs');
16
+ const require_generate_preload_assets = require('./plugins/generate-preload-assets.cjs');
17
+ const require_SnapshotHandler = require('./plugins/snapshot/SnapshotHandler.cjs');
18
+ const require_index$4 = require('./shared/index.cjs');
19
+ const require_index$5 = require('./remote/index.cjs');
20
+ let _module_federation_sdk = require("@module-federation/sdk");
21
+ let _module_federation_error_codes = require("@module-federation/error-codes");
22
+
23
+ //#region src/core.ts
24
+ const USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
25
+ var ModuleFederation = class {
26
+ constructor(userOptions) {
27
+ this.hooks = new require_pluginSystem.PluginSystem({
28
+ beforeInit: new require_syncWaterfallHook.SyncWaterfallHook("beforeInit"),
29
+ init: new require_syncHook.SyncHook(),
30
+ beforeInitContainer: new require_asyncWaterfallHooks.AsyncWaterfallHook("beforeInitContainer"),
31
+ initContainer: new require_asyncWaterfallHooks.AsyncWaterfallHook("initContainer")
32
+ });
33
+ this.version = "0.0.0-chore-bump-node-22-20260710161714";
34
+ this.moduleCache = /* @__PURE__ */ new Map();
35
+ this.loaderHook = new require_pluginSystem.PluginSystem({
36
+ getModuleInfo: new require_syncHook.SyncHook(),
37
+ createScript: new require_syncHook.SyncHook(),
38
+ createLink: new require_syncHook.SyncHook(),
39
+ fetch: new require_asyncHook.AsyncHook(),
40
+ loadEntryError: new require_asyncHook.AsyncHook(),
41
+ afterLoadEntry: new require_asyncHook.AsyncHook("afterLoadEntry"),
42
+ beforeInitRemote: new require_asyncHook.AsyncHook("beforeInitRemote"),
43
+ afterInitRemote: new require_asyncHook.AsyncHook("afterInitRemote"),
44
+ beforeGetExpose: new require_asyncHook.AsyncHook("beforeGetExpose"),
45
+ afterGetExpose: new require_asyncHook.AsyncHook("afterGetExpose"),
46
+ beforeExecuteFactory: new require_asyncHook.AsyncHook("beforeExecuteFactory"),
47
+ afterExecuteFactory: new require_asyncHook.AsyncHook("afterExecuteFactory"),
48
+ getModuleFactory: new require_asyncHook.AsyncHook()
49
+ });
50
+ this.bridgeHook = new require_pluginSystem.PluginSystem({
51
+ beforeBridgeRender: new require_syncHook.SyncHook(),
52
+ afterBridgeRender: new require_syncHook.SyncHook(),
53
+ beforeBridgeDestroy: new require_syncHook.SyncHook(),
54
+ afterBridgeDestroy: new require_syncHook.SyncHook()
55
+ });
56
+ const plugins = USE_SNAPSHOT ? [require_index$3.snapshotPlugin(), require_generate_preload_assets.generatePreloadAssetsPlugin()] : [];
57
+ const defaultOptions = {
58
+ id: require_env.getBuilderId(),
59
+ name: userOptions.name,
60
+ plugins,
61
+ remotes: [],
62
+ shared: {},
63
+ inBrowser: _module_federation_sdk.isBrowserEnvValue
64
+ };
65
+ this.name = userOptions.name;
66
+ this.options = defaultOptions;
67
+ this.snapshotHandler = new require_SnapshotHandler.SnapshotHandler(this);
68
+ this.sharedHandler = new require_index$4.SharedHandler(this);
69
+ this.remoteHandler = new require_index$5.RemoteHandler(this);
70
+ this.shareScopeMap = this.sharedHandler.shareScopeMap;
71
+ this.registerPlugins([...defaultOptions.plugins, ...userOptions.plugins || []]);
72
+ this.options = this.formatOptions(defaultOptions, userOptions);
73
+ }
74
+ initOptions(userOptions) {
75
+ if (userOptions.name && userOptions.name !== this.options.name) require_logger.error((0, _module_federation_error_codes.getShortErrorMsg)(_module_federation_error_codes.RUNTIME_010, _module_federation_error_codes.runtimeDescMap));
76
+ this.registerPlugins(userOptions.plugins);
77
+ const options = this.formatOptions(this.options, userOptions);
78
+ this.options = options;
79
+ return options;
80
+ }
81
+ async loadShare(pkgName, extraOptions) {
82
+ return this.sharedHandler.loadShare(pkgName, extraOptions);
83
+ }
84
+ loadShareSync(pkgName, extraOptions) {
85
+ return this.sharedHandler.loadShareSync(pkgName, extraOptions);
86
+ }
87
+ initializeSharing(shareScopeName = require_constant.DEFAULT_SCOPE, extraOptions) {
88
+ return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);
89
+ }
90
+ initRawContainer(name, url, container) {
91
+ const remoteInfo = require_load.getRemoteInfo({
92
+ name,
93
+ entry: url
94
+ });
95
+ const module = new require_index$1.Module({
96
+ host: this,
97
+ remoteInfo
98
+ });
99
+ module.remoteEntryExports = container;
100
+ this.moduleCache.set(name, module);
101
+ return module;
102
+ }
103
+ async loadRemote(id, options) {
104
+ return this.remoteHandler.loadRemote(id, options);
105
+ }
106
+ async preloadRemote(preloadOptions) {
107
+ return this.remoteHandler.preloadRemote(preloadOptions);
108
+ }
109
+ initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
110
+ this.sharedHandler.initShareScopeMap(scopeName, shareScope, extraOptions);
111
+ }
112
+ formatOptions(globalOptions, userOptions) {
113
+ const { allShareInfos: shared } = require_share.formatShareConfigs(globalOptions, userOptions);
114
+ const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
115
+ origin: this,
116
+ userOptions,
117
+ options: globalOptions,
118
+ shareInfo: shared
119
+ });
120
+ const remotes = this.remoteHandler.formatAndRegisterRemote(globalOptionsRes, userOptionsRes);
121
+ const { allShareInfos } = this.sharedHandler.registerShared(globalOptionsRes, userOptionsRes);
122
+ const plugins = [...globalOptionsRes.plugins];
123
+ if (userOptionsRes.plugins) userOptionsRes.plugins.forEach((plugin) => {
124
+ if (!plugins.includes(plugin)) plugins.push(plugin);
125
+ });
126
+ const optionsRes = {
127
+ ...globalOptions,
128
+ ...userOptions,
129
+ plugins,
130
+ remotes,
131
+ shared: allShareInfos,
132
+ id: userOptionsRes.id || globalOptions.id
133
+ };
134
+ this.hooks.lifecycle.init.emit({
135
+ origin: this,
136
+ options: optionsRes
137
+ });
138
+ return optionsRes;
139
+ }
140
+ registerPlugins(plugins) {
141
+ const pluginRes = require_plugin.registerPlugins(plugins, this);
142
+ this.options.plugins = this.options.plugins.reduce((res, plugin) => {
143
+ if (!plugin) return res;
144
+ if (res && !res.find((item) => item.name === plugin.name)) res.push(plugin);
145
+ return res;
146
+ }, pluginRes || []);
147
+ }
148
+ registerRemotes(remotes, options) {
149
+ return this.remoteHandler.registerRemotes(remotes, options);
150
+ }
151
+ registerShared(shared) {
152
+ this.sharedHandler.registerShared(this.options, {
153
+ ...this.options,
154
+ shared
155
+ });
156
+ }
157
+ };
158
+
159
+ //#endregion
160
+ exports.ModuleFederation = ModuleFederation;
161
+ //# sourceMappingURL=core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.cjs","names":["PluginSystem","SyncWaterfallHook","SyncHook","AsyncWaterfallHook","AsyncHook","snapshotPlugin","generatePreloadAssetsPlugin","getBuilderId","isBrowserEnvValue","SnapshotHandler","SharedHandler","RemoteHandler","RUNTIME_010","runtimeDescMap","DEFAULT_SCOPE","getRemoteInfo","Module","formatShareConfigs","registerPlugins"],"sources":["../src/core.ts"],"sourcesContent":["import { isBrowserEnvValue } from '@module-federation/sdk';\nimport type {\n CreateLinkHookReturnDom,\n CreateScriptHookReturn,\n GlobalModuleInfo,\n ModuleInfo,\n} from '@module-federation/sdk';\nimport {\n Options,\n PreloadRemoteArgs,\n RemoteEntryExports,\n Remote,\n Shared,\n ShareInfos,\n UserOptions,\n RemoteInfo,\n ShareScopeMap,\n InitScope,\n RemoteEntryInitOptions,\n CallFrom,\n ResourceLoadContext,\n} from './type';\nimport { getBuilderId, registerPlugins, getRemoteEntry, error } from './utils';\nimport {\n getShortErrorMsg,\n RUNTIME_010,\n runtimeDescMap,\n} from '@module-federation/error-codes';\nimport { Module, type RemoteModuleFactory } from './module';\nimport {\n AsyncHook,\n AsyncWaterfallHook,\n PluginSystem,\n SyncHook,\n SyncWaterfallHook,\n} from './utils/hooks';\nimport { generatePreloadAssetsPlugin } from './plugins/generate-preload-assets';\nimport { snapshotPlugin } from './plugins/snapshot';\nimport { getRemoteInfo } from './utils/load';\nimport { DEFAULT_SCOPE } from './constant';\nimport { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';\nimport { SharedHandler } from './shared';\nimport { RemoteHandler } from './remote';\nimport { formatShareConfigs } from './utils/share';\n\n// Declare the global constant that will be defined by DefinePlugin\n// Default to true if not defined (e.g., when runtime-core is used outside of webpack)\n// so that snapshot functionality is included by default.\ndeclare const FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN: boolean;\nconst USE_SNAPSHOT =\n typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === 'boolean'\n ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN\n : true; // Default to true (use snapshot) when not explicitly defined\n\nexport class ModuleFederation {\n options: Options;\n hooks = new PluginSystem({\n beforeInit: new SyncWaterfallHook<{\n userOptions: UserOptions;\n options: Options;\n origin: ModuleFederation;\n /**\n * @deprecated shareInfo will be removed soon, please use userOptions directly!\n */\n shareInfo: ShareInfos;\n }>('beforeInit'),\n init: new SyncHook<\n [\n {\n options: Options;\n origin: ModuleFederation;\n },\n ],\n void\n >(),\n // maybe will change, temporarily for internal use only\n beforeInitContainer: new AsyncWaterfallHook<{\n shareScope: ShareScopeMap[string];\n initScope: InitScope;\n remoteEntryInitOptions: RemoteEntryInitOptions;\n remoteInfo: RemoteInfo;\n origin: ModuleFederation;\n }>('beforeInitContainer'),\n // maybe will change, temporarily for internal use only\n initContainer: new AsyncWaterfallHook<{\n shareScope: ShareScopeMap[string];\n initScope: InitScope;\n remoteEntryInitOptions: RemoteEntryInitOptions;\n remoteInfo: RemoteInfo;\n remoteEntryExports: RemoteEntryExports;\n origin: ModuleFederation;\n id?: string;\n remoteSnapshot?: ModuleInfo;\n }>('initContainer'),\n });\n version: string = __VERSION__;\n name: string;\n moduleCache: Map<string, Module> = new Map();\n snapshotHandler: SnapshotHandler;\n sharedHandler: SharedHandler;\n remoteHandler: RemoteHandler;\n shareScopeMap: ShareScopeMap;\n loaderHook = new PluginSystem({\n // FIXME: may not be suitable , not open to the public yet\n getModuleInfo: new SyncHook<\n [\n {\n target: Record<string, any>;\n key: any;\n },\n ],\n { value: any | undefined; key: string } | void\n >(),\n createScript: new SyncHook<\n [\n {\n url: string;\n attrs?: Record<string, any>;\n /**\n * The producer(remote) info bound to this resource.\n * Only present when the loader is invoked in a remote-related context\n * (e.g. preloadRemote / loading remoteEntry).\n */\n remoteInfo?: RemoteInfo;\n resourceContext?: ResourceLoadContext;\n },\n ],\n CreateScriptHookReturn\n >(),\n createLink: new SyncHook<\n [\n {\n url: string;\n attrs?: Record<string, any>;\n /**\n * The producer(remote) info bound to this resource.\n * Only present when the loader is invoked in a remote-related context\n * (e.g. preloadRemote / loading remoteEntry).\n */\n remoteInfo?: RemoteInfo;\n resourceContext?: ResourceLoadContext;\n },\n ],\n CreateLinkHookReturnDom\n >(),\n fetch: new AsyncHook<\n [string, RequestInit, RemoteInfo?, ResourceLoadContext?],\n Promise<Response> | void | false\n >(),\n loadEntryError: new AsyncHook<\n [\n {\n getRemoteEntry: typeof getRemoteEntry;\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | undefined;\n globalLoading: Record<\n string,\n Promise<void | RemoteEntryExports> | undefined\n >;\n uniqueKey: string;\n },\n ],\n Promise<Promise<RemoteEntryExports | undefined> | undefined>\n >(),\n afterLoadEntry: new AsyncHook<\n [\n {\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | false | void;\n error?: unknown;\n recovered?: boolean;\n },\n ],\n void\n >('afterLoadEntry'),\n beforeInitRemote: new AsyncHook<\n [\n {\n id?: string;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n origin: ModuleFederation;\n },\n ],\n void\n >('beforeInitRemote'),\n afterInitRemote: new AsyncHook<\n [\n {\n id?: string;\n remoteInfo: RemoteInfo;\n remoteSnapshot?: ModuleInfo;\n remoteEntryExports?: RemoteEntryExports;\n error?: unknown;\n cached?: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterInitRemote'),\n beforeGetExpose: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n remoteEntryExports: RemoteEntryExports;\n origin: ModuleFederation;\n },\n ],\n void\n >('beforeGetExpose'),\n afterGetExpose: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n remoteEntryExports: RemoteEntryExports;\n moduleFactory?: RemoteModuleFactory;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterGetExpose'),\n beforeExecuteFactory: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n loadFactory: boolean;\n origin: ModuleFederation;\n },\n ],\n void\n >('beforeExecuteFactory'),\n afterExecuteFactory: new AsyncHook<\n [\n {\n id: string;\n expose: string;\n moduleInfo: RemoteInfo;\n loadFactory: boolean;\n exposeModule?: unknown;\n error?: unknown;\n origin: ModuleFederation;\n },\n ],\n void\n >('afterExecuteFactory'),\n getModuleFactory: new AsyncHook<\n [\n {\n remoteEntryExports: RemoteEntryExports;\n expose: string;\n moduleInfo: RemoteInfo;\n },\n ],\n RemoteModuleFactory | Promise<RemoteModuleFactory | undefined> | undefined\n >(),\n });\n bridgeHook = new PluginSystem({\n beforeBridgeRender: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n afterBridgeRender: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n beforeBridgeDestroy: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n afterBridgeDestroy: new SyncHook<\n [Record<string, any>],\n void | Record<string, any>\n >(),\n });\n moduleInfo?: GlobalModuleInfo[string];\n\n constructor(userOptions: UserOptions) {\n const plugins = USE_SNAPSHOT\n ? [snapshotPlugin(), generatePreloadAssetsPlugin()]\n : [];\n // TODO: Validate the details of the options\n // Initialize options with default values\n const defaultOptions: Options = {\n id: getBuilderId(),\n name: userOptions.name,\n plugins,\n remotes: [],\n shared: {},\n inBrowser: isBrowserEnvValue,\n };\n\n this.name = userOptions.name;\n this.options = defaultOptions;\n this.snapshotHandler = new SnapshotHandler(this);\n this.sharedHandler = new SharedHandler(this);\n this.remoteHandler = new RemoteHandler(this);\n this.shareScopeMap = this.sharedHandler.shareScopeMap;\n this.registerPlugins([\n ...defaultOptions.plugins,\n ...(userOptions.plugins || []),\n ]);\n this.options = this.formatOptions(defaultOptions, userOptions);\n }\n\n initOptions(userOptions: UserOptions): Options {\n if (userOptions.name && userOptions.name !== this.options.name) {\n error(getShortErrorMsg(RUNTIME_010, runtimeDescMap));\n }\n this.registerPlugins(userOptions.plugins);\n const options = this.formatOptions(this.options, userOptions);\n\n this.options = options;\n\n return options;\n }\n\n async loadShare<T>(\n pkgName: string,\n extraOptions?: {\n customShareInfo?: Partial<Shared>;\n resolver?: (sharedOptions: ShareInfos[string]) => Shared;\n },\n ): Promise<false | (() => T | undefined)> {\n return this.sharedHandler.loadShare(pkgName, extraOptions);\n }\n\n // The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.\n // 1. If the loaded shared already exists globally, then it will be reused\n // 2. If lib exists in local shared, it will be used directly\n // 3. If the local get returns something other than Promise, then it will be used directly\n loadShareSync<T>(\n pkgName: string,\n extraOptions?: {\n customShareInfo?: Partial<Shared>;\n from?: 'build' | 'runtime';\n resolver?: (sharedOptions: ShareInfos[string]) => Shared;\n },\n ): () => T | never {\n return this.sharedHandler.loadShareSync(pkgName, extraOptions);\n }\n\n initializeSharing(\n shareScopeName = DEFAULT_SCOPE,\n extraOptions?: {\n initScope?: InitScope;\n from?: CallFrom;\n strategy?: Shared['strategy'];\n },\n ): Array<Promise<void>> {\n return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);\n }\n\n initRawContainer(\n name: string,\n url: string,\n container: RemoteEntryExports,\n ): Module {\n const remoteInfo = getRemoteInfo({ name, entry: url });\n const module = new Module({ host: this, remoteInfo });\n\n module.remoteEntryExports = container;\n this.moduleCache.set(name, module);\n\n return module;\n }\n\n // eslint-disable-next-line max-lines-per-function\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async loadRemote<T>(\n id: string,\n options?: { loadFactory?: boolean; from: CallFrom },\n ): Promise<T | null> {\n return this.remoteHandler.loadRemote(id, options);\n }\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n async preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void> {\n return this.remoteHandler.preloadRemote(preloadOptions);\n }\n\n initShareScopeMap(\n scopeName: string,\n shareScope: ShareScopeMap[string],\n extraOptions: { hostShareScopeMap?: ShareScopeMap } = {},\n ): void {\n this.sharedHandler.initShareScopeMap(scopeName, shareScope, extraOptions);\n }\n\n formatOptions(globalOptions: Options, userOptions: UserOptions): Options {\n const { allShareInfos: shared } = formatShareConfigs(\n globalOptions,\n userOptions,\n );\n const { userOptions: userOptionsRes, options: globalOptionsRes } =\n this.hooks.lifecycle.beforeInit.emit({\n origin: this,\n userOptions,\n options: globalOptions,\n shareInfo: shared,\n });\n\n const remotes = this.remoteHandler.formatAndRegisterRemote(\n globalOptionsRes,\n userOptionsRes,\n );\n\n const { allShareInfos } = this.sharedHandler.registerShared(\n globalOptionsRes,\n userOptionsRes,\n );\n\n const plugins = [...globalOptionsRes.plugins];\n\n if (userOptionsRes.plugins) {\n userOptionsRes.plugins.forEach((plugin) => {\n if (!plugins.includes(plugin)) {\n plugins.push(plugin);\n }\n });\n }\n\n const optionsRes: Options = {\n ...globalOptions,\n ...userOptions,\n plugins,\n remotes,\n shared: allShareInfos,\n id: userOptionsRes.id || globalOptions.id,\n };\n\n this.hooks.lifecycle.init.emit({\n origin: this,\n options: optionsRes,\n });\n return optionsRes;\n }\n\n registerPlugins(plugins: UserOptions['plugins']) {\n const pluginRes = registerPlugins(plugins, this);\n // Merge plugin\n this.options.plugins = this.options.plugins.reduce((res, plugin) => {\n if (!plugin) return res;\n if (res && !res.find((item) => item.name === plugin.name)) {\n res.push(plugin);\n }\n return res;\n }, pluginRes || []);\n }\n registerRemotes(remotes: Remote[], options?: { force?: boolean }): void {\n return this.remoteHandler.registerRemotes(remotes, options);\n }\n\n registerShared(shared: UserOptions['shared']) {\n this.sharedHandler.registerShared(this.options, {\n ...this.options,\n shared,\n });\n }\n}\n"],"mappings":"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"}
package/dist/core.d.ts ADDED
@@ -0,0 +1,197 @@
1
+ import { Module as Module$1, RemoteModuleFactory } from "./module/index.js";
2
+ import { SyncHook } from "./utils/hooks/syncHook.js";
3
+ import { AsyncHook } from "./utils/hooks/asyncHook.js";
4
+ import { SyncWaterfallHook } from "./utils/hooks/syncWaterfallHook.js";
5
+ import { AsyncWaterfallHook } from "./utils/hooks/asyncWaterfallHooks.js";
6
+ import { PluginSystem } from "./utils/hooks/pluginSystem.js";
7
+ import { SnapshotHandler } from "./plugins/snapshot/SnapshotHandler.js";
8
+ import { RemoteHandler } from "./remote/index.js";
9
+ import { SharedHandler } from "./shared/index.js";
10
+ import { CallFrom, InitScope, Options, Remote, RemoteEntryExports, RemoteEntryInitOptions, RemoteInfo, ShareInfos, ShareScopeMap, Shared, UserOptions } from "./type/config.js";
11
+ import { PreloadRemoteArgs, ResourceLoadContext } from "./type/preload.js";
12
+ import { getRemoteEntry } from "./utils/load.js";
13
+ import { CreateLinkHookReturnDom, CreateScriptHookReturn, GlobalModuleInfo, ModuleInfo } from "@module-federation/sdk";
14
+
15
+ //#region src/core.d.ts
16
+ declare class ModuleFederation {
17
+ options: Options;
18
+ hooks: PluginSystem<{
19
+ beforeInit: SyncWaterfallHook<{
20
+ userOptions: UserOptions;
21
+ options: Options;
22
+ origin: ModuleFederation;
23
+ /**
24
+ * @deprecated shareInfo will be removed soon, please use userOptions directly!
25
+ */
26
+ shareInfo: ShareInfos;
27
+ }>;
28
+ init: SyncHook<[{
29
+ options: Options;
30
+ origin: ModuleFederation;
31
+ }], void>;
32
+ beforeInitContainer: AsyncWaterfallHook<{
33
+ shareScope: ShareScopeMap[string];
34
+ initScope: InitScope;
35
+ remoteEntryInitOptions: RemoteEntryInitOptions;
36
+ remoteInfo: RemoteInfo;
37
+ origin: ModuleFederation;
38
+ }>;
39
+ initContainer: AsyncWaterfallHook<{
40
+ shareScope: ShareScopeMap[string];
41
+ initScope: InitScope;
42
+ remoteEntryInitOptions: RemoteEntryInitOptions;
43
+ remoteInfo: RemoteInfo;
44
+ remoteEntryExports: RemoteEntryExports;
45
+ origin: ModuleFederation;
46
+ id?: string;
47
+ remoteSnapshot?: ModuleInfo;
48
+ }>;
49
+ }>;
50
+ version: string;
51
+ name: string;
52
+ moduleCache: Map<string, Module$1>;
53
+ snapshotHandler: SnapshotHandler;
54
+ sharedHandler: SharedHandler;
55
+ remoteHandler: RemoteHandler;
56
+ shareScopeMap: ShareScopeMap;
57
+ loaderHook: PluginSystem<{
58
+ getModuleInfo: SyncHook<[{
59
+ target: Record<string, any>;
60
+ key: any;
61
+ }], void | {
62
+ value: any | undefined;
63
+ key: string;
64
+ }>;
65
+ createScript: SyncHook<[{
66
+ url: string;
67
+ attrs?: Record<string, any>;
68
+ /**
69
+ * The producer(remote) info bound to this resource.
70
+ * Only present when the loader is invoked in a remote-related context
71
+ * (e.g. preloadRemote / loading remoteEntry).
72
+ */
73
+ remoteInfo?: RemoteInfo;
74
+ resourceContext?: ResourceLoadContext;
75
+ }], CreateScriptHookReturn>;
76
+ createLink: SyncHook<[{
77
+ url: string;
78
+ attrs?: Record<string, any>;
79
+ /**
80
+ * The producer(remote) info bound to this resource.
81
+ * Only present when the loader is invoked in a remote-related context
82
+ * (e.g. preloadRemote / loading remoteEntry).
83
+ */
84
+ remoteInfo?: RemoteInfo;
85
+ resourceContext?: ResourceLoadContext;
86
+ }], CreateLinkHookReturnDom>;
87
+ fetch: AsyncHook<[string, RequestInit, (RemoteInfo | undefined)?, (ResourceLoadContext | undefined)?], false | void | Promise<Response>>;
88
+ loadEntryError: AsyncHook<[{
89
+ getRemoteEntry: typeof getRemoteEntry;
90
+ origin: ModuleFederation;
91
+ remoteInfo: RemoteInfo;
92
+ remoteEntryExports?: RemoteEntryExports | undefined;
93
+ globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
94
+ uniqueKey: string;
95
+ }], Promise<Promise<RemoteEntryExports | undefined> | undefined>>;
96
+ afterLoadEntry: AsyncHook<[{
97
+ origin: ModuleFederation;
98
+ remoteInfo: RemoteInfo;
99
+ remoteEntryExports?: false | void | RemoteEntryExports | undefined;
100
+ error?: unknown;
101
+ recovered?: boolean;
102
+ }], void>;
103
+ beforeInitRemote: AsyncHook<[{
104
+ id?: string;
105
+ remoteInfo: RemoteInfo;
106
+ remoteSnapshot?: ModuleInfo;
107
+ origin: ModuleFederation;
108
+ }], void>;
109
+ afterInitRemote: AsyncHook<[{
110
+ id?: string;
111
+ remoteInfo: RemoteInfo;
112
+ remoteSnapshot?: ModuleInfo;
113
+ remoteEntryExports?: RemoteEntryExports;
114
+ error?: unknown;
115
+ cached?: boolean;
116
+ origin: ModuleFederation;
117
+ }], void>;
118
+ beforeGetExpose: AsyncHook<[{
119
+ id: string;
120
+ expose: string;
121
+ moduleInfo: RemoteInfo;
122
+ remoteEntryExports: RemoteEntryExports;
123
+ origin: ModuleFederation;
124
+ }], void>;
125
+ afterGetExpose: AsyncHook<[{
126
+ id: string;
127
+ expose: string;
128
+ moduleInfo: RemoteInfo;
129
+ remoteEntryExports: RemoteEntryExports;
130
+ moduleFactory?: RemoteModuleFactory;
131
+ error?: unknown;
132
+ origin: ModuleFederation;
133
+ }], void>;
134
+ beforeExecuteFactory: AsyncHook<[{
135
+ id: string;
136
+ expose: string;
137
+ moduleInfo: RemoteInfo;
138
+ loadFactory: boolean;
139
+ origin: ModuleFederation;
140
+ }], void>;
141
+ afterExecuteFactory: AsyncHook<[{
142
+ id: string;
143
+ expose: string;
144
+ moduleInfo: RemoteInfo;
145
+ loadFactory: boolean;
146
+ exposeModule?: unknown;
147
+ error?: unknown;
148
+ origin: ModuleFederation;
149
+ }], void>;
150
+ getModuleFactory: AsyncHook<[{
151
+ remoteEntryExports: RemoteEntryExports;
152
+ expose: string;
153
+ moduleInfo: RemoteInfo;
154
+ }], RemoteModuleFactory | Promise<RemoteModuleFactory | undefined> | undefined>;
155
+ }>;
156
+ bridgeHook: PluginSystem<{
157
+ beforeBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
158
+ afterBridgeRender: SyncHook<[Record<string, any>], void | Record<string, any>>;
159
+ beforeBridgeDestroy: SyncHook<[Record<string, any>], void | Record<string, any>>;
160
+ afterBridgeDestroy: SyncHook<[Record<string, any>], void | Record<string, any>>;
161
+ }>;
162
+ moduleInfo?: GlobalModuleInfo[string];
163
+ constructor(userOptions: UserOptions);
164
+ initOptions(userOptions: UserOptions): Options;
165
+ loadShare<T>(pkgName: string, extraOptions?: {
166
+ customShareInfo?: Partial<Shared>;
167
+ resolver?: (sharedOptions: ShareInfos[string]) => Shared;
168
+ }): Promise<false | (() => T | undefined)>;
169
+ loadShareSync<T>(pkgName: string, extraOptions?: {
170
+ customShareInfo?: Partial<Shared>;
171
+ from?: 'build' | 'runtime';
172
+ resolver?: (sharedOptions: ShareInfos[string]) => Shared;
173
+ }): () => T | never;
174
+ initializeSharing(shareScopeName?: string, extraOptions?: {
175
+ initScope?: InitScope;
176
+ from?: CallFrom;
177
+ strategy?: Shared['strategy'];
178
+ }): Array<Promise<void>>;
179
+ initRawContainer(name: string, url: string, container: RemoteEntryExports): Module$1;
180
+ loadRemote<T>(id: string, options?: {
181
+ loadFactory?: boolean;
182
+ from: CallFrom;
183
+ }): Promise<T | null>;
184
+ preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
185
+ initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
186
+ hostShareScopeMap?: ShareScopeMap;
187
+ }): void;
188
+ formatOptions(globalOptions: Options, userOptions: UserOptions): Options;
189
+ registerPlugins(plugins: UserOptions['plugins']): void;
190
+ registerRemotes(remotes: Remote[], options?: {
191
+ force?: boolean;
192
+ }): void;
193
+ registerShared(shared: UserOptions['shared']): void;
194
+ }
195
+ //#endregion
196
+ export { ModuleFederation };
197
+ //# sourceMappingURL=core.d.ts.map