Skip to content

Commit e44d7fa

Browse files
authored
fix: parameter url for fetch retry options should not be necessary (#3175)
1 parent 7baf337 commit e44d7fa

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.changeset/little-insects-lick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@module-federation/retry-plugin': patch
3+
'website-new': patch
4+
---
5+
6+
fix: parameter url for fetch options should not be necessary

apps/website-new/docs/en/plugin/plugins/retry-plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ init({
184184
// the retry resource url
185185
url: 'http://localhost:2001/-mf-manifest.json',
186186
// after all retried failed, set a fallback function to guarantee a fallback resource
187-
fallback: () => 'http://localhost:2002/mf-manifest.json',
187+
fallback: (url: string) => 'http://localhost:2002/mf-manifest.json',
188188
},
189189
script: {
190190
// the retry times

apps/website-new/docs/zh/plugin/plugins/retry-plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ type FetchWithRetryOptions = {
9595
options?: RequestInit;
9696
retryTimes?: number;
9797
retryDelay?: number;
98-
fallback?: () => string;
98+
fallback?: (url: string) => string;
9999
}
100100

101101
type ScriptWithRetryOptions = {

packages/retry-plugin/src/fetch-retry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { FetchWithRetryOptions } from './types';
1+
import type { RequiredFetchWithRetryOptions } from './types';
22
import {
33
defaultRetries,
44
defaultRetryDelay,
@@ -12,7 +12,7 @@ async function fetchWithRetry({
1212
retryTimes = defaultRetries, // retry times
1313
retryDelay = defaultRetryDelay, // retry delay
1414
fallback, // fallback url
15-
}: FetchWithRetryOptions) {
15+
}: RequiredFetchWithRetryOptions) {
1616
try {
1717
const response = await fetch(url, options);
1818

packages/retry-plugin/src/types.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface FetchWithRetryOptions {
2-
url: string;
2+
url?: string;
33
options?: RequestInit;
44
retryTimes?: number;
55
retryDelay?: number;
@@ -19,3 +19,8 @@ export type RetryPluginParams = {
1919
fetch?: FetchWithRetryOptions;
2020
script?: ScriptWithRetryOptions;
2121
};
22+
23+
export type RequiredFetchWithRetryOptions = Required<
24+
Pick<FetchWithRetryOptions, 'url'>
25+
> &
26+
Omit<FetchWithRetryOptions, 'url'>;

0 commit comments

Comments
 (0)