@module-federation/node 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703

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 (128) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +31 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  3. package/dist/node_modules/.pnpm/webpack@5.104.1_@swc_core@1.7.26_@swc_helpers@0.5.13__esbuild@0.28.1_webpack-cli@5.1.4/node_modules/webpack/types.d.mts +1 -0
  4. package/dist/node_modules/.pnpm/webpack@5.104.1_@swc_core@1.7.26_@swc_helpers@0.5.13__esbuild@0.28.1_webpack-cli@5.1.4/node_modules/webpack/types.d.ts +1 -0
  5. package/dist/plugins/ChunkCorrelationPlugin.js +308 -0
  6. package/dist/plugins/ChunkCorrelationPlugin.js.map +1 -0
  7. package/dist/plugins/ChunkCorrelationPlugin.mjs +305 -0
  8. package/dist/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
  9. package/dist/plugins/createBundlerLogger.js +9 -0
  10. package/dist/plugins/createBundlerLogger.js.map +1 -0
  11. package/dist/plugins/createBundlerLogger.mjs +8 -0
  12. package/dist/plugins/createBundlerLogger.mjs.map +1 -0
  13. package/dist/src/filesystem/stratagies.d.mts +21 -0
  14. package/dist/src/filesystem/stratagies.d.ts +10 -7
  15. package/dist/src/filesystem/stratagies.js +97 -116
  16. package/dist/src/filesystem/stratagies.js.map +1 -1
  17. package/dist/src/filesystem/stratagies.mjs +103 -0
  18. package/dist/src/filesystem/stratagies.mjs.map +1 -0
  19. package/dist/src/index.d.mts +8 -0
  20. package/dist/src/index.d.ts +8 -7
  21. package/dist/src/index.js +16 -22
  22. package/dist/src/index.mjs +9 -0
  23. package/dist/src/plugins/AutomaticPublicPathPlugin.d.mts +12 -0
  24. package/dist/src/plugins/AutomaticPublicPathPlugin.d.ts +9 -7
  25. package/dist/src/plugins/AutomaticPublicPathPlugin.js +26 -35
  26. package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -1
  27. package/dist/src/plugins/AutomaticPublicPathPlugin.mjs +28 -0
  28. package/dist/src/plugins/AutomaticPublicPathPlugin.mjs.map +1 -0
  29. package/dist/src/plugins/ChunkCorrelationPlugin.d.mts +5 -0
  30. package/dist/src/plugins/ChunkCorrelationPlugin.d.ts +4 -61
  31. package/dist/src/plugins/ChunkCorrelationPlugin.js +8 -440
  32. package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -1
  33. package/dist/src/plugins/ChunkCorrelationPlugin.mjs +8 -0
  34. package/dist/src/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
  35. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.mts +21 -0
  36. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.ts +16 -13
  37. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js +68 -118
  38. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
  39. package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs +70 -0
  40. package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs.map +1 -0
  41. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +44 -0
  42. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +37 -34
  43. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +109 -126
  44. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -1
  45. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs +110 -0
  46. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs.map +1 -0
  47. package/dist/src/plugins/EntryChunkTrackerPlugin.d.mts +17 -0
  48. package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +14 -10
  49. package/dist/src/plugins/EntryChunkTrackerPlugin.js +30 -32
  50. package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -1
  51. package/dist/src/plugins/EntryChunkTrackerPlugin.mjs +38 -0
  52. package/dist/src/plugins/EntryChunkTrackerPlugin.mjs.map +1 -0
  53. package/dist/src/plugins/NodeFederationPlugin.d.mts +54 -0
  54. package/dist/src/plugins/NodeFederationPlugin.d.ts +33 -26
  55. package/dist/src/plugins/NodeFederationPlugin.js +72 -84
  56. package/dist/src/plugins/NodeFederationPlugin.js.map +1 -1
  57. package/dist/src/plugins/NodeFederationPlugin.mjs +73 -0
  58. package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -0
  59. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.mts +13 -0
  60. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +10 -8
  61. package/dist/src/plugins/RemotePublicPathRuntimeModule.js +34 -35
  62. package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -1
  63. package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs +132 -0
  64. package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs.map +1 -0
  65. package/dist/src/plugins/StreamingTargetPlugin.d.mts +32 -0
  66. package/dist/src/plugins/StreamingTargetPlugin.d.ts +19 -16
  67. package/dist/src/plugins/StreamingTargetPlugin.js +43 -56
  68. package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -1
  69. package/dist/src/plugins/StreamingTargetPlugin.mjs +46 -0
  70. package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -0
  71. package/dist/src/plugins/UniversalFederationPlugin.d.mts +49 -0
  72. package/dist/src/plugins/UniversalFederationPlugin.d.ts +26 -23
  73. package/dist/src/plugins/UniversalFederationPlugin.js +62 -81
  74. package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -1
  75. package/dist/src/plugins/UniversalFederationPlugin.mjs +65 -0
  76. package/dist/src/plugins/UniversalFederationPlugin.mjs.map +1 -0
  77. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.mts +9 -0
  78. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.ts +6 -3
  79. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js +14 -17
  80. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js.map +1 -1
  81. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs +23 -0
  82. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs.map +1 -0
  83. package/dist/src/plugins/webpackChunkUtilities.d.mts +55 -0
  84. package/dist/src/plugins/webpackChunkUtilities.d.ts +14 -9
  85. package/dist/src/plugins/webpackChunkUtilities.js +195 -257
  86. package/dist/src/plugins/webpackChunkUtilities.js.map +1 -1
  87. package/dist/src/plugins/webpackChunkUtilities.mjs +234 -0
  88. package/dist/src/plugins/webpackChunkUtilities.mjs.map +1 -0
  89. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.mts +7 -0
  90. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.ts +5 -2
  91. package/dist/src/recordDynamicRemoteEntryHashPlugin.js +24 -61
  92. package/dist/src/recordDynamicRemoteEntryHashPlugin.js.map +1 -1
  93. package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs +26 -0
  94. package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs.map +1 -0
  95. package/dist/src/runtimePlugin.d.mts +27 -0
  96. package/dist/src/runtimePlugin.d.ts +24 -19
  97. package/dist/src/runtimePlugin.js +214 -252
  98. package/dist/src/runtimePlugin.js.map +1 -1
  99. package/dist/src/runtimePlugin.mjs +226 -0
  100. package/dist/src/runtimePlugin.mjs.map +1 -0
  101. package/dist/src/types/index.d.mts +8 -0
  102. package/dist/src/types/index.d.ts +8 -3
  103. package/dist/src/types/index.js +1 -3
  104. package/dist/src/types/index.mjs +1 -0
  105. package/dist/src/utils/flush-chunks.d.mts +17 -0
  106. package/dist/src/utils/flush-chunks.d.ts +9 -3
  107. package/dist/src/utils/flush-chunks.js +138 -167
  108. package/dist/src/utils/flush-chunks.js.map +1 -1
  109. package/dist/src/utils/flush-chunks.mjs +144 -0
  110. package/dist/src/utils/flush-chunks.mjs.map +1 -0
  111. package/dist/src/utils/hot-reload.d.mts +16 -0
  112. package/dist/src/utils/hot-reload.d.ts +14 -10
  113. package/dist/src/utils/hot-reload.js +178 -264
  114. package/dist/src/utils/hot-reload.js.map +1 -1
  115. package/dist/src/utils/hot-reload.mjs +195 -0
  116. package/dist/src/utils/hot-reload.mjs.map +1 -0
  117. package/dist/src/utils/index.d.mts +3 -0
  118. package/dist/src/utils/index.d.ts +3 -2
  119. package/dist/src/utils/index.js +15 -19
  120. package/dist/src/utils/index.mjs +4 -0
  121. package/package.json +71 -26
  122. package/dist/jest.config.d.ts +0 -11
  123. package/dist/jest.config.js +0 -19
  124. package/dist/jest.config.js.map +0 -1
  125. package/dist/package.json +0 -90
  126. package/dist/src/index.js.map +0 -1
  127. package/dist/src/types/index.js.map +0 -1
  128. package/dist/src/utils/index.js.map +0 -1
@@ -1,177 +1,148 @@
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
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ let _module_federation_sdk = require("@module-federation/sdk");
4
+
5
+ //#region src/utils/flush-chunks.ts
6
+ if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
10
7
  /**
11
- * Initialize usedChunks and share it globally.
12
- * @type {Set}
13
- */
14
- // @ts-ignore
15
- exports.usedChunks = globalThis.usedChunks;
16
- /**
17
- * Load hostStats from the JSON file.
18
- * @returns {object} hostStats - An object containing host stats data.
19
- */
20
- const loadHostStats = () => {
21
- try {
22
- //@ts-ignore
23
- return __non_webpack_require__('../federated-stats.json');
24
- }
25
- catch (e) {
26
- return {};
27
- }
8
+ * Initialize usedChunks and share it globally.
9
+ * @type {Set}
10
+ */
11
+ const { usedChunks } = globalThis;
12
+ const getFederationController = () => new Function("return globalThis")().__FEDERATION__;
13
+ const getAllKnownRemotes = function() {
14
+ const federationController = getFederationController();
15
+ if (!federationController || !federationController.__INSTANCES__) return {};
16
+ const collected = {};
17
+ for (const instance of federationController.__INSTANCES__) for (const [, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) {
18
+ const remoteInfo = cacheModule.remoteInfo;
19
+ collected[remoteInfo.name] = remoteInfo;
20
+ if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;
21
+ }
22
+ return collected;
28
23
  };
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;
24
+ const getConfiguredManifestUrls = () => {
25
+ const manifestUrls = /* @__PURE__ */ new Map();
26
+ const federationController = getFederationController();
27
+ for (const instance of federationController?.__INSTANCES__ || []) for (const configuredRemote of instance.options?.remotes || []) {
28
+ if (!("entry" in configuredRemote)) continue;
29
+ try {
30
+ if (!new URL(configuredRemote.entry).pathname.endsWith(".json")) continue;
31
+ } catch {
32
+ continue;
33
+ }
34
+ manifestUrls.set(configuredRemote.name, configuredRemote.entry);
35
+ if (configuredRemote.alias) manifestUrls.set(configuredRemote.alias, configuredRemote.entry);
36
+ }
37
+ return manifestUrls;
50
38
  };
51
- exports.getAllKnownRemotes = getAllKnownRemotes;
52
- /**
53
- * Create a shareMap based on the loaded modules.
54
- * @returns {object} shareMap - An object containing the shareMap data.
55
- */
56
- 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 {};
39
+ const parseUsedChunk = (chunk, remoteNames) => {
40
+ const normalizedChunk = chunk.replace("->", "/");
41
+ const remote = remoteNames.find((name) => normalizedChunk === name || normalizedChunk.startsWith(`${name}/`)) || normalizedChunk.split("/", 1)[0];
42
+ const request = normalizedChunk.slice(remote.length).replace(/^\//, "");
43
+ return [remote, request.startsWith("./") ? request : `./${request}`];
88
44
  };
89
- /**
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
97
- 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
- }
45
+ const getMetadataUrl = (entry, filename) => {
46
+ const url = new URL(entry);
47
+ url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1)}${filename}`;
48
+ url.pathname = url.pathname.replace("/ssr/", "/chunks/");
49
+ return url.href;
50
+ };
51
+ const getManifestUrl = (remoteInfo, configuredManifestUrl) => {
52
+ if (configuredManifestUrl) return configuredManifestUrl;
53
+ return getMetadataUrl(remoteInfo.entry, "mf-manifest.json");
54
+ };
55
+ const getAssetBaseUrl = (metadataUrl) => {
56
+ const baseUrl = new URL(metadataUrl);
57
+ const staticPathIndex = baseUrl.pathname.indexOf("/static/");
58
+ baseUrl.pathname = staticPathIndex === -1 ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf("/") + 1) : baseUrl.pathname.slice(0, staticPathIndex + 1);
59
+ baseUrl.search = "";
60
+ baseUrl.hash = "";
61
+ return baseUrl;
62
+ };
63
+ const fetchJson = async (url) => {
64
+ const response = await fetch(url);
65
+ if (!response.ok) throw new Error(`Request failed with status ${response.status}`);
66
+ return response.json();
67
+ };
68
+ const collectManifestAssets = (manifest, manifestUrl, requests) => {
69
+ const chunks = /* @__PURE__ */ new Set();
70
+ const missingRequests = new Set(requests);
71
+ let assetBaseUrl = getAssetBaseUrl(manifestUrl);
72
+ const resourceBasePath = (0, _module_federation_sdk.getResourceUrl)(manifest.metaData, "");
73
+ if (resourceBasePath !== "auto") {
74
+ const normalizedBasePath = resourceBasePath && !resourceBasePath.endsWith("/") ? `${resourceBasePath}/` : resourceBasePath || "./";
75
+ assetBaseUrl = new URL(normalizedBasePath, manifestUrl);
76
+ }
77
+ const resolveAssetUrl = (file) => new URL(file, assetBaseUrl).href;
78
+ for (const expose of manifest.exposes) {
79
+ const request = expose.path || `./${expose.name}`;
80
+ if (!requests.has(request)) continue;
81
+ if (expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0) missingRequests.delete(request);
82
+ for (const file of expose.assets.js.sync) chunks.add(resolveAssetUrl(file));
83
+ for (const file of expose.assets.css.sync) chunks.add(resolveAssetUrl(file));
84
+ }
85
+ return {
86
+ chunks: Array.from(chunks),
87
+ missingRequests
88
+ };
89
+ };
90
+ const collectLegacyAssets = (stats, statsUrl, requests) => {
91
+ const chunks = /* @__PURE__ */ new Set();
92
+ const assetBaseUrl = getAssetBaseUrl(statsUrl);
93
+ for (const federatedModule of stats.federatedModules || []) for (const request of requests) for (const file of federatedModule.exposes?.[request] || []) chunks.add(new URL(file, assetBaseUrl).href);
94
+ return Array.from(chunks);
95
+ };
96
+ const processRemote = async (remoteInfo, requests, configuredManifestUrl) => {
97
+ const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);
98
+ let manifestChunks = [];
99
+ let legacyRequests = requests;
100
+ try {
101
+ const { chunks, missingRequests } = collectManifestAssets(await fetchJson(manifestUrl), manifestUrl, requests);
102
+ manifestChunks = chunks;
103
+ if (!missingRequests.size) return chunks;
104
+ legacyRequests = missingRequests;
105
+ } catch {}
106
+ const statsUrl = getMetadataUrl(remoteInfo.entry, "federated-stats.json");
107
+ try {
108
+ const stats = await fetchJson(statsUrl);
109
+ return Array.from(new Set([...manifestChunks, ...collectLegacyAssets(stats, statsUrl, legacyRequests)]));
110
+ } catch (error) {
111
+ if (!manifestChunks.length) console.error("flush error:", error);
112
+ return manifestChunks;
113
+ }
160
114
  };
161
115
  /**
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
- */
116
+ * Flush the chunks and return a deduplicated array of chunks.
117
+ * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
118
+ */
165
119
  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);
120
+ const knownRemotes = getAllKnownRemotes();
121
+ const configuredManifestUrls = getConfiguredManifestUrls();
122
+ const remoteNames = Object.keys(knownRemotes).sort((left, right) => right.length - left.length);
123
+ const requestsByRemote = /* @__PURE__ */ new Map();
124
+ for (const chunk of usedChunks) {
125
+ const [remote, request] = parseUsedChunk(chunk, remoteNames);
126
+ const remoteInfo = knownRemotes[remote];
127
+ if (!remoteInfo) {
128
+ console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
129
+ continue;
130
+ }
131
+ const remoteRequests = requestsByRemote.get(remoteInfo.name) || {
132
+ remoteInfo,
133
+ manifestUrl: configuredManifestUrls.get(remote) || configuredManifestUrls.get(remoteInfo.name),
134
+ requests: /* @__PURE__ */ new Set()
135
+ };
136
+ remoteRequests.requests.add(request);
137
+ requestsByRemote.set(remoteInfo.name, remoteRequests);
138
+ }
139
+ usedChunks.clear();
140
+ const allFlushed = await Promise.all(Array.from(requestsByRemote.values(), ({ remoteInfo, requests, manifestUrl }) => processRemote(remoteInfo, requests, manifestUrl)));
141
+ return Array.from(new Set(allFlushed.flat()));
175
142
  };
143
+
144
+ //#endregion
176
145
  exports.flushChunks = flushChunks;
146
+ exports.getAllKnownRemotes = getAllKnownRemotes;
147
+ exports.usedChunks = usedChunks;
177
148
  //# 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,CAAC;AACpC,CAAC;AACD;;;GAGG;AACH,aAAa;AACE,kBAAU,GAAK,UAAU,YAAC;AACzC;;;GAGG;AACH,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,IAAI,CAAC;QACH,YAAY;QACZ,OAAO,uBAAuB,CAAC,yBAAyB,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAEK,MAAM,kBAAkB,GAAG;IAChC,4DAA4D;IAC5D,MAAM,oBAAoB,GAAG,IAAI,QAAQ,CAAC,mBAAmB,CAA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.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\nimport { getResourceUrl, type Manifest } from '@module-federation/sdk';\nimport type { RemoteInfo } from '@module-federation/runtime/types';\n\ntype LegacyFederatedStats = {\n federatedModules?: Array<{\n exposes?: Record<string, string[]>;\n }>;\n};\n\ntype RemoteRequests = {\n remoteInfo: RemoteInfo;\n manifestUrl?: string;\n requests: Set<string>;\n};\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;\nconst getFederationController = () =>\n new Function('return globalThis')().__FEDERATION__;\n\nexport const getAllKnownRemotes = function (): Record<string, RemoteInfo> {\n const federationController = getFederationController();\n if (!federationController || !federationController.__INSTANCES__) {\n return {};\n }\n\n const collected: Record<string, RemoteInfo> = {};\n for (const instance of federationController.__INSTANCES__) {\n for (const [, cacheModule] of instance.moduleCache) {\n if (cacheModule.remoteInfo) {\n const remoteInfo = cacheModule.remoteInfo as RemoteInfo;\n collected[remoteInfo.name] = remoteInfo;\n if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;\n }\n }\n }\n return collected;\n};\n\nconst getConfiguredManifestUrls = (): Map<string, string> => {\n const manifestUrls = new Map<string, string>();\n const federationController = getFederationController();\n\n for (const instance of federationController?.__INSTANCES__ || []) {\n for (const configuredRemote of instance.options?.remotes || []) {\n if (!('entry' in configuredRemote)) continue;\n try {\n if (!new URL(configuredRemote.entry).pathname.endsWith('.json')) {\n continue;\n }\n } catch {\n continue;\n }\n manifestUrls.set(configuredRemote.name, configuredRemote.entry);\n if (configuredRemote.alias) {\n manifestUrls.set(configuredRemote.alias, configuredRemote.entry);\n }\n }\n }\n\n return manifestUrls;\n};\n\nconst parseUsedChunk = (\n chunk: string,\n remoteNames: string[],\n): [remote: string, request: string] => {\n const normalizedChunk = chunk.replace('->', '/');\n const remote =\n remoteNames.find(\n (name) =>\n normalizedChunk === name || normalizedChunk.startsWith(`${name}/`),\n ) || normalizedChunk.split('/', 1)[0];\n const request = normalizedChunk.slice(remote.length).replace(/^\\//, '');\n return [remote, request.startsWith('./') ? request : `./${request}`];\n};\n\nconst getMetadataUrl = (entry: string, filename: string): string => {\n const url = new URL(entry);\n url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf('/') + 1)}${filename}`;\n url.pathname = url.pathname.replace('/ssr/', '/chunks/');\n return url.href;\n};\n\nconst getManifestUrl = (\n remoteInfo: RemoteInfo,\n configuredManifestUrl?: string,\n): string => {\n if (configuredManifestUrl) return configuredManifestUrl;\n return getMetadataUrl(remoteInfo.entry, 'mf-manifest.json');\n};\n\nconst getAssetBaseUrl = (metadataUrl: string): URL => {\n const baseUrl = new URL(metadataUrl);\n const staticPathIndex = baseUrl.pathname.indexOf('/static/');\n baseUrl.pathname =\n staticPathIndex === -1\n ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf('/') + 1)\n : baseUrl.pathname.slice(0, staticPathIndex + 1);\n baseUrl.search = '';\n baseUrl.hash = '';\n return baseUrl;\n};\n\nconst fetchJson = async <T>(url: string): Promise<T> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n return response.json() as Promise<T>;\n};\n\nconst collectManifestAssets = (\n manifest: Manifest,\n manifestUrl: string,\n requests: Set<string>,\n): { chunks: string[]; missingRequests: Set<string> } => {\n const chunks = new Set<string>();\n const missingRequests = new Set(requests);\n let assetBaseUrl = getAssetBaseUrl(manifestUrl);\n const resourceBasePath = getResourceUrl(manifest.metaData, '');\n\n if (resourceBasePath !== 'auto') {\n const normalizedBasePath =\n resourceBasePath && !resourceBasePath.endsWith('/')\n ? `${resourceBasePath}/`\n : resourceBasePath || './';\n assetBaseUrl = new URL(normalizedBasePath, manifestUrl);\n }\n\n const resolveAssetUrl = (file: string) => new URL(file, assetBaseUrl).href;\n\n for (const expose of manifest.exposes) {\n const request = expose.path || `./${expose.name}`;\n if (!requests.has(request)) continue;\n\n const hasSyncAssets =\n expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0;\n if (hasSyncAssets) missingRequests.delete(request);\n\n for (const file of expose.assets.js.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n for (const file of expose.assets.css.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n }\n\n return { chunks: Array.from(chunks), missingRequests };\n};\n\nconst collectLegacyAssets = (\n stats: LegacyFederatedStats,\n statsUrl: string,\n requests: Set<string>,\n): string[] => {\n const chunks = new Set<string>();\n const assetBaseUrl = getAssetBaseUrl(statsUrl);\n\n for (const federatedModule of stats.federatedModules || []) {\n for (const request of requests) {\n for (const file of federatedModule.exposes?.[request] || []) {\n chunks.add(new URL(file, assetBaseUrl).href);\n }\n }\n }\n\n return Array.from(chunks);\n};\n\nconst processRemote = async (\n remoteInfo: RemoteInfo,\n requests: Set<string>,\n configuredManifestUrl?: string,\n): Promise<string[]> => {\n const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);\n let manifestChunks: string[] = [];\n let legacyRequests = requests;\n\n try {\n const manifest = await fetchJson<Manifest>(manifestUrl);\n const { chunks, missingRequests } = collectManifestAssets(\n manifest,\n manifestUrl,\n requests,\n );\n manifestChunks = chunks;\n if (!missingRequests.size) return chunks;\n legacyRequests = missingRequests;\n } catch {\n // Older remotes may only expose federated-stats.json.\n }\n\n const statsUrl = getMetadataUrl(remoteInfo.entry, 'federated-stats.json');\n try {\n const stats = await fetchJson<LegacyFederatedStats>(statsUrl);\n return Array.from(\n new Set([\n ...manifestChunks,\n ...collectLegacyAssets(stats, statsUrl, legacyRequests),\n ]),\n );\n } catch (error) {\n if (!manifestChunks.length) console.error('flush error:', error);\n return manifestChunks;\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 (): Promise<string[]> => {\n const knownRemotes = getAllKnownRemotes();\n const configuredManifestUrls = getConfiguredManifestUrls();\n const remoteNames = Object.keys(knownRemotes).sort(\n (left, right) => right.length - left.length,\n );\n const requestsByRemote = new Map<string, RemoteRequests>();\n\n for (const chunk of usedChunks) {\n const [remote, request] = parseUsedChunk(chunk, remoteNames);\n const remoteInfo = knownRemotes[remote];\n if (!remoteInfo) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n continue;\n }\n\n const remoteRequests = requestsByRemote.get(remoteInfo.name) || {\n remoteInfo,\n manifestUrl:\n configuredManifestUrls.get(remote) ||\n configuredManifestUrls.get(remoteInfo.name),\n requests: new Set<string>(),\n };\n remoteRequests.requests.add(request);\n requestsByRemote.set(remoteInfo.name, remoteRequests);\n }\n usedChunks.clear();\n\n const allFlushed = await Promise.all(\n Array.from(\n requestsByRemote.values(),\n ({ remoteInfo, requests, manifestUrl }) =>\n processRemote(remoteInfo, requests, manifestUrl),\n ),\n );\n\n return Array.from(new Set(allFlushed.flat()));\n};\n"],"mappings":";;;;;AAkBA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;AAC9B,MAAM,gCACJ,IAAI,SAAS,oBAAoB,EAAE,CAAC;AAEtC,MAAa,qBAAqB,WAAwC;CACxE,MAAM,uBAAuB,yBAAyB;AACtD,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cACjD,QAAO,EAAE;CAGX,MAAM,YAAwC,EAAE;AAChD,MAAK,MAAM,YAAY,qBAAqB,cAC1C,MAAK,MAAM,GAAG,gBAAgB,SAAS,YACrC,KAAI,YAAY,YAAY;EAC1B,MAAM,aAAa,YAAY;AAC/B,YAAU,WAAW,QAAQ;AAC7B,MAAI,WAAW,MAAO,WAAU,WAAW,SAAS;;AAI1D,QAAO;;AAGT,MAAM,kCAAuD;CAC3D,MAAM,+BAAe,IAAI,KAAqB;CAC9C,MAAM,uBAAuB,yBAAyB;AAEtD,MAAK,MAAM,YAAY,sBAAsB,iB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AAW,KAAK;GAC7C,0BAAU,IAAI,KAAa;GAC5B;AACD,iBAAe,SAAS,IAAI,QAAQ;AACpC,mBAAiB,IAAI,WAAW,MAAM,eAAe;;AAEvD,YAAW,OAAO;CAElB,MAAM,aAAa,MAAM,QAAQ,IAC/B,MAAM,KACJ,iBAAiB,QAAQ,GACxB,EAAE,YAAY,UAAU,kBACvB,cAAc,YAAY,UAAU,YAAY,CACnD,CACF;AAED,QAAO,MAAM,KAAK,IAAI,IAAI,WAAW,MAAM,CAAC,CAAC"}
@@ -0,0 +1,144 @@
1
+ import { getResourceUrl } from "@module-federation/sdk";
2
+
3
+ //#region src/utils/flush-chunks.ts
4
+ if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
5
+ /**
6
+ * Initialize usedChunks and share it globally.
7
+ * @type {Set}
8
+ */
9
+ const { usedChunks } = globalThis;
10
+ const getFederationController = () => new Function("return globalThis")().__FEDERATION__;
11
+ const getAllKnownRemotes = function() {
12
+ const federationController = getFederationController();
13
+ if (!federationController || !federationController.__INSTANCES__) return {};
14
+ const collected = {};
15
+ for (const instance of federationController.__INSTANCES__) for (const [, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) {
16
+ const remoteInfo = cacheModule.remoteInfo;
17
+ collected[remoteInfo.name] = remoteInfo;
18
+ if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;
19
+ }
20
+ return collected;
21
+ };
22
+ const getConfiguredManifestUrls = () => {
23
+ const manifestUrls = /* @__PURE__ */ new Map();
24
+ const federationController = getFederationController();
25
+ for (const instance of federationController?.__INSTANCES__ || []) for (const configuredRemote of instance.options?.remotes || []) {
26
+ if (!("entry" in configuredRemote)) continue;
27
+ try {
28
+ if (!new URL(configuredRemote.entry).pathname.endsWith(".json")) continue;
29
+ } catch {
30
+ continue;
31
+ }
32
+ manifestUrls.set(configuredRemote.name, configuredRemote.entry);
33
+ if (configuredRemote.alias) manifestUrls.set(configuredRemote.alias, configuredRemote.entry);
34
+ }
35
+ return manifestUrls;
36
+ };
37
+ const parseUsedChunk = (chunk, remoteNames) => {
38
+ const normalizedChunk = chunk.replace("->", "/");
39
+ const remote = remoteNames.find((name) => normalizedChunk === name || normalizedChunk.startsWith(`${name}/`)) || normalizedChunk.split("/", 1)[0];
40
+ const request = normalizedChunk.slice(remote.length).replace(/^\//, "");
41
+ return [remote, request.startsWith("./") ? request : `./${request}`];
42
+ };
43
+ const getMetadataUrl = (entry, filename) => {
44
+ const url = new URL(entry);
45
+ url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1)}${filename}`;
46
+ url.pathname = url.pathname.replace("/ssr/", "/chunks/");
47
+ return url.href;
48
+ };
49
+ const getManifestUrl = (remoteInfo, configuredManifestUrl) => {
50
+ if (configuredManifestUrl) return configuredManifestUrl;
51
+ return getMetadataUrl(remoteInfo.entry, "mf-manifest.json");
52
+ };
53
+ const getAssetBaseUrl = (metadataUrl) => {
54
+ const baseUrl = new URL(metadataUrl);
55
+ const staticPathIndex = baseUrl.pathname.indexOf("/static/");
56
+ baseUrl.pathname = staticPathIndex === -1 ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf("/") + 1) : baseUrl.pathname.slice(0, staticPathIndex + 1);
57
+ baseUrl.search = "";
58
+ baseUrl.hash = "";
59
+ return baseUrl;
60
+ };
61
+ const fetchJson = async (url) => {
62
+ const response = await fetch(url);
63
+ if (!response.ok) throw new Error(`Request failed with status ${response.status}`);
64
+ return response.json();
65
+ };
66
+ const collectManifestAssets = (manifest, manifestUrl, requests) => {
67
+ const chunks = /* @__PURE__ */ new Set();
68
+ const missingRequests = new Set(requests);
69
+ let assetBaseUrl = getAssetBaseUrl(manifestUrl);
70
+ const resourceBasePath = getResourceUrl(manifest.metaData, "");
71
+ if (resourceBasePath !== "auto") {
72
+ const normalizedBasePath = resourceBasePath && !resourceBasePath.endsWith("/") ? `${resourceBasePath}/` : resourceBasePath || "./";
73
+ assetBaseUrl = new URL(normalizedBasePath, manifestUrl);
74
+ }
75
+ const resolveAssetUrl = (file) => new URL(file, assetBaseUrl).href;
76
+ for (const expose of manifest.exposes) {
77
+ const request = expose.path || `./${expose.name}`;
78
+ if (!requests.has(request)) continue;
79
+ if (expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0) missingRequests.delete(request);
80
+ for (const file of expose.assets.js.sync) chunks.add(resolveAssetUrl(file));
81
+ for (const file of expose.assets.css.sync) chunks.add(resolveAssetUrl(file));
82
+ }
83
+ return {
84
+ chunks: Array.from(chunks),
85
+ missingRequests
86
+ };
87
+ };
88
+ const collectLegacyAssets = (stats, statsUrl, requests) => {
89
+ const chunks = /* @__PURE__ */ new Set();
90
+ const assetBaseUrl = getAssetBaseUrl(statsUrl);
91
+ for (const federatedModule of stats.federatedModules || []) for (const request of requests) for (const file of federatedModule.exposes?.[request] || []) chunks.add(new URL(file, assetBaseUrl).href);
92
+ return Array.from(chunks);
93
+ };
94
+ const processRemote = async (remoteInfo, requests, configuredManifestUrl) => {
95
+ const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);
96
+ let manifestChunks = [];
97
+ let legacyRequests = requests;
98
+ try {
99
+ const { chunks, missingRequests } = collectManifestAssets(await fetchJson(manifestUrl), manifestUrl, requests);
100
+ manifestChunks = chunks;
101
+ if (!missingRequests.size) return chunks;
102
+ legacyRequests = missingRequests;
103
+ } catch {}
104
+ const statsUrl = getMetadataUrl(remoteInfo.entry, "federated-stats.json");
105
+ try {
106
+ const stats = await fetchJson(statsUrl);
107
+ return Array.from(new Set([...manifestChunks, ...collectLegacyAssets(stats, statsUrl, legacyRequests)]));
108
+ } catch (error) {
109
+ if (!manifestChunks.length) console.error("flush error:", error);
110
+ return manifestChunks;
111
+ }
112
+ };
113
+ /**
114
+ * Flush the chunks and return a deduplicated array of chunks.
115
+ * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
116
+ */
117
+ const flushChunks = async () => {
118
+ const knownRemotes = getAllKnownRemotes();
119
+ const configuredManifestUrls = getConfiguredManifestUrls();
120
+ const remoteNames = Object.keys(knownRemotes).sort((left, right) => right.length - left.length);
121
+ const requestsByRemote = /* @__PURE__ */ new Map();
122
+ for (const chunk of usedChunks) {
123
+ const [remote, request] = parseUsedChunk(chunk, remoteNames);
124
+ const remoteInfo = knownRemotes[remote];
125
+ if (!remoteInfo) {
126
+ console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
127
+ continue;
128
+ }
129
+ const remoteRequests = requestsByRemote.get(remoteInfo.name) || {
130
+ remoteInfo,
131
+ manifestUrl: configuredManifestUrls.get(remote) || configuredManifestUrls.get(remoteInfo.name),
132
+ requests: /* @__PURE__ */ new Set()
133
+ };
134
+ remoteRequests.requests.add(request);
135
+ requestsByRemote.set(remoteInfo.name, remoteRequests);
136
+ }
137
+ usedChunks.clear();
138
+ const allFlushed = await Promise.all(Array.from(requestsByRemote.values(), ({ remoteInfo, requests, manifestUrl }) => processRemote(remoteInfo, requests, manifestUrl)));
139
+ return Array.from(new Set(allFlushed.flat()));
140
+ };
141
+
142
+ //#endregion
143
+ export { flushChunks, getAllKnownRemotes, usedChunks };
144
+ //# sourceMappingURL=flush-chunks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flush-chunks.mjs","names":[],"sources":["../../../src/utils/flush-chunks.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\nimport { getResourceUrl, type Manifest } from '@module-federation/sdk';\nimport type { RemoteInfo } from '@module-federation/runtime/types';\n\ntype LegacyFederatedStats = {\n federatedModules?: Array<{\n exposes?: Record<string, string[]>;\n }>;\n};\n\ntype RemoteRequests = {\n remoteInfo: RemoteInfo;\n manifestUrl?: string;\n requests: Set<string>;\n};\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;\nconst getFederationController = () =>\n new Function('return globalThis')().__FEDERATION__;\n\nexport const getAllKnownRemotes = function (): Record<string, RemoteInfo> {\n const federationController = getFederationController();\n if (!federationController || !federationController.__INSTANCES__) {\n return {};\n }\n\n const collected: Record<string, RemoteInfo> = {};\n for (const instance of federationController.__INSTANCES__) {\n for (const [, cacheModule] of instance.moduleCache) {\n if (cacheModule.remoteInfo) {\n const remoteInfo = cacheModule.remoteInfo as RemoteInfo;\n collected[remoteInfo.name] = remoteInfo;\n if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;\n }\n }\n }\n return collected;\n};\n\nconst getConfiguredManifestUrls = (): Map<string, string> => {\n const manifestUrls = new Map<string, string>();\n const federationController = getFederationController();\n\n for (const instance of federationController?.__INSTANCES__ || []) {\n for (const configuredRemote of instance.options?.remotes || []) {\n if (!('entry' in configuredRemote)) continue;\n try {\n if (!new URL(configuredRemote.entry).pathname.endsWith('.json')) {\n continue;\n }\n } catch {\n continue;\n }\n manifestUrls.set(configuredRemote.name, configuredRemote.entry);\n if (configuredRemote.alias) {\n manifestUrls.set(configuredRemote.alias, configuredRemote.entry);\n }\n }\n }\n\n return manifestUrls;\n};\n\nconst parseUsedChunk = (\n chunk: string,\n remoteNames: string[],\n): [remote: string, request: string] => {\n const normalizedChunk = chunk.replace('->', '/');\n const remote =\n remoteNames.find(\n (name) =>\n normalizedChunk === name || normalizedChunk.startsWith(`${name}/`),\n ) || normalizedChunk.split('/', 1)[0];\n const request = normalizedChunk.slice(remote.length).replace(/^\\//, '');\n return [remote, request.startsWith('./') ? request : `./${request}`];\n};\n\nconst getMetadataUrl = (entry: string, filename: string): string => {\n const url = new URL(entry);\n url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf('/') + 1)}${filename}`;\n url.pathname = url.pathname.replace('/ssr/', '/chunks/');\n return url.href;\n};\n\nconst getManifestUrl = (\n remoteInfo: RemoteInfo,\n configuredManifestUrl?: string,\n): string => {\n if (configuredManifestUrl) return configuredManifestUrl;\n return getMetadataUrl(remoteInfo.entry, 'mf-manifest.json');\n};\n\nconst getAssetBaseUrl = (metadataUrl: string): URL => {\n const baseUrl = new URL(metadataUrl);\n const staticPathIndex = baseUrl.pathname.indexOf('/static/');\n baseUrl.pathname =\n staticPathIndex === -1\n ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf('/') + 1)\n : baseUrl.pathname.slice(0, staticPathIndex + 1);\n baseUrl.search = '';\n baseUrl.hash = '';\n return baseUrl;\n};\n\nconst fetchJson = async <T>(url: string): Promise<T> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n return response.json() as Promise<T>;\n};\n\nconst collectManifestAssets = (\n manifest: Manifest,\n manifestUrl: string,\n requests: Set<string>,\n): { chunks: string[]; missingRequests: Set<string> } => {\n const chunks = new Set<string>();\n const missingRequests = new Set(requests);\n let assetBaseUrl = getAssetBaseUrl(manifestUrl);\n const resourceBasePath = getResourceUrl(manifest.metaData, '');\n\n if (resourceBasePath !== 'auto') {\n const normalizedBasePath =\n resourceBasePath && !resourceBasePath.endsWith('/')\n ? `${resourceBasePath}/`\n : resourceBasePath || './';\n assetBaseUrl = new URL(normalizedBasePath, manifestUrl);\n }\n\n const resolveAssetUrl = (file: string) => new URL(file, assetBaseUrl).href;\n\n for (const expose of manifest.exposes) {\n const request = expose.path || `./${expose.name}`;\n if (!requests.has(request)) continue;\n\n const hasSyncAssets =\n expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0;\n if (hasSyncAssets) missingRequests.delete(request);\n\n for (const file of expose.assets.js.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n for (const file of expose.assets.css.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n }\n\n return { chunks: Array.from(chunks), missingRequests };\n};\n\nconst collectLegacyAssets = (\n stats: LegacyFederatedStats,\n statsUrl: string,\n requests: Set<string>,\n): string[] => {\n const chunks = new Set<string>();\n const assetBaseUrl = getAssetBaseUrl(statsUrl);\n\n for (const federatedModule of stats.federatedModules || []) {\n for (const request of requests) {\n for (const file of federatedModule.exposes?.[request] || []) {\n chunks.add(new URL(file, assetBaseUrl).href);\n }\n }\n }\n\n return Array.from(chunks);\n};\n\nconst processRemote = async (\n remoteInfo: RemoteInfo,\n requests: Set<string>,\n configuredManifestUrl?: string,\n): Promise<string[]> => {\n const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);\n let manifestChunks: string[] = [];\n let legacyRequests = requests;\n\n try {\n const manifest = await fetchJson<Manifest>(manifestUrl);\n const { chunks, missingRequests } = collectManifestAssets(\n manifest,\n manifestUrl,\n requests,\n );\n manifestChunks = chunks;\n if (!missingRequests.size) return chunks;\n legacyRequests = missingRequests;\n } catch {\n // Older remotes may only expose federated-stats.json.\n }\n\n const statsUrl = getMetadataUrl(remoteInfo.entry, 'federated-stats.json');\n try {\n const stats = await fetchJson<LegacyFederatedStats>(statsUrl);\n return Array.from(\n new Set([\n ...manifestChunks,\n ...collectLegacyAssets(stats, statsUrl, legacyRequests),\n ]),\n );\n } catch (error) {\n if (!manifestChunks.length) console.error('flush error:', error);\n return manifestChunks;\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 (): Promise<string[]> => {\n const knownRemotes = getAllKnownRemotes();\n const configuredManifestUrls = getConfiguredManifestUrls();\n const remoteNames = Object.keys(knownRemotes).sort(\n (left, right) => right.length - left.length,\n );\n const requestsByRemote = new Map<string, RemoteRequests>();\n\n for (const chunk of usedChunks) {\n const [remote, request] = parseUsedChunk(chunk, remoteNames);\n const remoteInfo = knownRemotes[remote];\n if (!remoteInfo) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n continue;\n }\n\n const remoteRequests = requestsByRemote.get(remoteInfo.name) || {\n remoteInfo,\n manifestUrl:\n configuredManifestUrls.get(remote) ||\n configuredManifestUrls.get(remoteInfo.name),\n requests: new Set<string>(),\n };\n remoteRequests.requests.add(request);\n requestsByRemote.set(remoteInfo.name, remoteRequests);\n }\n usedChunks.clear();\n\n const allFlushed = await Promise.all(\n Array.from(\n requestsByRemote.values(),\n ({ remoteInfo, requests, manifestUrl }) =>\n processRemote(remoteInfo, requests, manifestUrl),\n ),\n );\n\n return Array.from(new Set(allFlushed.flat()));\n};\n"],"mappings":";;;AAkBA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;AAC9B,MAAM,gCACJ,IAAI,SAAS,oBAAoB,EAAE,CAAC;AAEtC,MAAa,qBAAqB,WAAwC;CACxE,MAAM,uBAAuB,yBAAyB;AACtD,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cACjD,QAAO,EAAE;CAGX,MAAM,YAAwC,EAAE;AAChD,MAAK,MAAM,YAAY,qBAAqB,cAC1C,MAAK,MAAM,GAAG,gBAAgB,SAAS,YACrC,KAAI,YAAY,YAAY;EAC1B,MAAM,aAAa,YAAY;AAC/B,YAAU,WAAW,QAAQ;AAC7B,MAAI,WAAW,MAAO,WAAU,WAAW,SAAS;;AAI1D,QAAO;;AAGT,MAAM,kCAAuD;CAC3D,MAAM,+BAAe,IAAI,KAAqB;CAC9C,MAAM,uBAAuB,yBAAyB;AAEtD,MAAK,MAAM,YAAY,sBAAsB,iBAAiB,EAAE,CAC9D,MAAK,MAAM,oBAAoB,SAAS,SAAS,WAAW,EAAE,EAAE;AAC9D,MAAI,EAAE,WAAW,kBAAmB;AACpC,MAAI;AACF,OAAI,CAAC,IAAI,IAAI,iBAAiB,MAAM,CAAC,SAAS,SAAS,QAAQ,CAC7D;UAEI;AACN;;AAEF,eAAa,IAAI,iBAAiB,MAAM,iBAAiB,MAAM;AAC/D,MAAI,iBAAiB,MACnB,cAAa,IAAI,iBAAiB,OAAO,iBAAiB,MAAM;;AAKtE,QAAO;;AAGT,MAAM,kBACJ,OACA,gBACsC;CACtC,MAAM,kBAAkB,MAAM,QAAQ,MAAM,IAAI;CAChD,MAAM,SACJ,YAAY,MAC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ty: boolean;
5
+ }
6
+ declare const performReload: (shouldReload: boolean) => Promise<boolean>;
7
+ declare const checkUnreachableRemote: (remoteScope: any) => boolean;
8
+ declare const checkMedusaConfigChange: (remoteScope: any, fetchModule: any) => boolean;
9
+ declare const checkFakeRemote: (remoteScope: any) => boolean;
10
+ declare const createFetcher: (url: string, fetchModule: any, name: string, cb: (hash: string) => void) => Promise<void | boolean>;
11
+ declare const fetchRemote: (remoteScope: any, fetchModule: any) => Promise<boolean>;
12
+ declare const revalidate: (fetchModule?: any, force?: boolean) => Promise<boolean>;
13
+ declare function getFetchModule(): any;
14
+ //#endregion
15
+ export { checkFakeRemote, checkMedusaConfigChange, checkUnreachableRemote, createFetcher, fetchRemote, getFetchModule, performReload, revalidate };
16
+ //# sourceMappingURL=hot-reload.d.mts.map
@@ -1,12 +1,16 @@
1
+ //#region src/utils/hot-reload.d.ts
1
2
  declare global {
2
- var mfHashMap: Record<string, string> | undefined;
3
- var moduleGraphDirty: boolean;
3
+ var mfHashMap: Record<string, string> | undefined;
4
+ var moduleGraphDirty: boolean;
4
5
  }
5
- export declare const performReload: (shouldReload: boolean) => Promise<boolean>;
6
- export declare const checkUnreachableRemote: (remoteScope: any) => boolean;
7
- export declare const checkMedusaConfigChange: (remoteScope: any, fetchModule: any) => boolean;
8
- export declare const checkFakeRemote: (remoteScope: any) => boolean;
9
- export declare const createFetcher: (url: string, fetchModule: any, name: string, cb: (hash: string) => void) => Promise<void | boolean>;
10
- export declare const fetchRemote: (remoteScope: any, fetchModule: any) => Promise<boolean>;
11
- export declare const revalidate: (fetchModule?: any, force?: boolean) => Promise<boolean>;
12
- export declare function getFetchModule(): any;
6
+ declare const performReload: (shouldReload: boolean) => Promise<boolean>;
7
+ declare const checkUnreachableRemote: (remoteScope: any) => boolean;
8
+ declare const checkMedusaConfigChange: (remoteScope: any, fetchModule: any) => boolean;
9
+ declare const checkFakeRemote: (remoteScope: any) => boolean;
10
+ declare const createFetcher: (url: string, fetchModule: any, name: string, cb: (hash: string) => void) => Promise<void | boolean>;
11
+ declare const fetchRemote: (remoteScope: any, fetchModule: any) => Promise<boolean>;
12
+ declare const revalidate: (fetchModule?: any, force?: boolean) => Promise<boolean>;
13
+ declare function getFetchModule(): any;
14
+ //#endregion
15
+ export { checkFakeRemote, checkMedusaConfigChange, checkUnreachableRemote, createFetcher, fetchRemote, getFetchModule, performReload, revalidate };
16
+ //# sourceMappingURL=hot-reload.d.ts.map