@modern-js/plugin-data-loader 2.7.0 → 2.8.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/CHANGELOG.md +11 -0
- package/README.md +2 -2
- package/dist/cjs/runtime/index.js +15 -0
- package/dist/esm/runtime/index.js +15 -0
- package/dist/esm-node/runtime/index.js +15 -0
- package/package.json +9 -9
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-sta
|
|
|
19
19
|
|
|
20
20
|
## Contributing
|
|
21
21
|
|
|
22
|
-
Please read the [Contributing Guide](https://github.com/
|
|
22
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
|
23
23
|
|
|
24
24
|
## License
|
|
25
25
|
|
|
26
|
-
Modern.js is [MIT licensed](https://github.com/
|
|
26
|
+
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
|
@@ -37,6 +37,20 @@ function isRedirectResponse(status) {
|
|
|
37
37
|
function isResponse(value) {
|
|
38
38
|
return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
|
|
39
39
|
}
|
|
40
|
+
function sortByUrlPath(entries) {
|
|
41
|
+
entries.sort(function(a, b) {
|
|
42
|
+
const length1 = a.urlPath.length;
|
|
43
|
+
const length2 = b.urlPath.length;
|
|
44
|
+
if (length1 < length2) {
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
if (length1 > length2) {
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
return 0;
|
|
51
|
+
});
|
|
52
|
+
return entries;
|
|
53
|
+
}
|
|
40
54
|
function convertModernRedirectResponse(headers, basename) {
|
|
41
55
|
const newHeaders = new Headers(headers);
|
|
42
56
|
let redirectUrl = headers.get("Location");
|
|
@@ -89,6 +103,7 @@ const sendLoaderResponse = async (res, nodeResponse) => {
|
|
|
89
103
|
}
|
|
90
104
|
};
|
|
91
105
|
const matchEntry = (pathname, entries) => {
|
|
106
|
+
sortByUrlPath(entries);
|
|
92
107
|
return entries.find((entry) => pathname.startsWith(entry.urlPath));
|
|
93
108
|
};
|
|
94
109
|
const handleRequest = async ({
|
|
@@ -195,6 +195,20 @@ function isRedirectResponse(status) {
|
|
|
195
195
|
function isResponse(value) {
|
|
196
196
|
return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
|
|
197
197
|
}
|
|
198
|
+
function sortByUrlPath(entries) {
|
|
199
|
+
entries.sort(function(a, b) {
|
|
200
|
+
var length1 = a.urlPath.length;
|
|
201
|
+
var length2 = b.urlPath.length;
|
|
202
|
+
if (length1 < length2) {
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
if (length1 > length2) {
|
|
206
|
+
return -1;
|
|
207
|
+
}
|
|
208
|
+
return 0;
|
|
209
|
+
});
|
|
210
|
+
return entries;
|
|
211
|
+
}
|
|
198
212
|
function convertModernRedirectResponse(headers, basename) {
|
|
199
213
|
var newHeaders = new Headers(headers);
|
|
200
214
|
var redirectUrl = headers.get("Location");
|
|
@@ -325,6 +339,7 @@ var sendLoaderResponse = function() {
|
|
|
325
339
|
};
|
|
326
340
|
}();
|
|
327
341
|
var matchEntry = function(pathname, entries) {
|
|
342
|
+
sortByUrlPath(entries);
|
|
328
343
|
return entries.find(function(entry) {
|
|
329
344
|
return pathname.startsWith(entry.urlPath);
|
|
330
345
|
});
|
|
@@ -20,6 +20,20 @@ function isRedirectResponse(status) {
|
|
|
20
20
|
function isResponse(value) {
|
|
21
21
|
return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
|
|
22
22
|
}
|
|
23
|
+
function sortByUrlPath(entries) {
|
|
24
|
+
entries.sort(function(a, b) {
|
|
25
|
+
const length1 = a.urlPath.length;
|
|
26
|
+
const length2 = b.urlPath.length;
|
|
27
|
+
if (length1 < length2) {
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
if (length1 > length2) {
|
|
31
|
+
return -1;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
});
|
|
35
|
+
return entries;
|
|
36
|
+
}
|
|
23
37
|
function convertModernRedirectResponse(headers, basename) {
|
|
24
38
|
const newHeaders = new Headers(headers);
|
|
25
39
|
let redirectUrl = headers.get("Location");
|
|
@@ -72,6 +86,7 @@ const sendLoaderResponse = async (res, nodeResponse) => {
|
|
|
72
86
|
}
|
|
73
87
|
};
|
|
74
88
|
const matchEntry = (pathname, entries) => {
|
|
89
|
+
sortByUrlPath(entries);
|
|
75
90
|
return entries.find((entry) => pathname.startsWith(entry.urlPath));
|
|
76
91
|
};
|
|
77
92
|
const handleRequest = async ({
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "@modern-js/plugin-data-loader",
|
|
3
3
|
"description": "A Progressive React Framework for modern web development.",
|
|
4
4
|
"homepage": "https://modernjs.dev",
|
|
5
|
-
"bugs": "https://github.com/
|
|
6
|
-
"repository": "
|
|
5
|
+
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
|
+
"repository": "web-infra-dev/modern.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.8.0",
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=14.17.6"
|
|
17
17
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@remix-run/node": "^1.12.0",
|
|
53
53
|
"path-to-regexp": "^6.2.0",
|
|
54
54
|
"react-router-dom": "^6.8.1",
|
|
55
|
-
"@modern-js/utils": "2.
|
|
55
|
+
"@modern-js/utils": "2.8.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/babel__core": "^7.1.15",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"typescript": "^4",
|
|
68
68
|
"webpack": "^5.75.0",
|
|
69
69
|
"webpack-chain": "^6.5.1",
|
|
70
|
-
"@modern-js/core": "2.
|
|
71
|
-
"@modern-js/server-core": "2.
|
|
72
|
-
"@modern-js/types": "2.
|
|
73
|
-
"@scripts/
|
|
74
|
-
"@scripts/
|
|
70
|
+
"@modern-js/core": "2.8.0",
|
|
71
|
+
"@modern-js/server-core": "2.8.0",
|
|
72
|
+
"@modern-js/types": "2.8.0",
|
|
73
|
+
"@scripts/jest-config": "2.8.0",
|
|
74
|
+
"@scripts/build": "2.8.0"
|
|
75
75
|
},
|
|
76
76
|
"sideEffects": false,
|
|
77
77
|
"publishConfig": {
|