remote-reload-utils 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/loader/utils.d.ts +4 -1
- package/dist/main.cjs +30 -23
- package/dist/main.js +30 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 8e4a168: test publish
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- d5c8346: 完善单元测试 & runtime 实例重试机制
|
|
12
|
+
|
|
3
13
|
## 1.0.0
|
|
4
14
|
|
|
5
15
|
### Major Changes
|
|
@@ -13,6 +23,12 @@
|
|
|
13
23
|
|
|
14
24
|
## [未发布]
|
|
15
25
|
|
|
26
|
+
## [1.0.1] - 2026-03-20
|
|
27
|
+
|
|
28
|
+
### Release
|
|
29
|
+
|
|
30
|
+
- Published version 1.0.1 with patch bump
|
|
31
|
+
|
|
16
32
|
## [0.0.17] - 2026-03-19
|
|
17
33
|
|
|
18
34
|
### Release
|
package/dist/loader/utils.d.ts
CHANGED
|
@@ -21,11 +21,14 @@ export interface LoadResult {
|
|
|
21
21
|
mf: ReturnType<typeof createInstance>;
|
|
22
22
|
}
|
|
23
23
|
export type RuntimeRemote = Parameters<ReturnType<typeof createInstance>['registerRemotes']>[0][number];
|
|
24
|
+
declare const mfInstanceCache: Map<string, import("@module-federation/enhanced/runtime").ModuleFederation>;
|
|
25
|
+
declare const mfInstanceLoadingCache: Map<string, Promise<LoadResult>>;
|
|
26
|
+
export { mfInstanceCache, mfInstanceLoadingCache };
|
|
24
27
|
/**
|
|
25
28
|
* 尝试加载单个远程模块 URL
|
|
26
29
|
* 注意:实际的重试机制在外层 loadRemoteMultiVersion 的 URL 遍历中实现
|
|
27
30
|
*/
|
|
28
|
-
export declare function tryLoadRemote(scopeName: string, url: string,
|
|
31
|
+
export declare function tryLoadRemote(scopeName: string, url: string, retries: number, delay: number, sharedConfig: Record<string, any>, plugins: ModuleFederationRuntimePlugin[], extraRemotes?: RuntimeRemote[], registerOptions?: {
|
|
29
32
|
force?: boolean;
|
|
30
33
|
}): Promise<LoadResult>;
|
|
31
34
|
/**
|
package/dist/main.cjs
CHANGED
|
@@ -335,7 +335,7 @@ function buildRemotesIdentity(remotes) {
|
|
|
335
335
|
entryGlobalName: remote.entryGlobalName || ''
|
|
336
336
|
})).sort().join('|');
|
|
337
337
|
}
|
|
338
|
-
async function tryLoadRemote(scopeName, url,
|
|
338
|
+
async function tryLoadRemote(scopeName, url, retries, delay, sharedConfig, plugins, extraRemotes = [], registerOptions = {}) {
|
|
339
339
|
const remotesIdentity = buildRemotesIdentity(extraRemotes);
|
|
340
340
|
const cacheKey = `${scopeName}::${url}::${remotesIdentity}::${registerOptions.force ? 'force' : 'normal'}`;
|
|
341
341
|
const cachedMfs = mfInstanceCache.get(cacheKey);
|
|
@@ -345,28 +345,35 @@ async function tryLoadRemote(scopeName, url, _retries, _delay, sharedConfig, plu
|
|
|
345
345
|
};
|
|
346
346
|
const loadingMfs = mfInstanceLoadingCache.get(cacheKey);
|
|
347
347
|
if (loadingMfs) return loadingMfs;
|
|
348
|
-
const loadPromise = Promise.resolve().then(()=>{
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
mf
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
348
|
+
const loadPromise = Promise.resolve().then(async ()=>{
|
|
349
|
+
let lastError;
|
|
350
|
+
for(let attempt = 0; attempt < retries; attempt++)try {
|
|
351
|
+
if (attempt > 0) await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
352
|
+
const mf = (0, runtime_namespaceObject.createInstance)({
|
|
353
|
+
name: 'host',
|
|
354
|
+
remotes: [
|
|
355
|
+
{
|
|
356
|
+
name: scopeName,
|
|
357
|
+
entry: url
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
shared: sharedConfig,
|
|
361
|
+
plugins: [
|
|
362
|
+
...plugins,
|
|
363
|
+
fallbackPlugin()
|
|
364
|
+
]
|
|
365
|
+
});
|
|
366
|
+
if (extraRemotes.length > 0) mf.registerRemotes(extraRemotes, registerOptions);
|
|
367
|
+
const result = {
|
|
368
|
+
scopeName,
|
|
369
|
+
mf
|
|
370
|
+
};
|
|
371
|
+
mfInstanceCache.set(cacheKey, mf);
|
|
372
|
+
return result;
|
|
373
|
+
} catch (e) {
|
|
374
|
+
lastError = e;
|
|
375
|
+
}
|
|
376
|
+
throw lastError || new Error('Unknown error');
|
|
370
377
|
});
|
|
371
378
|
mfInstanceLoadingCache.set(cacheKey, loadPromise);
|
|
372
379
|
try {
|
package/dist/main.js
CHANGED
|
@@ -267,7 +267,7 @@ function buildRemotesIdentity(remotes) {
|
|
|
267
267
|
entryGlobalName: remote.entryGlobalName || ''
|
|
268
268
|
})).sort().join('|');
|
|
269
269
|
}
|
|
270
|
-
async function tryLoadRemote(scopeName, url,
|
|
270
|
+
async function tryLoadRemote(scopeName, url, retries, delay, sharedConfig, plugins, extraRemotes = [], registerOptions = {}) {
|
|
271
271
|
const remotesIdentity = buildRemotesIdentity(extraRemotes);
|
|
272
272
|
const cacheKey = `${scopeName}::${url}::${remotesIdentity}::${registerOptions.force ? 'force' : 'normal'}`;
|
|
273
273
|
const cachedMfs = mfInstanceCache.get(cacheKey);
|
|
@@ -277,28 +277,35 @@ async function tryLoadRemote(scopeName, url, _retries, _delay, sharedConfig, plu
|
|
|
277
277
|
};
|
|
278
278
|
const loadingMfs = mfInstanceLoadingCache.get(cacheKey);
|
|
279
279
|
if (loadingMfs) return loadingMfs;
|
|
280
|
-
const loadPromise = Promise.resolve().then(()=>{
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
mf
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
280
|
+
const loadPromise = Promise.resolve().then(async ()=>{
|
|
281
|
+
let lastError;
|
|
282
|
+
for(let attempt = 0; attempt < retries; attempt++)try {
|
|
283
|
+
if (attempt > 0) await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
284
|
+
const mf = createInstance({
|
|
285
|
+
name: 'host',
|
|
286
|
+
remotes: [
|
|
287
|
+
{
|
|
288
|
+
name: scopeName,
|
|
289
|
+
entry: url
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
shared: sharedConfig,
|
|
293
|
+
plugins: [
|
|
294
|
+
...plugins,
|
|
295
|
+
fallbackPlugin()
|
|
296
|
+
]
|
|
297
|
+
});
|
|
298
|
+
if (extraRemotes.length > 0) mf.registerRemotes(extraRemotes, registerOptions);
|
|
299
|
+
const result = {
|
|
300
|
+
scopeName,
|
|
301
|
+
mf
|
|
302
|
+
};
|
|
303
|
+
mfInstanceCache.set(cacheKey, mf);
|
|
304
|
+
return result;
|
|
305
|
+
} catch (e) {
|
|
306
|
+
lastError = e;
|
|
307
|
+
}
|
|
308
|
+
throw lastError || new Error('Unknown error');
|
|
302
309
|
});
|
|
303
310
|
mfInstanceLoadingCache.set(cacheKey, loadPromise);
|
|
304
311
|
try {
|