@module-federation/retry-plugin 2.0.1 → 2.2.0

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/README.md CHANGED
@@ -35,7 +35,7 @@ const mf = createInstance({
35
35
  {
36
36
  name: 'remote1',
37
37
  entry: 'http://localhost:2001/mf-manifest.json',
38
- }
38
+ },
39
39
  ],
40
40
  plugins: [
41
41
  RetryPlugin({
@@ -48,7 +48,7 @@ const mf = createInstance({
48
48
  onSuccess: ({ url }) => console.log('Success!', url),
49
49
  onError: ({ url }) => console.log('Failed!', url),
50
50
  }),
51
- ]
51
+ ],
52
52
  });
53
53
  ```
54
54
 
@@ -66,9 +66,7 @@ export default {
66
66
  remotes: {
67
67
  remote1: 'remote1@http://localhost:2001/mf-manifest.json',
68
68
  },
69
- runtimePlugins: [
70
- path.join(__dirname, './src/runtime-plugin/retry.ts'),
71
- ],
69
+ runtimePlugins: [path.join(__dirname, './src/runtime-plugin/retry.ts')],
72
70
  }),
73
71
  ],
74
72
  };
@@ -78,34 +76,35 @@ export default {
78
76
  // src/runtime-plugin/retry.ts
79
77
  import { RetryPlugin } from '@module-federation/retry-plugin';
80
78
 
81
- export default () => RetryPlugin({
82
- retryTimes: 3,
83
- retryDelay: 1000,
84
- domains: ['https://cdn1.example.com', 'https://cdn2.example.com'],
85
- manifestDomains: ['https://domain1.example.com', 'https://domain2.example.com'],
86
- addQuery: ({ times, originalQuery }) => `${originalQuery}&retry=${times}`,
87
- onRetry: ({ times, url }) => console.log('Retrying...', times, url),
88
- onSuccess: ({ url }) => console.log('Success!', url),
89
- onError: ({ url }) => console.log('Failed!', url),
90
- });
79
+ export default () =>
80
+ RetryPlugin({
81
+ retryTimes: 3,
82
+ retryDelay: 1000,
83
+ domains: ['https://cdn1.example.com', 'https://cdn2.example.com'],
84
+ manifestDomains: ['https://domain1.example.com', 'https://domain2.example.com'],
85
+ addQuery: ({ times, originalQuery }) => `${originalQuery}&retry=${times}`,
86
+ onRetry: ({ times, url }) => console.log('Retrying...', times, url),
87
+ onSuccess: ({ url }) => console.log('Success!', url),
88
+ onError: ({ url }) => console.log('Failed!', url),
89
+ });
91
90
  ```
92
91
 
93
92
  ## Configuration Options
94
93
 
95
94
  ### CommonRetryOptions
96
95
 
97
- | Option | Type | Default | Description |
98
- |--------|------|---------|-------------|
99
- | `retryTimes` | `number` | `3` | Number of retry attempts |
100
- | `retryDelay` | `number` | `1000` | Delay between retries in milliseconds |
101
- | `successTimes` | `number` | `0` | Number of successful requests required |
102
- | `domains` | `string[]` | `[]` | Alternative domains for script resources |
103
- | `manifestDomains` | `string[]` | `[]` | Alternative domains for manifest files |
104
- | `addQuery` | `boolean \| function` | `false` | Add query parameters for cache busting |
105
- | `fetchOptions` | `RequestInit` | `{}` | Additional fetch options |
106
- | `onRetry` | `function` | `undefined` | Callback when retry occurs |
107
- | `onSuccess` | `function` | `undefined` | Callback when request succeeds |
108
- | `onError` | `function` | `undefined` | Callback when all retries fail |
96
+ | Option | Type | Default | Description |
97
+ | ----------------- | --------------------- | ----------- | ---------------------------------------- |
98
+ | `retryTimes` | `number` | `3` | Number of retry attempts |
99
+ | `retryDelay` | `number` | `1000` | Delay between retries in milliseconds |
100
+ | `successTimes` | `number` | `0` | Number of successful requests required |
101
+ | `domains` | `string[]` | `[]` | Alternative domains for script resources |
102
+ | `manifestDomains` | `string[]` | `[]` | Alternative domains for manifest files |
103
+ | `addQuery` | `boolean \| function` | `false` | Add query parameters for cache busting |
104
+ | `fetchOptions` | `RequestInit` | `{}` | Additional fetch options |
105
+ | `onRetry` | `function` | `undefined` | Callback when retry occurs |
106
+ | `onSuccess` | `function` | `undefined` | Callback when request succeeds |
107
+ | `onError` | `function` | `undefined` | Callback when all retries fail |
109
108
 
110
109
  ### addQuery Function
111
110
 
@@ -114,7 +113,7 @@ addQuery: ({ times, originalQuery }) => {
114
113
  // Add retry count and timestamp for cache busting
115
114
  const separator = originalQuery ? '&' : '?';
116
115
  return `${originalQuery}${separator}retry=${times}&t=${Date.now()}`;
117
- }
116
+ };
118
117
  ```
119
118
 
120
119
  ### Callback Functions
@@ -144,15 +143,8 @@ onError: ({ domains, url, tagName }) => {
144
143
  RetryPlugin({
145
144
  retryTimes: 5,
146
145
  retryDelay: (attempt) => Math.pow(2, attempt) * 1000, // Exponential backoff
147
- domains: [
148
- 'https://cdn1.example.com',
149
- 'https://cdn2.example.com',
150
- 'https://cdn3.example.com',
151
- ],
152
- manifestDomains: [
153
- 'https://api1.example.com',
154
- 'https://api2.example.com',
155
- ],
146
+ domains: ['https://cdn1.example.com', 'https://cdn2.example.com', 'https://cdn3.example.com'],
147
+ manifestDomains: ['https://api1.example.com', 'https://api2.example.com'],
156
148
  addQuery: ({ times, originalQuery }) => {
157
149
  const params = new URLSearchParams(originalQuery);
158
150
  params.set('retry', times.toString());
@@ -171,7 +163,7 @@ RetryPlugin({
171
163
  console.error(`❌ Failed to load ${url} after all retries`);
172
164
  console.error(`❌ Tried all domains: ${domains?.join(', ')}`);
173
165
  },
174
- })
166
+ });
175
167
  ```
176
168
 
177
169
  ### Error Handling with Fallback
@@ -184,7 +176,7 @@ RetryPlugin({
184
176
  onError: ({ url, domains }) => {
185
177
  // Log error for monitoring
186
178
  console.error('Module loading failed:', { url, domains });
187
-
179
+
188
180
  // Send error to monitoring service
189
181
  if (window.gtag) {
190
182
  window.gtag('event', 'module_load_error', {
@@ -193,7 +185,7 @@ RetryPlugin({
193
185
  value: domains?.length || 0,
194
186
  });
195
187
  }
196
-
188
+
197
189
  // Show user-friendly error message
198
190
  const errorElement = document.createElement('div');
199
191
  errorElement.className = 'module-load-error';
@@ -206,7 +198,7 @@ RetryPlugin({
206
198
  `;
207
199
  document.body.appendChild(errorElement);
208
200
  },
209
- })
201
+ });
210
202
  ```
211
203
 
212
204
  ### Production Configuration
@@ -215,15 +207,8 @@ RetryPlugin({
215
207
  RetryPlugin({
216
208
  retryTimes: 3,
217
209
  retryDelay: 1000,
218
- domains: [
219
- 'https://cdn1.prod.example.com',
220
- 'https://cdn2.prod.example.com',
221
- 'https://cdn3.prod.example.com',
222
- ],
223
- manifestDomains: [
224
- 'https://api1.prod.example.com',
225
- 'https://api2.prod.example.com',
226
- ],
210
+ domains: ['https://cdn1.prod.example.com', 'https://cdn2.prod.example.com', 'https://cdn3.prod.example.com'],
211
+ manifestDomains: ['https://api1.prod.example.com', 'https://api2.prod.example.com'],
227
212
  addQuery: ({ times, originalQuery }) => {
228
213
  const params = new URLSearchParams(originalQuery);
229
214
  params.set('retry', times.toString());
@@ -251,13 +236,10 @@ RetryPlugin({
251
236
  onError: ({ url, domains }) => {
252
237
  // Send error to monitoring service
253
238
  if (window.errorReporting) {
254
- window.errorReporting.captureException(
255
- new Error(`Module loading failed: ${url}`),
256
- { extra: { domains, url } }
257
- );
239
+ window.errorReporting.captureException(new Error(`Module loading failed: ${url}`), { extra: { domains, url } });
258
240
  }
259
241
  },
260
- })
242
+ });
261
243
  ```
262
244
 
263
245
  ## How It Works
@@ -318,9 +300,11 @@ RetryPlugin({
318
300
  },
319
301
  script: {
320
302
  url: 'http://localhost:2001/static/js/async/src_App_tsx.js',
321
- customCreateScript: (url, attrs) => { /* ... */ },
322
- }
323
- })
303
+ customCreateScript: (url, attrs) => {
304
+ /* ... */
305
+ },
306
+ },
307
+ });
324
308
 
325
309
  // ✅ New way
326
310
  RetryPlugin({
@@ -329,7 +313,7 @@ RetryPlugin({
329
313
  domains: ['http://localhost:2001'],
330
314
  manifestDomains: ['http://localhost:2001'],
331
315
  addQuery: ({ times, originalQuery }) => `${originalQuery}&retry=${times}`,
332
- })
316
+ });
333
317
  ```
334
318
 
335
319
  ## Contributing
@@ -344,4 +328,4 @@ Contributions are welcome! Please read our [contributing guidelines](https://git
344
328
 
345
329
  - [Module Federation Documentation](https://module-federation.io/)
346
330
  - [Module Federation Runtime](https://www.npmjs.com/package/@module-federation/runtime)
347
- - [Module Federation Enhanced](https://www.npmjs.com/package/@module-federation/enhanced)
331
+ - [Module Federation Enhanced](https://www.npmjs.com/package/@module-federation/enhanced)
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @module-federation/retry-plugin
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [c856ec1]
8
+ - Updated dependencies [12240bb]
9
+ - Updated dependencies [e5dd6ef]
10
+ - @module-federation/sdk@2.2.0
11
+
12
+ ## 2.1.0
13
+
14
+ ### Patch Changes
15
+
16
+ - 918294f: Add missing release coverage for packages moved to the new build implementation and standardized ESM/CJS artifact outputs. This ensures package versioning and publish automation include the remaining affected packages on this branch.
17
+ - Updated dependencies [918294f]
18
+ - @module-federation/sdk@2.1.0
19
+
3
20
  ## 2.0.1
4
21
 
5
22
  ### Patch Changes
@@ -153,7 +170,6 @@
153
170
  ### Patch Changes
154
171
 
155
172
  - a7cf276: chore: upgrade NX to 21.2.3, Storybook to 9.0.9, and TypeScript to 5.8.3
156
-
157
173
  - Upgraded NX from 21.0.3 to 21.2.3 with workspace configuration updates
158
174
  - Migrated Storybook from 8.3.5 to 9.0.9 with updated configurations and automigrations
159
175
  - Upgraded TypeScript from 5.7.3 to 5.8.3 with compatibility fixes
package/dist/README.md CHANGED
@@ -35,7 +35,7 @@ const mf = createInstance({
35
35
  {
36
36
  name: 'remote1',
37
37
  entry: 'http://localhost:2001/mf-manifest.json',
38
- }
38
+ },
39
39
  ],
40
40
  plugins: [
41
41
  RetryPlugin({
@@ -48,7 +48,7 @@ const mf = createInstance({
48
48
  onSuccess: ({ url }) => console.log('Success!', url),
49
49
  onError: ({ url }) => console.log('Failed!', url),
50
50
  }),
51
- ]
51
+ ],
52
52
  });
53
53
  ```
54
54
 
@@ -66,9 +66,7 @@ export default {
66
66
  remotes: {
67
67
  remote1: 'remote1@http://localhost:2001/mf-manifest.json',
68
68
  },
69
- runtimePlugins: [
70
- path.join(__dirname, './src/runtime-plugin/retry.ts'),
71
- ],
69
+ runtimePlugins: [path.join(__dirname, './src/runtime-plugin/retry.ts')],
72
70
  }),
73
71
  ],
74
72
  };
@@ -78,34 +76,35 @@ export default {
78
76
  // src/runtime-plugin/retry.ts
79
77
  import { RetryPlugin } from '@module-federation/retry-plugin';
80
78
 
81
- export default () => RetryPlugin({
82
- retryTimes: 3,
83
- retryDelay: 1000,
84
- domains: ['https://cdn1.example.com', 'https://cdn2.example.com'],
85
- manifestDomains: ['https://domain1.example.com', 'https://domain2.example.com'],
86
- addQuery: ({ times, originalQuery }) => `${originalQuery}&retry=${times}`,
87
- onRetry: ({ times, url }) => console.log('Retrying...', times, url),
88
- onSuccess: ({ url }) => console.log('Success!', url),
89
- onError: ({ url }) => console.log('Failed!', url),
90
- });
79
+ export default () =>
80
+ RetryPlugin({
81
+ retryTimes: 3,
82
+ retryDelay: 1000,
83
+ domains: ['https://cdn1.example.com', 'https://cdn2.example.com'],
84
+ manifestDomains: ['https://domain1.example.com', 'https://domain2.example.com'],
85
+ addQuery: ({ times, originalQuery }) => `${originalQuery}&retry=${times}`,
86
+ onRetry: ({ times, url }) => console.log('Retrying...', times, url),
87
+ onSuccess: ({ url }) => console.log('Success!', url),
88
+ onError: ({ url }) => console.log('Failed!', url),
89
+ });
91
90
  ```
92
91
 
93
92
  ## Configuration Options
94
93
 
95
94
  ### CommonRetryOptions
96
95
 
97
- | Option | Type | Default | Description |
98
- |--------|------|---------|-------------|
99
- | `retryTimes` | `number` | `3` | Number of retry attempts |
100
- | `retryDelay` | `number` | `1000` | Delay between retries in milliseconds |
101
- | `successTimes` | `number` | `0` | Number of successful requests required |
102
- | `domains` | `string[]` | `[]` | Alternative domains for script resources |
103
- | `manifestDomains` | `string[]` | `[]` | Alternative domains for manifest files |
104
- | `addQuery` | `boolean \| function` | `false` | Add query parameters for cache busting |
105
- | `fetchOptions` | `RequestInit` | `{}` | Additional fetch options |
106
- | `onRetry` | `function` | `undefined` | Callback when retry occurs |
107
- | `onSuccess` | `function` | `undefined` | Callback when request succeeds |
108
- | `onError` | `function` | `undefined` | Callback when all retries fail |
96
+ | Option | Type | Default | Description |
97
+ | ----------------- | --------------------- | ----------- | ---------------------------------------- |
98
+ | `retryTimes` | `number` | `3` | Number of retry attempts |
99
+ | `retryDelay` | `number` | `1000` | Delay between retries in milliseconds |
100
+ | `successTimes` | `number` | `0` | Number of successful requests required |
101
+ | `domains` | `string[]` | `[]` | Alternative domains for script resources |
102
+ | `manifestDomains` | `string[]` | `[]` | Alternative domains for manifest files |
103
+ | `addQuery` | `boolean \| function` | `false` | Add query parameters for cache busting |
104
+ | `fetchOptions` | `RequestInit` | `{}` | Additional fetch options |
105
+ | `onRetry` | `function` | `undefined` | Callback when retry occurs |
106
+ | `onSuccess` | `function` | `undefined` | Callback when request succeeds |
107
+ | `onError` | `function` | `undefined` | Callback when all retries fail |
109
108
 
110
109
  ### addQuery Function
111
110
 
@@ -114,7 +113,7 @@ addQuery: ({ times, originalQuery }) => {
114
113
  // Add retry count and timestamp for cache busting
115
114
  const separator = originalQuery ? '&' : '?';
116
115
  return `${originalQuery}${separator}retry=${times}&t=${Date.now()}`;
117
- }
116
+ };
118
117
  ```
119
118
 
120
119
  ### Callback Functions
@@ -144,15 +143,8 @@ onError: ({ domains, url, tagName }) => {
144
143
  RetryPlugin({
145
144
  retryTimes: 5,
146
145
  retryDelay: (attempt) => Math.pow(2, attempt) * 1000, // Exponential backoff
147
- domains: [
148
- 'https://cdn1.example.com',
149
- 'https://cdn2.example.com',
150
- 'https://cdn3.example.com',
151
- ],
152
- manifestDomains: [
153
- 'https://api1.example.com',
154
- 'https://api2.example.com',
155
- ],
146
+ domains: ['https://cdn1.example.com', 'https://cdn2.example.com', 'https://cdn3.example.com'],
147
+ manifestDomains: ['https://api1.example.com', 'https://api2.example.com'],
156
148
  addQuery: ({ times, originalQuery }) => {
157
149
  const params = new URLSearchParams(originalQuery);
158
150
  params.set('retry', times.toString());
@@ -171,7 +163,7 @@ RetryPlugin({
171
163
  console.error(`❌ Failed to load ${url} after all retries`);
172
164
  console.error(`❌ Tried all domains: ${domains?.join(', ')}`);
173
165
  },
174
- })
166
+ });
175
167
  ```
176
168
 
177
169
  ### Error Handling with Fallback
@@ -184,7 +176,7 @@ RetryPlugin({
184
176
  onError: ({ url, domains }) => {
185
177
  // Log error for monitoring
186
178
  console.error('Module loading failed:', { url, domains });
187
-
179
+
188
180
  // Send error to monitoring service
189
181
  if (window.gtag) {
190
182
  window.gtag('event', 'module_load_error', {
@@ -193,7 +185,7 @@ RetryPlugin({
193
185
  value: domains?.length || 0,
194
186
  });
195
187
  }
196
-
188
+
197
189
  // Show user-friendly error message
198
190
  const errorElement = document.createElement('div');
199
191
  errorElement.className = 'module-load-error';
@@ -206,7 +198,7 @@ RetryPlugin({
206
198
  `;
207
199
  document.body.appendChild(errorElement);
208
200
  },
209
- })
201
+ });
210
202
  ```
211
203
 
212
204
  ### Production Configuration
@@ -215,15 +207,8 @@ RetryPlugin({
215
207
  RetryPlugin({
216
208
  retryTimes: 3,
217
209
  retryDelay: 1000,
218
- domains: [
219
- 'https://cdn1.prod.example.com',
220
- 'https://cdn2.prod.example.com',
221
- 'https://cdn3.prod.example.com',
222
- ],
223
- manifestDomains: [
224
- 'https://api1.prod.example.com',
225
- 'https://api2.prod.example.com',
226
- ],
210
+ domains: ['https://cdn1.prod.example.com', 'https://cdn2.prod.example.com', 'https://cdn3.prod.example.com'],
211
+ manifestDomains: ['https://api1.prod.example.com', 'https://api2.prod.example.com'],
227
212
  addQuery: ({ times, originalQuery }) => {
228
213
  const params = new URLSearchParams(originalQuery);
229
214
  params.set('retry', times.toString());
@@ -251,13 +236,10 @@ RetryPlugin({
251
236
  onError: ({ url, domains }) => {
252
237
  // Send error to monitoring service
253
238
  if (window.errorReporting) {
254
- window.errorReporting.captureException(
255
- new Error(`Module loading failed: ${url}`),
256
- { extra: { domains, url } }
257
- );
239
+ window.errorReporting.captureException(new Error(`Module loading failed: ${url}`), { extra: { domains, url } });
258
240
  }
259
241
  },
260
- })
242
+ });
261
243
  ```
262
244
 
263
245
  ## How It Works
@@ -318,9 +300,11 @@ RetryPlugin({
318
300
  },
319
301
  script: {
320
302
  url: 'http://localhost:2001/static/js/async/src_App_tsx.js',
321
- customCreateScript: (url, attrs) => { /* ... */ },
322
- }
323
- })
303
+ customCreateScript: (url, attrs) => {
304
+ /* ... */
305
+ },
306
+ },
307
+ });
324
308
 
325
309
  // ✅ New way
326
310
  RetryPlugin({
@@ -329,7 +313,7 @@ RetryPlugin({
329
313
  domains: ['http://localhost:2001'],
330
314
  manifestDomains: ['http://localhost:2001'],
331
315
  addQuery: ({ times, originalQuery }) => `${originalQuery}&retry=${times}`,
332
- })
316
+ });
333
317
  ```
334
318
 
335
319
  ## Contributing
@@ -344,4 +328,4 @@ Contributions are welcome! Please read our [contributing guidelines](https://git
344
328
 
345
329
  - [Module Federation Documentation](https://module-federation.io/)
346
330
  - [Module Federation Runtime](https://www.npmjs.com/package/@module-federation/runtime)
347
- - [Module Federation Enhanced](https://www.npmjs.com/package/@module-federation/enhanced)
331
+ - [Module Federation Enhanced](https://www.npmjs.com/package/@module-federation/enhanced)