@module-federation/node 2.7.31 → 2.7.33

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 (122) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +31 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  3. package/dist/plugins/ChunkCorrelationPlugin.js +308 -0
  4. package/dist/plugins/ChunkCorrelationPlugin.js.map +1 -0
  5. package/dist/plugins/ChunkCorrelationPlugin.mjs +305 -0
  6. package/dist/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
  7. package/dist/src/filesystem/stratagies.d.mts +21 -0
  8. package/dist/src/filesystem/stratagies.d.ts +10 -7
  9. package/dist/src/filesystem/stratagies.js +97 -116
  10. package/dist/src/filesystem/stratagies.js.map +1 -1
  11. package/dist/src/filesystem/stratagies.mjs +103 -0
  12. package/dist/src/filesystem/stratagies.mjs.map +1 -0
  13. package/dist/src/index.d.mts +8 -0
  14. package/dist/src/index.d.ts +8 -7
  15. package/dist/src/index.js +16 -22
  16. package/dist/src/index.mjs +9 -0
  17. package/dist/src/plugins/AutomaticPublicPathPlugin.d.mts +12 -0
  18. package/dist/src/plugins/AutomaticPublicPathPlugin.d.ts +9 -7
  19. package/dist/src/plugins/AutomaticPublicPathPlugin.js +26 -35
  20. package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -1
  21. package/dist/src/plugins/AutomaticPublicPathPlugin.mjs +28 -0
  22. package/dist/src/plugins/AutomaticPublicPathPlugin.mjs.map +1 -0
  23. package/dist/src/plugins/ChunkCorrelationPlugin.d.mts +5 -0
  24. package/dist/src/plugins/ChunkCorrelationPlugin.d.ts +4 -61
  25. package/dist/src/plugins/ChunkCorrelationPlugin.js +8 -440
  26. package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -1
  27. package/dist/src/plugins/ChunkCorrelationPlugin.mjs +8 -0
  28. package/dist/src/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
  29. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.mts +21 -0
  30. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.ts +16 -13
  31. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js +68 -118
  32. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
  33. package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs +70 -0
  34. package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs.map +1 -0
  35. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +46 -0
  36. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +39 -34
  37. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +110 -126
  38. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -1
  39. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs +111 -0
  40. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs.map +1 -0
  41. package/dist/src/plugins/EntryChunkTrackerPlugin.d.mts +17 -0
  42. package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +14 -10
  43. package/dist/src/plugins/EntryChunkTrackerPlugin.js +30 -32
  44. package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -1
  45. package/dist/src/plugins/EntryChunkTrackerPlugin.mjs +38 -0
  46. package/dist/src/plugins/EntryChunkTrackerPlugin.mjs.map +1 -0
  47. package/dist/src/plugins/NodeFederationPlugin.d.mts +54 -0
  48. package/dist/src/plugins/NodeFederationPlugin.d.ts +33 -26
  49. package/dist/src/plugins/NodeFederationPlugin.js +69 -84
  50. package/dist/src/plugins/NodeFederationPlugin.js.map +1 -1
  51. package/dist/src/plugins/NodeFederationPlugin.mjs +70 -0
  52. package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -0
  53. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.mts +15 -0
  54. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +12 -8
  55. package/dist/src/plugins/RemotePublicPathRuntimeModule.js +34 -35
  56. package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -1
  57. package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs +132 -0
  58. package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs.map +1 -0
  59. package/dist/src/plugins/StreamingTargetPlugin.d.mts +32 -0
  60. package/dist/src/plugins/StreamingTargetPlugin.d.ts +19 -16
  61. package/dist/src/plugins/StreamingTargetPlugin.js +43 -56
  62. package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -1
  63. package/dist/src/plugins/StreamingTargetPlugin.mjs +46 -0
  64. package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -0
  65. package/dist/src/plugins/UniversalFederationPlugin.d.mts +49 -0
  66. package/dist/src/plugins/UniversalFederationPlugin.d.ts +26 -23
  67. package/dist/src/plugins/UniversalFederationPlugin.js +58 -81
  68. package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -1
  69. package/dist/src/plugins/UniversalFederationPlugin.mjs +61 -0
  70. package/dist/src/plugins/UniversalFederationPlugin.mjs.map +1 -0
  71. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.mts +9 -0
  72. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.ts +6 -3
  73. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js +17 -17
  74. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js.map +1 -1
  75. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs +25 -0
  76. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs.map +1 -0
  77. package/dist/src/plugins/webpackChunkUtilities.d.mts +55 -0
  78. package/dist/src/plugins/webpackChunkUtilities.d.ts +14 -9
  79. package/dist/src/plugins/webpackChunkUtilities.js +195 -257
  80. package/dist/src/plugins/webpackChunkUtilities.js.map +1 -1
  81. package/dist/src/plugins/webpackChunkUtilities.mjs +234 -0
  82. package/dist/src/plugins/webpackChunkUtilities.mjs.map +1 -0
  83. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.mts +7 -0
  84. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.ts +5 -2
  85. package/dist/src/recordDynamicRemoteEntryHashPlugin.js +24 -61
  86. package/dist/src/recordDynamicRemoteEntryHashPlugin.js.map +1 -1
  87. package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs +26 -0
  88. package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs.map +1 -0
  89. package/dist/src/runtimePlugin.d.mts +27 -0
  90. package/dist/src/runtimePlugin.d.ts +24 -19
  91. package/dist/src/runtimePlugin.js +157 -252
  92. package/dist/src/runtimePlugin.js.map +1 -1
  93. package/dist/src/runtimePlugin.mjs +169 -0
  94. package/dist/src/runtimePlugin.mjs.map +1 -0
  95. package/dist/src/types/index.d.mts +8 -0
  96. package/dist/src/types/index.d.ts +8 -3
  97. package/dist/src/types/index.js +1 -3
  98. package/dist/src/types/index.mjs +1 -0
  99. package/dist/src/utils/flush-chunks.d.mts +15 -0
  100. package/dist/src/utils/flush-chunks.d.ts +7 -3
  101. package/dist/src/utils/flush-chunks.js +87 -161
  102. package/dist/src/utils/flush-chunks.js.map +1 -1
  103. package/dist/src/utils/flush-chunks.mjs +99 -0
  104. package/dist/src/utils/flush-chunks.mjs.map +1 -0
  105. package/dist/src/utils/hot-reload.d.mts +16 -0
  106. package/dist/src/utils/hot-reload.d.ts +14 -10
  107. package/dist/src/utils/hot-reload.js +177 -264
  108. package/dist/src/utils/hot-reload.js.map +1 -1
  109. package/dist/src/utils/hot-reload.mjs +194 -0
  110. package/dist/src/utils/hot-reload.mjs.map +1 -0
  111. package/dist/src/utils/index.d.mts +3 -0
  112. package/dist/src/utils/index.d.ts +3 -2
  113. package/dist/src/utils/index.js +15 -19
  114. package/dist/src/utils/index.mjs +4 -0
  115. package/package.json +59 -15
  116. package/dist/jest.config.d.ts +0 -11
  117. package/dist/jest.config.js +0 -19
  118. package/dist/jest.config.js.map +0 -1
  119. package/dist/package.json +0 -82
  120. package/dist/src/index.js.map +0 -1
  121. package/dist/src/types/index.js.map +0 -1
  122. package/dist/src/utils/index.js.map +0 -1
@@ -0,0 +1,169 @@
1
+ //#region src/runtimePlugin.ts
2
+ const nodeRuntimeImportCache = /* @__PURE__ */ new Map();
3
+ function importNodeModule(name) {
4
+ if (!name) throw new Error("import specifier is required");
5
+ if (nodeRuntimeImportCache.has(name)) return nodeRuntimeImportCache.get(name);
6
+ const promise = new Function("name", `return import(name)`)(name).then((res) => res.default).catch((error) => {
7
+ console.error(`Error importing module ${name}:`, error);
8
+ nodeRuntimeImportCache.delete(name);
9
+ throw error;
10
+ });
11
+ nodeRuntimeImportCache.set(name, promise);
12
+ return promise;
13
+ }
14
+ const resolveFile = (rootOutputDir, chunkId) => {
15
+ return __non_webpack_require__("path").join(__dirname, rootOutputDir + __webpack_require__.u(chunkId));
16
+ };
17
+ const returnFromCache = (remoteName) => {
18
+ const federationInstances = new Function("return globalThis")()["__FEDERATION__"]["__INSTANCES__"];
19
+ for (const instance of federationInstances) {
20
+ const moduleContainer = instance.moduleCache.get(remoteName);
21
+ if (moduleContainer?.remoteInfo) return moduleContainer.remoteInfo.entry;
22
+ }
23
+ return null;
24
+ };
25
+ const returnFromGlobalInstances = (remoteName) => {
26
+ const federationInstances = new Function("return globalThis")()["__FEDERATION__"]["__INSTANCES__"];
27
+ for (const instance of federationInstances) for (const remote of instance.options.remotes) if (remote.name === remoteName || remote.alias === remoteName) {
28
+ console.log("Backup remote entry found:", remote.entry);
29
+ return remote.entry;
30
+ }
31
+ return null;
32
+ };
33
+ const loadFromFs = (filename, callback) => {
34
+ const fs = __non_webpack_require__("fs");
35
+ const path = __non_webpack_require__("path");
36
+ const vm = __non_webpack_require__("vm");
37
+ if (fs.existsSync(filename)) fs.readFile(filename, "utf-8", (err, content) => {
38
+ if (err) return callback(err, null);
39
+ const chunk = {};
40
+ try {
41
+ new vm.Script(`(function(exports, require, __dirname, __filename) {${content}\n})`, {
42
+ filename,
43
+ importModuleDynamically: vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule
44
+ }).runInThisContext()(chunk, __non_webpack_require__, path.dirname(filename), filename);
45
+ callback(null, chunk);
46
+ } catch (e) {
47
+ console.log("'runInThisContext threw'", e);
48
+ callback(e, null);
49
+ }
50
+ });
51
+ else callback(/* @__PURE__ */ new Error(`File ${filename} does not exist`), null);
52
+ };
53
+ const fetchAndRun = (url, chunkName, callback, args) => {
54
+ (typeof fetch === "undefined" ? importNodeModule("node-fetch").then((mod) => mod.default) : Promise.resolve(fetch)).then((fetchFunction) => {
55
+ return args.origin.loaderHook.lifecycle.fetch.emit(url.href, {}).then((res) => {
56
+ if (!res || !(res instanceof Response)) return fetchFunction(url.href).then((response) => response.text());
57
+ return res.text();
58
+ });
59
+ }).then((data) => {
60
+ const chunk = {};
61
+ try {
62
+ eval(`(function(exports, require, __dirname, __filename) {${data}\n})`)(chunk, __non_webpack_require__, url.pathname.split("/").slice(0, -1).join("/"), chunkName);
63
+ callback(null, chunk);
64
+ } catch (e) {
65
+ callback(e, null);
66
+ }
67
+ }).catch((err) => callback(err, null));
68
+ };
69
+ const resolveUrl = (remoteName, chunkName) => {
70
+ try {
71
+ return new URL(chunkName, __webpack_require__.p);
72
+ } catch {
73
+ const entryUrl = returnFromCache(remoteName) || returnFromGlobalInstances(remoteName);
74
+ if (!entryUrl) return null;
75
+ const url = new URL(entryUrl);
76
+ const path = __non_webpack_require__("path");
77
+ const urlPath = url.pathname;
78
+ const lastSlashIndex = urlPath.lastIndexOf("/");
79
+ const directoryPath = lastSlashIndex >= 0 ? urlPath.substring(0, lastSlashIndex + 1) : "/";
80
+ const rootDir = __webpack_require__.federation.rootOutputDir || "";
81
+ const combinedPath = path.join(directoryPath, rootDir, chunkName).replace(/\\/g, "/");
82
+ return new URL(combinedPath, url.origin);
83
+ }
84
+ };
85
+ const loadChunk = (strategy, chunkId, rootOutputDir, callback, args) => {
86
+ if (strategy === "filesystem") return loadFromFs(resolveFile(rootOutputDir, chunkId), callback);
87
+ const url = resolveUrl(rootOutputDir, chunkId);
88
+ if (!url) return callback(null, {
89
+ modules: {},
90
+ ids: [],
91
+ runtime: null
92
+ });
93
+ fetchAndRun(url, chunkId, callback, args);
94
+ };
95
+ const installChunk = (chunk, installedChunks) => {
96
+ for (const moduleId in chunk.modules) __webpack_require__.m[moduleId] = chunk.modules[moduleId];
97
+ if (chunk.runtime) chunk.runtime(__webpack_require__);
98
+ for (const chunkId of chunk.ids) {
99
+ if (installedChunks[chunkId]) installedChunks[chunkId][0]();
100
+ installedChunks[chunkId] = 0;
101
+ }
102
+ };
103
+ const deleteChunk = (chunkId, installedChunks) => {
104
+ delete installedChunks[chunkId];
105
+ return true;
106
+ };
107
+ const setupScriptLoader = () => {
108
+ __webpack_require__.l = (url, done, key, chunkId) => {
109
+ if (!key || chunkId) throw new Error(`__webpack_require__.l name is required for ${url}`);
110
+ __webpack_require__.federation.runtime.loadScriptNode(url, { attrs: { globalName: key } }).then((res) => {
111
+ const enhancedRemote = __webpack_require__.federation.instance.initRawContainer(key, url, res);
112
+ new Function("return globalThis")()[key] = enhancedRemote;
113
+ done(enhancedRemote);
114
+ }).catch(done);
115
+ };
116
+ };
117
+ const setupChunkHandler = (installedChunks, args) => {
118
+ return (chunkId, promises) => {
119
+ let installedChunkData = installedChunks[chunkId];
120
+ if (installedChunkData !== 0) if (installedChunkData) promises.push(installedChunkData[2]);
121
+ else if (__webpack_require__.federation.chunkMatcher ? __webpack_require__.federation.chunkMatcher(chunkId) : true) {
122
+ const promise = new Promise((resolve, reject) => {
123
+ installedChunkData = installedChunks[chunkId] = [resolve, reject];
124
+ const fs = typeof process !== "undefined" ? __non_webpack_require__("fs") : false;
125
+ const filename = typeof process !== "undefined" ? resolveFile(__webpack_require__.federation.rootOutputDir || "", chunkId) : false;
126
+ if (fs && fs.existsSync(filename)) loadChunk("filesystem", chunkId, __webpack_require__.federation.rootOutputDir || "", (err, chunk) => {
127
+ if (err) return deleteChunk(chunkId, installedChunks) && reject(err);
128
+ if (chunk) installChunk(chunk, installedChunks);
129
+ resolve(chunk);
130
+ }, args);
131
+ else {
132
+ const chunkName = __webpack_require__.u(chunkId);
133
+ loadChunk(typeof process === "undefined" ? "http-eval" : "http-vm", chunkName, __webpack_require__.federation.initOptions.name, (err, chunk) => {
134
+ if (err) return deleteChunk(chunkId, installedChunks) && reject(err);
135
+ if (chunk) installChunk(chunk, installedChunks);
136
+ resolve(chunk);
137
+ }, args);
138
+ }
139
+ });
140
+ promises.push(installedChunkData[2] = promise);
141
+ } else installedChunks[chunkId] = 0;
142
+ };
143
+ };
144
+ const setupWebpackRequirePatching = (handle) => {
145
+ if (__webpack_require__.f) {
146
+ if (__webpack_require__.f.require) {
147
+ console.warn("\x1B[33m%s\x1B[0m", "CAUTION: build target is not set to \"async-node\", attempting to patch additional chunk handlers. This may not work");
148
+ __webpack_require__.f.require = handle;
149
+ }
150
+ if (__webpack_require__.f.readFileVm) __webpack_require__.f.readFileVm = handle;
151
+ }
152
+ };
153
+ function runtimePlugin_default() {
154
+ return {
155
+ name: "node-federation-plugin",
156
+ beforeInit(args) {
157
+ (() => {
158
+ const installedChunks = {};
159
+ setupScriptLoader();
160
+ setupWebpackRequirePatching(setupChunkHandler(installedChunks, args));
161
+ })();
162
+ return args;
163
+ }
164
+ };
165
+ }
166
+
167
+ //#endregion
168
+ export { runtimePlugin_default as default, deleteChunk, fetchAndRun, importNodeModule, installChunk, loadChunk, loadFromFs, nodeRuntimeImportCache, resolveFile, resolveUrl, returnFromCache, returnFromGlobalInstances, setupChunkHandler, setupScriptLoader, setupWebpackRequirePatching };
169
+ //# sourceMappingURL=runtimePlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimePlugin.mjs","names":[],"sources":["../../src/runtimePlugin.ts"],"sourcesContent":["import type {\n ModuleFederationRuntimePlugin,\n ModuleFederation,\n} from '@module-federation/runtime';\ntype WebpackRequire = {\n (id: string): any;\n u: (chunkId: string) => string;\n p: string;\n m: { [key: string]: any };\n o: (obj: any, prop: string) => boolean;\n C?: (chunk: any) => void;\n l: (\n url: string,\n done: (res: any) => void,\n key: string,\n chunkId: string,\n ) => void;\n federation: {\n runtime: {\n loadScriptNode: (\n url: string,\n options: { attrs: { globalName: string } },\n ) => Promise<any>;\n };\n instance: ModuleFederation;\n chunkMatcher?: (chunkId: string) => boolean;\n rootOutputDir?: string;\n initOptions: {\n name: string;\n remotes: any;\n };\n };\n f?: {\n require?: (chunkId: string, promises: any[]) => void;\n readFileVm?: (chunkId: string, promises: any[]) => void;\n };\n};\n\ndeclare const __webpack_require__: WebpackRequire;\ndeclare const __non_webpack_require__: (id: string) => any;\n\nexport const nodeRuntimeImportCache = new Map<string, Promise<any>>();\n\nexport function importNodeModule<T>(name: string): Promise<T> {\n if (!name) {\n throw new Error('import specifier is required');\n }\n\n // Check cache to prevent infinite recursion\n if (nodeRuntimeImportCache.has(name)) {\n return nodeRuntimeImportCache.get(name)!;\n }\n\n const importModule = new Function('name', `return import(name)`);\n const promise = importModule(name)\n .then((res: any) => res.default as T)\n .catch((error: any) => {\n console.error(`Error importing module ${name}:`, error);\n // Remove from cache on error so it can be retried\n nodeRuntimeImportCache.delete(name);\n throw error;\n });\n\n // Cache the promise to prevent recursive calls\n nodeRuntimeImportCache.set(name, promise);\n return promise;\n}\n\n// Hoisted utility function to resolve file paths for chunks\nexport const resolveFile = (rootOutputDir: string, chunkId: string): string => {\n const path = __non_webpack_require__('path');\n return path.join(__dirname, rootOutputDir + __webpack_require__.u(chunkId));\n};\n\n// Hoisted utility function to get remote entry from cache\nexport const returnFromCache = (remoteName: string): string | null => {\n const globalThisVal = new Function('return globalThis')();\n const federationInstances = globalThisVal['__FEDERATION__']['__INSTANCES__'];\n for (const instance of federationInstances) {\n const moduleContainer = instance.moduleCache.get(remoteName);\n if (moduleContainer?.remoteInfo) return moduleContainer.remoteInfo.entry;\n }\n return null;\n};\n\n// Hoisted utility function to get remote entry from global instances\nexport const returnFromGlobalInstances = (\n remoteName: string,\n): string | null => {\n const globalThisVal = new Function('return globalThis')();\n const federationInstances = globalThisVal['__FEDERATION__']['__INSTANCES__'];\n for (const instance of federationInstances) {\n for (const remote of instance.options.remotes) {\n if (remote.name === remoteName || remote.alias === remoteName) {\n console.log('Backup remote entry found:', remote.entry);\n return remote.entry;\n }\n }\n }\n return null;\n};\n\n// Hoisted utility function to load chunks from filesystem\nexport const loadFromFs = (\n filename: string,\n callback: (err: Error | null, chunk: any) => void,\n): void => {\n const fs = __non_webpack_require__('fs') as typeof import('fs');\n const path = __non_webpack_require__('path') as typeof import('path');\n const vm = __non_webpack_require__('vm') as typeof import('vm');\n\n if (fs.existsSync(filename)) {\n fs.readFile(filename, 'utf-8', (err, content) => {\n if (err) return callback(err, null);\n const chunk = {};\n try {\n const script = new vm.Script(\n `(function(exports, require, __dirname, __filename) {${content}\\n})`,\n {\n filename,\n importModuleDynamically:\n //@ts-ignore\n vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule,\n },\n );\n script.runInThisContext()(\n chunk,\n __non_webpack_require__,\n path.dirname(filename),\n filename,\n );\n callback(null, chunk);\n } catch (e) {\n console.log(\"'runInThisContext threw'\", e);\n callback(e as Error, null);\n }\n });\n } else {\n callback(new Error(`File ${filename} does not exist`), null);\n }\n};\n\n// Hoisted utility function to fetch and execute chunks from remote URLs\nexport const fetchAndRun = (\n url: URL,\n chunkName: string,\n callback: (err: Error | null, chunk: any) => void,\n args: any,\n): void => {\n (typeof fetch === 'undefined'\n ? importNodeModule<typeof import('node-fetch')>('node-fetch').then(\n (mod) => mod.default,\n )\n : Promise.resolve(fetch)\n )\n .then((fetchFunction) => {\n return args.origin.loaderHook.lifecycle.fetch\n .emit(url.href, {})\n .then((res: Response | null) => {\n if (!res || !(res instanceof Response)) {\n return fetchFunction(url.href).then((response) => response.text());\n }\n return res.text();\n });\n })\n .then((data) => {\n const chunk = {};\n try {\n eval(`(function(exports, require, __dirname, __filename) {${data}\\n})`)(\n chunk,\n __non_webpack_require__,\n url.pathname.split('/').slice(0, -1).join('/'),\n chunkName,\n );\n callback(null, chunk);\n } catch (e) {\n callback(e as Error, null);\n }\n })\n .catch((err: Error) => callback(err, null));\n};\n\n// Hoisted utility function to resolve URLs for chunks\nexport const resolveUrl = (\n remoteName: string,\n chunkName: string,\n): URL | null => {\n try {\n return new URL(chunkName, __webpack_require__.p);\n } catch {\n const entryUrl =\n returnFromCache(remoteName) || returnFromGlobalInstances(remoteName);\n\n if (!entryUrl) return null;\n\n const url = new URL(entryUrl);\n const path = __non_webpack_require__('path');\n\n // Extract the directory path from the remote entry URL\n // e.g., from \"http://url/static/js/remoteEntry.js\" to \"/static/js/\"\n const urlPath = url.pathname;\n const lastSlashIndex = urlPath.lastIndexOf('/');\n const directoryPath =\n lastSlashIndex >= 0 ? urlPath.substring(0, lastSlashIndex + 1) : '/';\n\n // Get rootDir from webpack configuration\n const rootDir = __webpack_require__.federation.rootOutputDir || '';\n\n // Use path.join to combine the paths properly while handling slashes\n // Convert Windows-style paths to URL-style paths\n const combinedPath = path\n .join(directoryPath, rootDir, chunkName)\n .replace(/\\\\/g, '/');\n // Create the final URL\n return new URL(combinedPath, url.origin);\n }\n};\n\n// Hoisted utility function to load chunks based on different strategies\nexport const loadChunk = (\n strategy: string,\n chunkId: string,\n rootOutputDir: string,\n callback: (err: Error | null, chunk: any) => void,\n args: any,\n): void => {\n if (strategy === 'filesystem') {\n return loadFromFs(resolveFile(rootOutputDir, chunkId), callback);\n }\n\n const url = resolveUrl(rootOutputDir, chunkId);\n if (!url) return callback(null, { modules: {}, ids: [], runtime: null });\n\n // Using fetchAndRun directly with args\n fetchAndRun(url, chunkId, callback, args);\n};\n\n// Hoisted utility function to install a chunk into webpack\nexport const installChunk = (\n chunk: any,\n installedChunks: { [key: string]: any },\n): void => {\n for (const moduleId in chunk.modules) {\n __webpack_require__.m[moduleId] = chunk.modules[moduleId];\n }\n if (chunk.runtime) chunk.runtime(__webpack_require__);\n for (const chunkId of chunk.ids) {\n if (installedChunks[chunkId]) installedChunks[chunkId][0]();\n installedChunks[chunkId] = 0;\n }\n};\n\n// Hoisted utility function to remove a chunk on fail\nexport const deleteChunk = (\n chunkId: string,\n installedChunks: { [key: string]: any },\n): boolean => {\n delete installedChunks[chunkId];\n return true;\n};\n\n// Hoisted function to set up webpack script loader\nexport const setupScriptLoader = (): void => {\n __webpack_require__.l = (\n url: string,\n done: (res: any) => void,\n key: string,\n chunkId: string,\n ): void => {\n if (!key || chunkId)\n throw new Error(`__webpack_require__.l name is required for ${url}`);\n __webpack_require__.federation.runtime\n .loadScriptNode(url, { attrs: { globalName: key } })\n .then((res) => {\n const enhancedRemote =\n __webpack_require__.federation.instance.initRawContainer(\n key,\n url,\n res,\n );\n new Function('return globalThis')()[key] = enhancedRemote;\n done(enhancedRemote);\n })\n .catch(done);\n };\n};\n\n// Hoisted function to set up chunk handler\nexport const setupChunkHandler = (\n installedChunks: { [key: string]: any },\n args: any,\n): ((chunkId: string, promises: any[]) => void) => {\n return (chunkId: string, promises: any[]): void => {\n let installedChunkData = installedChunks[chunkId];\n if (installedChunkData !== 0) {\n if (installedChunkData) {\n promises.push(installedChunkData[2]);\n } else {\n const matcher = __webpack_require__.federation.chunkMatcher\n ? __webpack_require__.federation.chunkMatcher(chunkId)\n : true;\n\n if (matcher) {\n const promise = new Promise((resolve, reject) => {\n installedChunkData = installedChunks[chunkId] = [resolve, reject];\n const fs =\n typeof process !== 'undefined'\n ? __non_webpack_require__('fs')\n : false;\n const filename =\n typeof process !== 'undefined'\n ? resolveFile(\n __webpack_require__.federation.rootOutputDir || '',\n chunkId,\n )\n : false;\n\n if (fs && fs.existsSync(filename)) {\n loadChunk(\n 'filesystem',\n chunkId,\n __webpack_require__.federation.rootOutputDir || '',\n (err, chunk) => {\n if (err)\n return deleteChunk(chunkId, installedChunks) && reject(err);\n if (chunk) installChunk(chunk, installedChunks);\n resolve(chunk);\n },\n args,\n );\n } else {\n const chunkName = __webpack_require__.u(chunkId);\n const loadingStrategy =\n typeof process === 'undefined' ? 'http-eval' : 'http-vm';\n loadChunk(\n loadingStrategy,\n chunkName,\n __webpack_require__.federation.initOptions.name,\n (err, chunk) => {\n if (err)\n return deleteChunk(chunkId, installedChunks) && reject(err);\n if (chunk) installChunk(chunk, installedChunks);\n resolve(chunk);\n },\n args,\n );\n }\n });\n promises.push((installedChunkData[2] = promise));\n } else {\n installedChunks[chunkId] = 0;\n }\n }\n }\n };\n};\n\n// Hoisted function to set up webpack require patching\nexport const setupWebpackRequirePatching = (\n handle: (chunkId: string, promises: any[]) => void,\n): void => {\n if (__webpack_require__.f) {\n if (__webpack_require__.f.require) {\n console.warn(\n '\\x1b[33m%s\\x1b[0m',\n 'CAUTION: build target is not set to \"async-node\", attempting to patch additional chunk handlers. This may not work',\n );\n __webpack_require__.f.require = handle;\n }\n\n if (__webpack_require__.f.readFileVm) {\n __webpack_require__.f.readFileVm = handle;\n }\n }\n};\n\nexport default function (): ModuleFederationRuntimePlugin {\n return {\n name: 'node-federation-plugin',\n beforeInit(args) {\n // Patch webpack chunk loading handlers\n (() => {\n // Create the chunk tracking object\n const installedChunks: { [key: string]: any } = {};\n\n // Set up webpack script loader\n setupScriptLoader();\n\n // Create and set up the chunk handler\n const handle = setupChunkHandler(installedChunks, args);\n\n // Patch webpack require\n setupWebpackRequirePatching(handle);\n })();\n\n return args;\n },\n };\n}\n"],"mappings":";AAyCA,MAAa,yCAAyB,IAAI,KAA2B;AAErE,SAAgB,iBAAoB,MAA0B;AAC5D,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,+BAA+B;AAIjD,KAAI,uBAAuB,IAAI,KAAK,CAClC,QAAO,uBAAuB,IAAI,KAAK;CAIzC,MAAM,UADe,IAAI,SAAS,QAAQ,sBAAsB,CACnC,KAAK,CAC/B,MAAM,QAAa,IAAI,QAAa,CACpC,OAAO,UAAe;AACrB,UAAQ,MAAM,0BAA0B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import { moduleFederationPlugin } from "@module-federation/sdk";
2
+
3
+ //#region src/types/index.d.ts
4
+ type ModuleFederationPluginOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
5
+ type RemotesObject = ModuleFederationPluginOptions['remotes'];
6
+ //#endregion
7
+ export { ModuleFederationPluginOptions, RemotesObject };
8
+ //# sourceMappingURL=index.d.mts.map
@@ -1,3 +1,8 @@
1
- import { moduleFederationPlugin } from '@module-federation/sdk';
2
- export type ModuleFederationPluginOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
3
- export type RemotesObject = ModuleFederationPluginOptions['remotes'];
1
+ import { moduleFederationPlugin } from "@module-federation/sdk";
2
+
3
+ //#region src/types/index.d.ts
4
+ type ModuleFederationPluginOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
5
+ type RemotesObject = ModuleFederationPluginOptions['remotes'];
6
+ //#endregion
7
+ export { ModuleFederationPluginOptions, RemotesObject };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,15 @@
1
+ //#region src/utils/flush-chunks.d.ts
2
+ /**
3
+ * Initialize usedChunks and share it globally.
4
+ * @type {Set}
5
+ */
6
+ declare const usedChunks: any;
7
+ declare const getAllKnownRemotes: () => {};
8
+ /**
9
+ * Flush the chunks and return a deduplicated array of chunks.
10
+ * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
11
+ */
12
+ declare const flushChunks: () => Promise<unknown[]>;
13
+ //#endregion
14
+ export { flushChunks, getAllKnownRemotes, usedChunks };
15
+ //# sourceMappingURL=flush-chunks.d.mts.map
@@ -1,11 +1,15 @@
1
+ //#region src/utils/flush-chunks.d.ts
1
2
  /**
2
3
  * Initialize usedChunks and share it globally.
3
4
  * @type {Set}
4
5
  */
5
- export declare const usedChunks: any;
6
- export declare const getAllKnownRemotes: () => {};
6
+ declare const usedChunks: any;
7
+ declare const getAllKnownRemotes: () => {};
7
8
  /**
8
9
  * Flush the chunks and return a deduplicated array of chunks.
9
10
  * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
10
11
  */
11
- export declare const flushChunks: () => Promise<unknown[]>;
12
+ declare const flushChunks: () => Promise<unknown[]>;
13
+ //#endregion
14
+ export { flushChunks, getAllKnownRemotes, usedChunks };
15
+ //# sourceMappingURL=flush-chunks.d.ts.map
@@ -1,177 +1,103 @@
1
- "use strict";
2
- /* eslint-disable no-undef */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.flushChunks = exports.getAllKnownRemotes = exports.usedChunks = void 0;
5
- // @ts-ignore
6
- if (!globalThis.usedChunks) {
7
- // @ts-ignore
8
- globalThis.usedChunks = new Set();
9
- }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/utils/flush-chunks.ts
4
+ if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
10
5
  /**
11
- * Initialize usedChunks and share it globally.
12
- * @type {Set}
13
- */
14
- // @ts-ignore
15
- exports.usedChunks = globalThis.usedChunks;
6
+ * Initialize usedChunks and share it globally.
7
+ * @type {Set}
8
+ */
9
+ const { usedChunks } = globalThis;
16
10
  /**
17
- * Load hostStats from the JSON file.
18
- * @returns {object} hostStats - An object containing host stats data.
19
- */
11
+ * Load hostStats from the JSON file.
12
+ * @returns {object} hostStats - An object containing host stats data.
13
+ */
20
14
  const loadHostStats = () => {
21
- try {
22
- //@ts-ignore
23
- return __non_webpack_require__('../federated-stats.json');
24
- }
25
- catch (e) {
26
- return {};
27
- }
15
+ try {
16
+ return __non_webpack_require__("../federated-stats.json");
17
+ } catch (e) {
18
+ return {};
19
+ }
28
20
  };
29
- const getAllKnownRemotes = function () {
30
- // Attempt to access the global federation controller safely
31
- const federationController = new Function('return globalThis')()
32
- .__FEDERATION__;
33
- if (!federationController || !federationController.__INSTANCES__) {
34
- // If the federation controller or instances are not defined, return an empty object
35
- return {};
36
- }
37
- var collected = {};
38
- // Use a for...of loop to iterate over all federation instances
39
- for (const instance of federationController.__INSTANCES__) {
40
- // Use another for...of loop to iterate over the module cache Map entries
41
- for (const [key, cacheModule] of instance.moduleCache) {
42
- // Check if the cacheModule has remoteInfo and use it to collect remote names
43
- if (cacheModule.remoteInfo) {
44
- //@ts-ignore
45
- collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;
46
- }
47
- }
48
- }
49
- return collected;
21
+ const getAllKnownRemotes = function() {
22
+ const federationController = new Function("return globalThis")().__FEDERATION__;
23
+ if (!federationController || !federationController.__INSTANCES__) return {};
24
+ var collected = {};
25
+ for (const instance of federationController.__INSTANCES__) for (const [key, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;
26
+ return collected;
50
27
  };
51
- exports.getAllKnownRemotes = getAllKnownRemotes;
52
28
  /**
53
- * Create a shareMap based on the loaded modules.
54
- * @returns {object} shareMap - An object containing the shareMap data.
55
- */
29
+ * Create a shareMap based on the loaded modules.
30
+ * @returns {object} shareMap - An object containing the shareMap data.
31
+ */
56
32
  const createShareMap = () => {
57
- // Check if __webpack_share_scopes__ is defined and has a default property
58
- // @ts-ignore
59
- if (__webpack_share_scopes__?.default) {
60
- // Reduce the keys of the default property to create the share map
61
- // @ts-ignore
62
- return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {
63
- // @ts-ignore
64
- const shareMap = __webpack_share_scopes__.default[key];
65
- // shareScope may equal undefined or null if it has unexpected value
66
- if (!shareMap || typeof shareMap !== 'object') {
67
- return acc;
68
- }
69
- // Get the loaded modules for the current key
70
- const loadedModules = Object.values(shareMap)
71
- // Filter out the modules that are not loaded
72
- // @ts-ignore
73
- .filter((sharedModule) => sharedModule.loaded)
74
- // Map the filtered modules to their 'from' properties
75
- // @ts-ignore
76
- .map((sharedModule) => sharedModule.from);
77
- // If there are any loaded modules, add them to the accumulator object
78
- if (loadedModules.length > 0) {
79
- // @ts-ignore
80
- acc[key] = loadedModules;
81
- }
82
- // Return the accumulator object for the next iteration
83
- return acc;
84
- }, {});
85
- }
86
- // If __webpack_share_scopes__ is not defined or doesn't have a default property, return an empty object
87
- return {};
33
+ if (__webpack_share_scopes__?.default) return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {
34
+ const shareMap = __webpack_share_scopes__.default[key];
35
+ if (!shareMap || typeof shareMap !== "object") return acc;
36
+ const loadedModules = Object.values(shareMap).filter((sharedModule) => sharedModule.loaded).map((sharedModule) => sharedModule.from);
37
+ if (loadedModules.length > 0) acc[key] = loadedModules;
38
+ return acc;
39
+ }, {});
40
+ return {};
88
41
  };
89
42
  /**
90
- * Process a single chunk and return an array of updated chunks.
91
- * @param {string} chunk - A chunk string containing remote and request data.
92
- * @param {object} shareMap - An object containing the shareMap data.
93
- * @param {object} hostStats - An object containing host stats data.
94
- * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.
95
- */
96
- // @ts-ignore
43
+ * Process a single chunk and return an array of updated chunks.
44
+ * @param {string} chunk - A chunk string containing remote and request data.
45
+ * @param {object} shareMap - An object containing the shareMap data.
46
+ * @param {object} hostStats - An object containing host stats data.
47
+ * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.
48
+ */
97
49
  const processChunk = async (chunk, shareMap, hostStats) => {
98
- const chunks = new Set();
99
- const [remote, req] = chunk.split('/');
100
- const request = './' + req;
101
- const knownRemotes = (0, exports.getAllKnownRemotes)();
102
- //@ts-ignore
103
- if (!knownRemotes[remote]) {
104
- console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
105
- return;
106
- }
107
- try {
108
- //@ts-ignore
109
- const remoteName = new URL(knownRemotes[remote].entry).pathname
110
- .split('/')
111
- .pop();
112
- //@ts-ignore
113
- const statsFile = knownRemotes[remote].entry
114
- .replace(remoteName, 'federated-stats.json')
115
- .replace('ssr', 'chunks');
116
- let stats = {};
117
- try {
118
- stats = await fetch(statsFile).then((res) => res.json());
119
- }
120
- catch (e) {
121
- console.error('flush error', e);
122
- }
123
- //@ts-ignore
124
- const [prefix] = knownRemotes[remote].entry.split('static/');
125
- //@ts-ignore
126
- if (stats.federatedModules) {
127
- //@ts-ignore
128
- stats.federatedModules.forEach((modules) => {
129
- if (modules.exposes?.[request]) {
130
- //@ts-ignore
131
- modules.exposes[request].forEach((chunk) => {
132
- chunks.add([prefix, chunk].join(''));
133
- Object.values(chunk).forEach((chunk) => {
134
- //@ts-ignore
135
- if (chunk.files) {
136
- //@ts-ignore
137
- chunk.files.forEach((file) => {
138
- chunks.add(prefix + file);
139
- });
140
- }
141
- //@ts-ignore
142
- if (chunk.requiredModules) {
143
- //@ts-ignore
144
- chunk.requiredModules.forEach((module) => {
145
- if (shareMap[module]) {
146
- // If the module is from the host, log the host stats
147
- }
148
- });
149
- }
150
- });
151
- });
152
- }
153
- });
154
- }
155
- return Array.from(chunks);
156
- }
157
- catch (e) {
158
- console.error('flush error:', e);
159
- }
50
+ const chunks = /* @__PURE__ */ new Set();
51
+ const [remote, req] = chunk.split("/");
52
+ const request = "./" + req;
53
+ const knownRemotes = getAllKnownRemotes();
54
+ if (!knownRemotes[remote]) {
55
+ console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
56
+ return;
57
+ }
58
+ try {
59
+ const remoteName = new URL(knownRemotes[remote].entry).pathname.split("/").pop();
60
+ const statsFile = knownRemotes[remote].entry.replace(remoteName, "federated-stats.json").replace("ssr", "chunks");
61
+ let stats = {};
62
+ try {
63
+ stats = await fetch(statsFile).then((res) => res.json());
64
+ } catch (e) {
65
+ console.error("flush error", e);
66
+ }
67
+ const [prefix] = knownRemotes[remote].entry.split("static/");
68
+ if (stats.federatedModules) stats.federatedModules.forEach((modules) => {
69
+ if (modules.exposes?.[request]) modules.exposes[request].forEach((chunk) => {
70
+ chunks.add([prefix, chunk].join(""));
71
+ Object.values(chunk).forEach((chunk) => {
72
+ if (chunk.files) chunk.files.forEach((file) => {
73
+ chunks.add(prefix + file);
74
+ });
75
+ if (chunk.requiredModules) chunk.requiredModules.forEach((module) => {
76
+ if (shareMap[module]) {}
77
+ });
78
+ });
79
+ });
80
+ });
81
+ return Array.from(chunks);
82
+ } catch (e) {
83
+ console.error("flush error:", e);
84
+ }
160
85
  };
161
86
  /**
162
- * Flush the chunks and return a deduplicated array of chunks.
163
- * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
164
- */
87
+ * Flush the chunks and return a deduplicated array of chunks.
88
+ * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
89
+ */
165
90
  const flushChunks = async () => {
166
- const hostStats = loadHostStats();
167
- const shareMap = createShareMap();
168
- const allFlushed = await Promise.all(Array.from(exports.usedChunks).map(async (chunk) => processChunk(chunk, shareMap, hostStats)));
169
- // Deduplicate the chunks array
170
- const dedupe = Array.from(new Set([...allFlushed.flat()]));
171
- // Clear usedChunks
172
- exports.usedChunks.clear();
173
- // Filter out any undefined or null values
174
- return dedupe.filter(Boolean);
91
+ const hostStats = loadHostStats();
92
+ const shareMap = createShareMap();
93
+ const allFlushed = await Promise.all(Array.from(usedChunks).map(async (chunk) => processChunk(chunk, shareMap, hostStats)));
94
+ const dedupe = Array.from(new Set([...allFlushed.flat()]));
95
+ usedChunks.clear();
96
+ return dedupe.filter(Boolean);
175
97
  };
98
+
99
+ //#endregion
176
100
  exports.flushChunks = flushChunks;
101
+ exports.getAllKnownRemotes = getAllKnownRemotes;
102
+ exports.usedChunks = usedChunks;
177
103
  //# sourceMappingURL=flush-chunks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flush-chunks.js","sourceRoot":"","sources":["../../../src/utils/flush-chunks.ts"],"names":[],"mappings":";AAAA,6BAA6B;;;AAE7B,aAAa;AACb,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IAC3B,aAAa;IACb,UAAU,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,C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CAAC,CACzC,CACF,CAAC;IAEF,+BAA+B;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE3D,mBAAmB;IACnB,kBAAU,CAAC,KAAK,EAAE,CAAC;IACnB,0CAA0C;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC,CAAC;AAjBW,QAAA,WAAW,eAiBtB"}
1
+ {"version":3,"file":"flush-chunks.js","names":[],"sources":["../../../src/utils/flush-chunks.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\n// @ts-ignore\nif (!globalThis.usedChunks) {\n // @ts-ignore\n globalThis.usedChunks = new Set();\n}\n/**\n * Initialize usedChunks and share it globally.\n * @type {Set}\n */\n// @ts-ignore\nexport const { usedChunks } = globalThis;\n/**\n * Load hostStats from the JSON file.\n * @returns {object} hostStats - An object containing host stats data.\n */\nconst loadHostStats = () => {\n try {\n //@ts-ignore\n return __non_webpack_require__('../federated-stats.json');\n } catch (e) {\n return {};\n }\n};\n\nexport const getAllKnownRemotes = function () {\n // Attempt to access the global federation controller safely\n const federationController = new Function('return globalThis')()\n .__FEDERATION__;\n if (!federationController || !federationController.__INSTANCES__) {\n // If the federation controller or instances are not defined, return an empty object\n return {};\n }\n\n var collected = {};\n // Use a for...of loop to iterate over all federation instances\n for (const instance of federationController.__INSTANCES__) {\n // Use another for...of loop to iterate over the module cache Map entries\n for (const [key, cacheModule] of instance.moduleCache) {\n // Check if the cacheModule has remoteInfo and use it to collect remote names\n if (cacheModule.remoteInfo) {\n //@ts-ignore\n collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;\n }\n }\n }\n return collected;\n};\n\n/**\n * Create a shareMap based on the loaded modules.\n * @returns {object} shareMap - An object containing the shareMap data.\n */\nconst createShareMap = () => {\n // Check if __webpack_share_scopes__ is defined and has a default property\n // @ts-ignore\n if (__webpack_share_scopes__?.default) {\n // Reduce the keys of the default property to create the share map\n // @ts-ignore\n return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {\n // @ts-ignore\n const shareMap = __webpack_share_scopes__.default[key];\n // shareScope may equal undefined or null if it has unexpected value\n if (!shareMap || typeof shareMap !== 'object') {\n return acc;\n }\n // Get the loaded modules for the current key\n const loadedModules = Object.values(shareMap)\n // Filter out the modules that are not loaded\n // @ts-ignore\n .filter((sharedModule) => sharedModule.loaded)\n // Map the filtered modules to their 'from' properties\n // @ts-ignore\n .map((sharedModule) => sharedModule.from);\n\n // If there are any loaded modules, add them to the accumulator object\n if (loadedModules.length > 0) {\n // @ts-ignore\n acc[key] = loadedModules;\n }\n // Return the accumulator object for the next iteration\n return acc;\n }, {});\n }\n // If __webpack_share_scopes__ is not defined or doesn't have a default property, return an empty object\n return {};\n};\n\n/**\n * Process a single chunk and return an array of updated chunks.\n * @param {string} chunk - A chunk string containing remote and request data.\n * @param {object} shareMap - An object containing the shareMap data.\n * @param {object} hostStats - An object containing host stats data.\n * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.\n */\n// @ts-ignore\nconst processChunk = async (chunk, shareMap, hostStats) => {\n const chunks = new Set();\n const [remote, req] = chunk.split('/');\n const request = './' + req;\n const knownRemotes = getAllKnownRemotes();\n //@ts-ignore\n if (!knownRemotes[remote]) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n return;\n }\n\n try {\n //@ts-ignore\n const remoteName = new URL(knownRemotes[remote].entry).pathname\n .split('/')\n .pop();\n //@ts-ignore\n\n const statsFile = knownRemotes[remote].entry\n .replace(remoteName, 'federated-stats.json')\n .replace('ssr', 'chunks');\n let stats = {};\n\n try {\n stats = await fetch(statsFile).then((res) => res.json());\n } catch (e) {\n console.error('flush error', e);\n }\n //@ts-ignore\n\n const [prefix] = knownRemotes[remote].entry.split('static/');\n //@ts-ignore\n\n if (stats.federatedModules) {\n //@ts-ignore\n\n stats.federatedModules.forEach((modules) => {\n if (modules.exposes?.[request]) {\n //@ts-ignore\n\n modules.exposes[request].forEach((chunk) => {\n chunks.add([prefix, chunk].join(''));\n\n Object.values(chunk).forEach((chunk) => {\n //@ts-ignore\n\n if (chunk.files) {\n //@ts-ignore\n\n chunk.files.forEach((file) => {\n chunks.add(prefix + file);\n });\n }\n //@ts-ignore\n\n if (chunk.requiredModules) {\n //@ts-ignore\n\n chunk.requiredModules.forEach((module) => {\n if (shareMap[module]) {\n // If the module is from the host, log the host stats\n }\n });\n }\n });\n });\n }\n });\n }\n\n return Array.from(chunks);\n } catch (e) {\n console.error('flush error:', e);\n }\n};\n\n/**\n * Flush the chunks and return a deduplicated array of chunks.\n * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.\n */\nexport const flushChunks = async () => {\n const hostStats = loadHostStats();\n const shareMap = createShareMap();\n\n const allFlushed = await Promise.all(\n Array.from(usedChunks).map(async (chunk) =>\n processChunk(chunk, shareMap, hostStats),\n ),\n );\n\n // Deduplicate the chunks array\n const dedupe = Array.from(new Set([...allFlushed.flat()]));\n\n // Clear usedChunks\n usedChunks.clear();\n // Filter out any undefined or null values\n return dedupe.filter(Boolean);\n};\n"],"mappings":";;;AAGA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;;;;;AAK9B,MAAM,sBAAsB;AAC1B,KAAI;AAEF,SAAO,wBAAwB,0BAA0B;UAClD,GAAG;AACV,SAAO,EAAE;;;AAIb,MAAa,qBAAqB,WAAY;CAE5C,MAAM,uBAAuB,IAAI,SAAS,oBAAoB,EAAE,CAC7D;AACH,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cAEjD,QAAO,EAAE;CAGX,IAAI,YAAY,EAAE;AAElB,MAAK,MAAM,YAAY,qBAAqB,cAE1C,MAAK,MAAM,CAAC,KAAK,gBAAgB,SAAS,YAExC,KAAI,YAAY,WAEd,WAAU,YAAY,WAAW,QAAQ,YAAY;AA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