remote-reload-utils 0.0.17 → 1.0.1
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 +57 -38
- package/dist/loader/utils.d.ts +4 -1
- package/dist/main.cjs +30 -23
- package/dist/main.js +30 -23
- package/package.json +21 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 9306c65: changeset cli 集成 & 变更日志记录
|
|
8
|
+
|
|
3
9
|
所有重要的项目变更都将记录在此文件中。
|
|
4
10
|
|
|
5
11
|
格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),
|
|
@@ -7,70 +13,69 @@
|
|
|
7
13
|
|
|
8
14
|
## [未发布]
|
|
9
15
|
|
|
16
|
+
## [1.0.1] - 2026-03-20
|
|
17
|
+
|
|
18
|
+
### Release
|
|
19
|
+
|
|
20
|
+
- Published version 1.0.1 with patch bump
|
|
21
|
+
|
|
22
|
+
|
|
10
23
|
## [0.0.17] - 2026-03-19
|
|
11
24
|
|
|
12
25
|
### Release
|
|
13
26
|
|
|
14
27
|
- Published version 0.0.17 with patch bump
|
|
15
28
|
|
|
16
|
-
|
|
17
29
|
## [0.0.16] - 2026-03-18
|
|
18
30
|
|
|
19
31
|
### Release
|
|
20
32
|
|
|
21
33
|
- Published version 0.0.16 with patch bump
|
|
22
34
|
|
|
23
|
-
|
|
24
35
|
## [0.0.15] - 2026-03-17
|
|
25
36
|
|
|
26
37
|
### Release
|
|
27
38
|
|
|
28
39
|
- Published version 0.0.15 with patch bump
|
|
29
40
|
|
|
30
|
-
|
|
31
41
|
## [0.0.14] - 2026-03-17
|
|
32
42
|
|
|
33
43
|
### Release
|
|
34
44
|
|
|
35
45
|
- Published version 0.0.14 with patch bump
|
|
36
46
|
|
|
37
|
-
|
|
38
47
|
## [0.0.13] - 2026-03-17
|
|
39
48
|
|
|
40
49
|
### Release
|
|
41
50
|
|
|
42
51
|
- Published version 0.0.13 with patch bump
|
|
43
52
|
|
|
44
|
-
|
|
45
53
|
## [0.0.12] - 2026-03-16
|
|
46
54
|
|
|
47
55
|
### Release
|
|
48
56
|
|
|
49
57
|
- Published version 0.0.12 with patch bump
|
|
50
58
|
|
|
51
|
-
|
|
52
59
|
## [0.0.11] - 2026-03-16
|
|
53
60
|
|
|
54
61
|
### Release
|
|
55
62
|
|
|
56
63
|
- Published version 0.0.11 with patch bump
|
|
57
64
|
|
|
58
|
-
|
|
59
65
|
## [0.0.10] - 2026-03-15
|
|
60
66
|
|
|
61
67
|
### Release
|
|
62
68
|
|
|
63
69
|
- Published version 0.0.10 with patch bump
|
|
64
70
|
|
|
65
|
-
|
|
66
71
|
## [0.0.9] - 2026-03-15
|
|
67
72
|
|
|
68
73
|
### Release
|
|
69
74
|
|
|
70
75
|
- Published version 0.0.9 with patch bump
|
|
71
76
|
|
|
72
|
-
|
|
73
77
|
### Refactor
|
|
78
|
+
|
|
74
79
|
- 重构项目为模块化目录结构
|
|
75
80
|
- `src/loader/` - 核心加载模块
|
|
76
81
|
- `src/version/` - 版本管理模块
|
|
@@ -84,6 +89,7 @@
|
|
|
84
89
|
- 更新 package.json types 路径为 `./dist/index.d.ts`
|
|
85
90
|
|
|
86
91
|
### Changed
|
|
92
|
+
|
|
87
93
|
- 修复 preloadRemote 引用从 loadRemote2 改为 loadRemote
|
|
88
94
|
- 移除 App.tsx 中未使用的 React 导入
|
|
89
95
|
- 添加 release 脚本到 package.json
|
|
@@ -91,6 +97,7 @@
|
|
|
91
97
|
## [0.0.8] - 2026-03-15
|
|
92
98
|
|
|
93
99
|
### Refactor
|
|
100
|
+
|
|
94
101
|
- 抽离公共工具函数到 `loadRemoteUtils.ts`
|
|
95
102
|
- 新增 `fetchLatestVersion()` - 从 npm registry 获取最新版本
|
|
96
103
|
- 新增 `getVersionCache()` / `setVersionCache()` - 缓存管理
|
|
@@ -103,14 +110,17 @@
|
|
|
103
110
|
- 简化 `loadRemote.ts`,使用公共工具函数
|
|
104
111
|
|
|
105
112
|
### Changed
|
|
113
|
+
|
|
106
114
|
- 更新 `index.ts` 导出,新增工具函数导出
|
|
107
115
|
|
|
108
116
|
### Docs
|
|
117
|
+
|
|
109
118
|
- 更新 `loadRemote.md`,添加工具函数 API 文档
|
|
110
119
|
|
|
111
120
|
## [0.0.7] - 2026-03-15
|
|
112
121
|
|
|
113
122
|
### Features
|
|
123
|
+
|
|
114
124
|
- 新增微前端工具函数集
|
|
115
125
|
- 远程模块加载
|
|
116
126
|
- React 多版本支持
|
|
@@ -121,15 +131,18 @@
|
|
|
121
131
|
## [0.0.6] - 2026-03-14
|
|
122
132
|
|
|
123
133
|
### Docs
|
|
134
|
+
|
|
124
135
|
- 更新 README 和 loadRemote.md 文档
|
|
125
136
|
- 添加使用指南和 API 参考
|
|
126
137
|
|
|
127
138
|
### Chore
|
|
139
|
+
|
|
128
140
|
- 更新 remote-reload-utils 版本至 0.0.8
|
|
129
141
|
|
|
130
142
|
## [0.0.5] - 2026-03-14
|
|
131
143
|
|
|
132
144
|
### Features
|
|
145
|
+
|
|
133
146
|
- 添加多版本远程加载功能
|
|
134
147
|
- 支持自定义 shared 配置
|
|
135
148
|
- 改进错误处理机制
|
|
@@ -137,33 +150,39 @@
|
|
|
137
150
|
## [0.0.4] - 2026-03-14
|
|
138
151
|
|
|
139
152
|
### Chore
|
|
153
|
+
|
|
140
154
|
- 更新错误处理逻辑
|
|
141
155
|
- 优化加载流程
|
|
142
156
|
|
|
143
157
|
## [0.0.3] - 2026-03-14
|
|
144
158
|
|
|
145
159
|
### Docs
|
|
160
|
+
|
|
146
161
|
- 添加项目描述和 git 仓库信息
|
|
147
162
|
- 更新 README 中的示例代码
|
|
148
163
|
- 将 loadRemote.md 从 src 移动到根目录
|
|
149
164
|
|
|
150
165
|
### Chore
|
|
166
|
+
|
|
151
167
|
- 更新 remote-reload-utils 的版本号至 0.0.3
|
|
152
168
|
|
|
153
169
|
## [0.0.2] - 2026-03-14
|
|
154
170
|
|
|
155
171
|
### Features
|
|
172
|
+
|
|
156
173
|
- 添加 React 多版本加载功能(v17/v18/v19)
|
|
157
174
|
- 添加共享配置支持
|
|
158
175
|
- 默认共享 react 和 react-dom
|
|
159
176
|
- 支持自定义共享模块
|
|
160
177
|
|
|
161
178
|
### Docs
|
|
179
|
+
|
|
162
180
|
- 更新示例代码展示如何使用 loadRemoteMultiVersion
|
|
163
181
|
|
|
164
182
|
## [0.0.1] - 2026-03-14
|
|
165
183
|
|
|
166
184
|
### Features
|
|
185
|
+
|
|
167
186
|
- 实现多版本远程模块加载功能
|
|
168
187
|
- 支持 CDN 故障转移(jsdelivr、unpkg)
|
|
169
188
|
- 支持本地 fallback 兜底
|
|
@@ -177,32 +196,32 @@
|
|
|
177
196
|
|
|
178
197
|
## 版本说明
|
|
179
198
|
|
|
180
|
-
| 版本
|
|
181
|
-
|
|
182
|
-
| 0.0.17 | 2026-03-19 | patch 版本发布
|
|
183
|
-
|
|
184
|
-
| 0.0.16 | 2026-03-18 | patch 版本发布
|
|
185
|
-
|
|
186
|
-
| 0.0.15 | 2026-03-17 | patch 版本发布
|
|
187
|
-
|
|
188
|
-
| 0.0.14 | 2026-03-17 | patch 版本发布
|
|
189
|
-
|
|
190
|
-
| 0.0.13 | 2026-03-17 | patch 版本发布
|
|
191
|
-
|
|
192
|
-
| 0.0.12 | 2026-03-16 | patch 版本发布
|
|
193
|
-
|
|
194
|
-
| 0.0.11 | 2026-03-16 | patch 版本发布
|
|
195
|
-
|
|
196
|
-
| 0.0.10 | 2026-03-15 | patch 版本发布
|
|
197
|
-
|
|
198
|
-
| 0.0.9
|
|
199
|
-
|
|
200
|
-
| 0.0.9
|
|
201
|
-
| 0.0.8
|
|
202
|
-
| 0.0.7
|
|
203
|
-
| 0.0.6
|
|
204
|
-
| 0.0.5
|
|
205
|
-
| 0.0.4
|
|
206
|
-
| 0.0.3
|
|
207
|
-
| 0.0.2
|
|
208
|
-
| 0.0.1
|
|
199
|
+
| 版本 | 日期 | 主要变更 |
|
|
200
|
+
| ------ | ---------- | ------------------------------ |
|
|
201
|
+
| 0.0.17 | 2026-03-19 | patch 版本发布 |
|
|
202
|
+
| ------ | ------ | ---------- |
|
|
203
|
+
| 0.0.16 | 2026-03-18 | patch 版本发布 |
|
|
204
|
+
| ------ | ------ | ---------- |
|
|
205
|
+
| 0.0.15 | 2026-03-17 | patch 版本发布 |
|
|
206
|
+
| ------ | ------ | ---------- |
|
|
207
|
+
| 0.0.14 | 2026-03-17 | patch 版本发布 |
|
|
208
|
+
| ------ | ------ | ---------- |
|
|
209
|
+
| 0.0.13 | 2026-03-17 | patch 版本发布 |
|
|
210
|
+
| ------ | ------ | ---------- |
|
|
211
|
+
| 0.0.12 | 2026-03-16 | patch 版本发布 |
|
|
212
|
+
| ------ | ------ | ---------- |
|
|
213
|
+
| 0.0.11 | 2026-03-16 | patch 版本发布 |
|
|
214
|
+
| ------ | ------ | ---------- |
|
|
215
|
+
| 0.0.10 | 2026-03-15 | patch 版本发布 |
|
|
216
|
+
| ------ | ------ | ---------- |
|
|
217
|
+
| 0.0.9 | 2026-03-15 | patch 版本发布 |
|
|
218
|
+
| ------ | ------ | ---------- |
|
|
219
|
+
| 0.0.9 | 2026-03-15 | 重构为模块化目录结构 |
|
|
220
|
+
| 0.0.8 | 2026-03-15 | 重构代码结构,抽离公共工具函数 |
|
|
221
|
+
| 0.0.7 | 2026-03-15 | 新增微前端工具函数集 |
|
|
222
|
+
| 0.0.6 | 2026-03-14 | 文档更新 |
|
|
223
|
+
| 0.0.5 | 2026-03-14 | 多版本远程加载 |
|
|
224
|
+
| 0.0.4 | 2026-03-14 | 错误处理优化 |
|
|
225
|
+
| 0.0.3 | 2026-03-14 | 文档和配置更新 |
|
|
226
|
+
| 0.0.2 | 2026-03-14 | React 多版本支持 |
|
|
227
|
+
| 0.0.1 | 2026-03-14 | 初始版本 |
|
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 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remote-reload-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utilities for remote reload in Module Federation & React Component",
|
|
6
6
|
"exports": {
|
|
@@ -57,23 +57,6 @@
|
|
|
57
57
|
"optional": true
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"build": "rslib build",
|
|
62
|
-
"dev": "rslib build --watch",
|
|
63
|
-
"prepublishOnly": "npm run build",
|
|
64
|
-
"format": "biome format --write",
|
|
65
|
-
"check": "biome check --write",
|
|
66
|
-
"test": "vitest run",
|
|
67
|
-
"test:watch": "vitest",
|
|
68
|
-
"lint": "biome format ./src --write",
|
|
69
|
-
"release:prepare": "node scripts/generateReleasePr.mjs",
|
|
70
|
-
"release:finalize": "node scripts/finalizeRelease.mjs",
|
|
71
|
-
"release:patch": "pnpm release:prepare -t patch",
|
|
72
|
-
"release:minor": "pnpm release:prepare -t minor",
|
|
73
|
-
"release:major": "pnpm release:prepare -t major",
|
|
74
|
-
"publish:dry": "npm publish --dry-run",
|
|
75
|
-
"publish:live": "npm publish"
|
|
76
|
-
},
|
|
77
60
|
"devDependencies": {
|
|
78
61
|
"@biomejs/biome": "2.0.6",
|
|
79
62
|
"@rslib/core": "0.17.0",
|
|
@@ -90,7 +73,26 @@
|
|
|
90
73
|
"typescript": "^5.9.2",
|
|
91
74
|
"vitest": "^2.1.8"
|
|
92
75
|
},
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
},
|
|
93
79
|
"dependencies": {
|
|
94
80
|
"@module-federation/enhanced": "0.18.3"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "rslib build",
|
|
84
|
+
"dev": "rslib build --watch",
|
|
85
|
+
"format": "biome format --write",
|
|
86
|
+
"check": "biome check --write",
|
|
87
|
+
"test": "vitest run",
|
|
88
|
+
"test:watch": "vitest",
|
|
89
|
+
"lint": "biome format ./src --write",
|
|
90
|
+
"release:prepare": "node scripts/generateReleasePr.mjs",
|
|
91
|
+
"release:finalize": "node scripts/finalizeRelease.mjs",
|
|
92
|
+
"release:patch": "pnpm release:prepare -t patch",
|
|
93
|
+
"release:minor": "pnpm release:prepare -t minor",
|
|
94
|
+
"release:major": "pnpm release:prepare -t major",
|
|
95
|
+
"publish:dry": "npm publish --dry-run",
|
|
96
|
+
"publish:live": "npm publish"
|
|
95
97
|
}
|
|
96
|
-
}
|
|
98
|
+
}
|