@module-federation/retry-plugin 0.21.4 → 0.21.5
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/dist/CHANGELOG.md +8 -0
- package/dist/esm/index.js +13 -1
- package/dist/index.js +13 -1
- package/dist/package.json +1 -1
- package/package.json +3 -3
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @module-federation/retry-plugin
|
|
2
2
|
|
|
3
|
+
## 0.21.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 443d491: fix(retry-plugin): add autoParseResponse to auto-select JSON or text based on file extension
|
|
8
|
+
- Updated dependencies [94d8868]
|
|
9
|
+
- @module-federation/sdk@0.21.5
|
|
10
|
+
|
|
3
11
|
## 0.21.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/esm/index.js
CHANGED
|
@@ -132,6 +132,18 @@ function combineUrlDomainWithPathQuery(domainUrl, pathQueryUrl) {
|
|
|
132
132
|
__name(combineUrlDomainWithPathQuery, "combineUrlDomainWithPathQuery");
|
|
133
133
|
|
|
134
134
|
// packages/retry-plugin/src/fetch-retry.ts
|
|
135
|
+
function autoParseResponse(url, response) {
|
|
136
|
+
try {
|
|
137
|
+
const parsed = new URL(url);
|
|
138
|
+
if (parsed.pathname.endsWith(".js") || parsed.pathname.endsWith(".cjs") || parsed.pathname.endsWith(".mjs")) {
|
|
139
|
+
return response.text();
|
|
140
|
+
}
|
|
141
|
+
return response.json();
|
|
142
|
+
} catch (error) {
|
|
143
|
+
return response.json();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
__name(autoParseResponse, "autoParseResponse");
|
|
135
147
|
async function fetchRetry(params, lastRequestUrl, originalTotal) {
|
|
136
148
|
const {
|
|
137
149
|
url,
|
|
@@ -173,7 +185,7 @@ async function fetchRetry(params, lastRequestUrl, originalTotal) {
|
|
|
173
185
|
if (!response.ok) {
|
|
174
186
|
throw new Error(`${PLUGIN_IDENTIFIER}: Request failed: ${response.status} ${response.statusText || ""} | url: ${requestUrl}`);
|
|
175
187
|
}
|
|
176
|
-
await responseClone
|
|
188
|
+
await autoParseResponse(requestUrl, responseClone).catch((error) => {
|
|
177
189
|
throw new Error(`${PLUGIN_IDENTIFIER}: JSON parse failed: ${error?.message || String(error)} | url: ${requestUrl}`);
|
|
178
190
|
});
|
|
179
191
|
if (!isFirstAttempt) {
|
package/dist/index.js
CHANGED
|
@@ -160,6 +160,18 @@ function combineUrlDomainWithPathQuery(domainUrl, pathQueryUrl) {
|
|
|
160
160
|
__name(combineUrlDomainWithPathQuery, "combineUrlDomainWithPathQuery");
|
|
161
161
|
|
|
162
162
|
// packages/retry-plugin/src/fetch-retry.ts
|
|
163
|
+
function autoParseResponse(url, response) {
|
|
164
|
+
try {
|
|
165
|
+
const parsed = new URL(url);
|
|
166
|
+
if (parsed.pathname.endsWith(".js") || parsed.pathname.endsWith(".cjs") || parsed.pathname.endsWith(".mjs")) {
|
|
167
|
+
return response.text();
|
|
168
|
+
}
|
|
169
|
+
return response.json();
|
|
170
|
+
} catch (error) {
|
|
171
|
+
return response.json();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
__name(autoParseResponse, "autoParseResponse");
|
|
163
175
|
async function fetchRetry(params, lastRequestUrl, originalTotal) {
|
|
164
176
|
const {
|
|
165
177
|
url,
|
|
@@ -201,7 +213,7 @@ async function fetchRetry(params, lastRequestUrl, originalTotal) {
|
|
|
201
213
|
if (!response.ok) {
|
|
202
214
|
throw new Error(`${PLUGIN_IDENTIFIER}: Request failed: ${response.status} ${response.statusText || ""} | url: ${requestUrl}`);
|
|
203
215
|
}
|
|
204
|
-
await responseClone
|
|
216
|
+
await autoParseResponse(requestUrl, responseClone).catch((error) => {
|
|
205
217
|
throw new Error(`${PLUGIN_IDENTIFIER}: JSON parse failed: ${error?.message || String(error)} | url: ${requestUrl}`);
|
|
206
218
|
});
|
|
207
219
|
if (!isFirstAttempt) {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/retry-plugin",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.5",
|
|
4
4
|
"author": "danpeen <dapeen.feng@gmail.com>",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@module-federation/runtime": "0.21.
|
|
36
|
+
"@module-federation/runtime": "0.21.5"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@module-federation/sdk": "0.21.
|
|
39
|
+
"@module-federation/sdk": "0.21.5"
|
|
40
40
|
}
|
|
41
41
|
}
|