@modern-js/plugin-data-loader 2.0.0-canary.3 → 2.0.0-canary.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/js/modern/cli/create-request.js +2 -1
- package/dist/js/modern/common/constants.js +4 -0
- package/dist/js/modern/server/index.js +1 -1
- package/dist/js/node/cli/create-request.js +2 -1
- package/dist/js/node/common/constants.js +27 -0
- package/dist/js/node/server/index.js +2 -2
- package/dist/js/treeshaking/cli/create-request.js +2 -1
- package/dist/js/treeshaking/common/constants.js +2 -0
- package/dist/js/treeshaking/server/index.js +1 -1
- package/dist/types/common/constants.d.ts +1 -0
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
20
20
|
};
|
|
21
21
|
import { compile } from "path-to-regexp";
|
|
22
22
|
import { redirect } from "react-router-dom";
|
|
23
|
+
import { LOADER_SEARCH_PARAM } from "../common/constants";
|
|
23
24
|
const getRequestUrl = ({
|
|
24
25
|
params,
|
|
25
26
|
request,
|
|
@@ -31,7 +32,7 @@ const getRequestUrl = ({
|
|
|
31
32
|
});
|
|
32
33
|
const newPathName = toPath(params);
|
|
33
34
|
url.pathname = newPathName;
|
|
34
|
-
url.searchParams.append(
|
|
35
|
+
url.searchParams.append(LOADER_SEARCH_PARAM, routeId);
|
|
35
36
|
return url;
|
|
36
37
|
};
|
|
37
38
|
const handleRedirectResponse = (res) => {
|
|
@@ -47,8 +47,8 @@ import {
|
|
|
47
47
|
matchRoutes
|
|
48
48
|
} from "react-router-dom";
|
|
49
49
|
import { LOADER_ROUTES_DIR, MAIN_ENTRY_NAME } from "@modern-js/utils";
|
|
50
|
+
import { LOADER_SEARCH_PARAM } from "../common/constants";
|
|
50
51
|
installGlobals();
|
|
51
|
-
const LOADER_SEARCH_PARAM = "_loader";
|
|
52
52
|
const redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
53
53
|
function isRedirectResponse(response) {
|
|
54
54
|
return redirectStatusCodes.has(response.status);
|
|
@@ -43,6 +43,7 @@ __export(create_request_exports, {
|
|
|
43
43
|
module.exports = __toCommonJS(create_request_exports);
|
|
44
44
|
var import_path_to_regexp = require("path-to-regexp");
|
|
45
45
|
var import_react_router_dom = require("react-router-dom");
|
|
46
|
+
var import_constants = require("../common/constants");
|
|
46
47
|
const getRequestUrl = ({
|
|
47
48
|
params,
|
|
48
49
|
request,
|
|
@@ -54,7 +55,7 @@ const getRequestUrl = ({
|
|
|
54
55
|
});
|
|
55
56
|
const newPathName = toPath(params);
|
|
56
57
|
url.pathname = newPathName;
|
|
57
|
-
url.searchParams.append(
|
|
58
|
+
url.searchParams.append(import_constants.LOADER_SEARCH_PARAM, routeId);
|
|
58
59
|
return url;
|
|
59
60
|
};
|
|
60
61
|
const handleRedirectResponse = (res) => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
LOADER_SEARCH_PARAM: () => LOADER_SEARCH_PARAM
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(constants_exports);
|
|
23
|
+
const LOADER_SEARCH_PARAM = "_ssrDirect";
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
LOADER_SEARCH_PARAM
|
|
27
|
+
});
|
|
@@ -71,8 +71,8 @@ var import_path = __toESM(require("path"));
|
|
|
71
71
|
var import_node = require("@remix-run/node");
|
|
72
72
|
var import_react_router_dom = require("react-router-dom");
|
|
73
73
|
var import_utils = require("@modern-js/utils");
|
|
74
|
+
var import_constants = require("../common/constants");
|
|
74
75
|
(0, import_node.installGlobals)();
|
|
75
|
-
const LOADER_SEARCH_PARAM = "_loader";
|
|
76
76
|
const redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
77
77
|
function isRedirectResponse(response) {
|
|
78
78
|
return redirectStatusCodes.has(response.status);
|
|
@@ -174,7 +174,7 @@ const handleRequest = (_0) => __async(void 0, [_0], function* ({
|
|
|
174
174
|
distDir
|
|
175
175
|
}) {
|
|
176
176
|
const { method, query } = context;
|
|
177
|
-
const routeId = query[LOADER_SEARCH_PARAM];
|
|
177
|
+
const routeId = query[import_constants.LOADER_SEARCH_PARAM];
|
|
178
178
|
if (!routeId || method.toLowerCase() !== "get") {
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
@@ -124,6 +124,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
124
124
|
};
|
|
125
125
|
import { compile } from "path-to-regexp";
|
|
126
126
|
import { redirect } from "react-router-dom";
|
|
127
|
+
import { LOADER_SEARCH_PARAM } from "../common/constants";
|
|
127
128
|
var getRequestUrl = function(param) {
|
|
128
129
|
var params = param.params, request = param.request, routeId = param.routeId;
|
|
129
130
|
var url = new URL(request.url);
|
|
@@ -132,7 +133,7 @@ var getRequestUrl = function(param) {
|
|
|
132
133
|
});
|
|
133
134
|
var newPathName = toPath(params);
|
|
134
135
|
url.pathname = newPathName;
|
|
135
|
-
url.searchParams.append(
|
|
136
|
+
url.searchParams.append(LOADER_SEARCH_PARAM, routeId);
|
|
136
137
|
return url;
|
|
137
138
|
};
|
|
138
139
|
var handleRedirectResponse = function(res) {
|
|
@@ -224,8 +224,8 @@ import path from "path";
|
|
|
224
224
|
import { installGlobals, writeReadableStreamToWritable, Response as NodeResponse } from "@remix-run/node";
|
|
225
225
|
import { matchRoutes } from "react-router-dom";
|
|
226
226
|
import { LOADER_ROUTES_DIR, MAIN_ENTRY_NAME } from "@modern-js/utils";
|
|
227
|
+
import { LOADER_SEARCH_PARAM } from "../common/constants";
|
|
227
228
|
installGlobals();
|
|
228
|
-
var LOADER_SEARCH_PARAM = "_loader";
|
|
229
229
|
var redirectStatusCodes = /* @__PURE__ */ new Set([
|
|
230
230
|
301,
|
|
231
231
|
302,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LOADER_SEARCH_PARAM = "_ssrDirect";
|