@modern-js/utils 2.56.2 → 2.57.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/index.js +3 -1
- package/dist/cjs/cli/route.js +65 -0
- package/dist/esm/cli/index.js +1 -0
- package/dist/esm/cli/route.js +44 -0
- package/dist/esm-node/cli/index.js +1 -0
- package/dist/esm-node/cli/route.js +40 -0
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/route.d.ts +3 -0
- package/package.json +4 -4
package/dist/cjs/cli/index.js
CHANGED
@@ -36,6 +36,7 @@ __reExport(cli_exports, require("./runtimeExports"), module.exports);
|
|
36
36
|
__reExport(cli_exports, require("./watch"), module.exports);
|
37
37
|
__reExport(cli_exports, require("./config"), module.exports);
|
38
38
|
__reExport(cli_exports, require("./action"), module.exports);
|
39
|
+
__reExport(cli_exports, require("./route"), module.exports);
|
39
40
|
// Annotate the CommonJS export names for ESM import in node:
|
40
41
|
0 && (module.exports = {
|
41
42
|
...require("./constants"),
|
@@ -58,5 +59,6 @@ __reExport(cli_exports, require("./action"), module.exports);
|
|
58
59
|
...require("./runtimeExports"),
|
59
60
|
...require("./watch"),
|
60
61
|
...require("./config"),
|
61
|
-
...require("./action")
|
62
|
+
...require("./action"),
|
63
|
+
...require("./route")
|
62
64
|
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var route_exports = {};
|
20
|
+
__export(route_exports, {
|
21
|
+
filterRoutesForServer: () => filterRoutesForServer,
|
22
|
+
filterRoutesLoader: () => filterRoutesLoader
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(route_exports);
|
25
|
+
var import_compiled = require("../compiled");
|
26
|
+
const { cloneDeep } = import_compiled.lodash;
|
27
|
+
function filterRoutesForServer(routes) {
|
28
|
+
const clonedRoutes = cloneDeep(routes);
|
29
|
+
const newRoutes = clonedRoutes.map((route) => {
|
30
|
+
if (route.type !== "nested") {
|
31
|
+
return route;
|
32
|
+
}
|
33
|
+
if (route.children && route.children.length > 0) {
|
34
|
+
route.children = filterRoutesForServer(route.children);
|
35
|
+
}
|
36
|
+
if (route.inValidSSRRoute) {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
return route;
|
40
|
+
}).filter((route) => route !== null);
|
41
|
+
return newRoutes;
|
42
|
+
}
|
43
|
+
function filterRoutesLoader(routes) {
|
44
|
+
const clonedRoutes = cloneDeep(routes);
|
45
|
+
const newRoutes = clonedRoutes.map((route) => {
|
46
|
+
if (route.type !== "nested") {
|
47
|
+
return route;
|
48
|
+
}
|
49
|
+
if (route.children && route.children.length > 0) {
|
50
|
+
route.children = filterRoutesLoader(route.children);
|
51
|
+
}
|
52
|
+
if (route.inValidSSRRoute) {
|
53
|
+
delete route.loader;
|
54
|
+
delete route.data;
|
55
|
+
delete route.action;
|
56
|
+
}
|
57
|
+
return route;
|
58
|
+
}).filter((route) => route !== null);
|
59
|
+
return newRoutes;
|
60
|
+
}
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
62
|
+
0 && (module.exports = {
|
63
|
+
filterRoutesForServer,
|
64
|
+
filterRoutesLoader
|
65
|
+
});
|
package/dist/esm/cli/index.js
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
import { lodash } from "../compiled";
|
2
|
+
var cloneDeep = lodash.cloneDeep;
|
3
|
+
function filterRoutesForServer(routes) {
|
4
|
+
var clonedRoutes = cloneDeep(routes);
|
5
|
+
var newRoutes = clonedRoutes.map(function(route) {
|
6
|
+
if (route.type !== "nested") {
|
7
|
+
return route;
|
8
|
+
}
|
9
|
+
if (route.children && route.children.length > 0) {
|
10
|
+
route.children = filterRoutesForServer(route.children);
|
11
|
+
}
|
12
|
+
if (route.inValidSSRRoute) {
|
13
|
+
return null;
|
14
|
+
}
|
15
|
+
return route;
|
16
|
+
}).filter(function(route) {
|
17
|
+
return route !== null;
|
18
|
+
});
|
19
|
+
return newRoutes;
|
20
|
+
}
|
21
|
+
function filterRoutesLoader(routes) {
|
22
|
+
var clonedRoutes = cloneDeep(routes);
|
23
|
+
var newRoutes = clonedRoutes.map(function(route) {
|
24
|
+
if (route.type !== "nested") {
|
25
|
+
return route;
|
26
|
+
}
|
27
|
+
if (route.children && route.children.length > 0) {
|
28
|
+
route.children = filterRoutesLoader(route.children);
|
29
|
+
}
|
30
|
+
if (route.inValidSSRRoute) {
|
31
|
+
delete route.loader;
|
32
|
+
delete route.data;
|
33
|
+
delete route.action;
|
34
|
+
}
|
35
|
+
return route;
|
36
|
+
}).filter(function(route) {
|
37
|
+
return route !== null;
|
38
|
+
});
|
39
|
+
return newRoutes;
|
40
|
+
}
|
41
|
+
export {
|
42
|
+
filterRoutesForServer,
|
43
|
+
filterRoutesLoader
|
44
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { lodash } from "../compiled";
|
2
|
+
const { cloneDeep } = lodash;
|
3
|
+
function filterRoutesForServer(routes) {
|
4
|
+
const clonedRoutes = cloneDeep(routes);
|
5
|
+
const newRoutes = clonedRoutes.map((route) => {
|
6
|
+
if (route.type !== "nested") {
|
7
|
+
return route;
|
8
|
+
}
|
9
|
+
if (route.children && route.children.length > 0) {
|
10
|
+
route.children = filterRoutesForServer(route.children);
|
11
|
+
}
|
12
|
+
if (route.inValidSSRRoute) {
|
13
|
+
return null;
|
14
|
+
}
|
15
|
+
return route;
|
16
|
+
}).filter((route) => route !== null);
|
17
|
+
return newRoutes;
|
18
|
+
}
|
19
|
+
function filterRoutesLoader(routes) {
|
20
|
+
const clonedRoutes = cloneDeep(routes);
|
21
|
+
const newRoutes = clonedRoutes.map((route) => {
|
22
|
+
if (route.type !== "nested") {
|
23
|
+
return route;
|
24
|
+
}
|
25
|
+
if (route.children && route.children.length > 0) {
|
26
|
+
route.children = filterRoutesLoader(route.children);
|
27
|
+
}
|
28
|
+
if (route.inValidSSRRoute) {
|
29
|
+
delete route.loader;
|
30
|
+
delete route.data;
|
31
|
+
delete route.action;
|
32
|
+
}
|
33
|
+
return route;
|
34
|
+
}).filter((route) => route !== null);
|
35
|
+
return newRoutes;
|
36
|
+
}
|
37
|
+
export {
|
38
|
+
filterRoutesForServer,
|
39
|
+
filterRoutesLoader
|
40
|
+
};
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import type { NestedRouteForCli, PageRoute } from '@modern-js/types';
|
2
|
+
export declare function filterRoutesForServer(routes: (NestedRouteForCli | PageRoute)[]): (NestedRouteForCli | PageRoute)[];
|
3
|
+
export declare function filterRoutesLoader(routes: (NestedRouteForCli | PageRoute)[]): (NestedRouteForCli | PageRoute)[];
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.57.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -162,9 +162,9 @@
|
|
162
162
|
"jest": "^29",
|
163
163
|
"typescript": "^5",
|
164
164
|
"webpack": "^5.93.0",
|
165
|
-
"@modern-js/types": "2.
|
166
|
-
"@scripts/jest-config": "2.
|
167
|
-
"@scripts/build": "2.
|
165
|
+
"@modern-js/types": "2.57.0",
|
166
|
+
"@scripts/jest-config": "2.57.0",
|
167
|
+
"@scripts/build": "2.57.0"
|
168
168
|
},
|
169
169
|
"sideEffects": false,
|
170
170
|
"scripts": {
|