@modern-js/utils 2.58.2-alpha.0 → 2.58.3-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/alias.js +1 -1
- package/dist/cjs/cli/index.js +3 -1
- package/dist/cjs/cli/is/project.js +1 -1
- package/dist/cjs/cli/monorepo.js +3 -2
- package/dist/cjs/cli/path.js +2 -2
- package/dist/cjs/cli/port.js +2 -1
- package/dist/cjs/cli/prettyInstructions.js +2 -2
- package/dist/cjs/cli/require.js +4 -1
- package/dist/cjs/cli/route.js +23 -2
- package/dist/cjs/cli/runtimeExports.js +3 -3
- package/dist/cjs/cli/version.js +32 -0
- package/dist/compiled/better-ajv-errors/index.js +1 -1
- package/dist/compiled/recursive-readdir/index.d.ts +21 -0
- package/dist/compiled/recursive-readdir/index.js +1 -0
- package/dist/compiled/recursive-readdir/license +21 -0
- package/dist/compiled/recursive-readdir/package.json +1 -0
- package/dist/compiled/webpack-dev-middleware/index.js +7 -0
- package/dist/compiled/webpack-dev-middleware/license +20 -0
- package/dist/compiled/webpack-dev-middleware/package.json +1 -0
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +262 -0
- package/dist/esm/cli/alias.js +1 -1
- package/dist/esm/cli/get/data.js +1 -1
- package/dist/esm/cli/index.js +1 -0
- package/dist/esm/cli/is/project.js +1 -1
- package/dist/esm/cli/monorepo.js +3 -2
- package/dist/esm/cli/path.js +2 -2
- package/dist/esm/cli/port.js +4 -3
- package/dist/esm/cli/prettyInstructions.js +2 -2
- package/dist/esm/cli/require.js +5 -2
- package/dist/esm/cli/route.js +21 -1
- package/dist/esm/cli/runtimeExports.js +3 -3
- package/dist/esm/cli/version.js +8 -0
- package/dist/esm-node/cli/alias.js +1 -1
- package/dist/esm-node/cli/get/data.js +1 -1
- package/dist/esm-node/cli/index.js +1 -0
- package/dist/esm-node/cli/is/project.js +1 -1
- package/dist/esm-node/cli/monorepo.js +3 -2
- package/dist/esm-node/cli/path.js +2 -2
- package/dist/esm-node/cli/port.js +2 -1
- package/dist/esm-node/cli/prettyInstructions.js +2 -2
- package/dist/esm-node/cli/require.js +4 -1
- package/dist/esm-node/cli/route.js +21 -1
- package/dist/esm-node/cli/runtimeExports.js +3 -3
- package/dist/esm-node/cli/version.js +8 -0
- package/dist/types/cli/babel.d.ts +1 -1
- package/dist/types/cli/constants.d.ts +1 -1
- package/dist/types/cli/get/data.d.ts +1 -1
- package/dist/types/cli/index.d.ts +1 -0
- package/dist/types/cli/port.d.ts +1 -1
- package/dist/types/cli/route.d.ts +1 -0
- package/dist/types/cli/version.d.ts +1 -0
- package/package.json +4 -4
package/dist/cjs/cli/alias.js
CHANGED
@@ -35,8 +35,8 @@ __export(alias_exports, {
|
|
35
35
|
module.exports = __toCommonJS(alias_exports);
|
36
36
|
var import_fs = __toESM(require("fs"));
|
37
37
|
var import_path = __toESM(require("path"));
|
38
|
-
var import_get = require("./get");
|
39
38
|
var import_applyOptionsChain = require("./applyOptionsChain");
|
39
|
+
var import_get = require("./get");
|
40
40
|
const mergeAlias = (alias) => (0, import_applyOptionsChain.applyOptionsChain)({}, alias);
|
41
41
|
const getAliasConfig = (aliasOption, option) => {
|
42
42
|
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
package/dist/cjs/cli/index.js
CHANGED
@@ -37,6 +37,7 @@ __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
39
|
__reExport(cli_exports, require("./route"), module.exports);
|
40
|
+
__reExport(cli_exports, require("./version"), module.exports);
|
40
41
|
// Annotate the CommonJS export names for ESM import in node:
|
41
42
|
0 && (module.exports = {
|
42
43
|
...require("./constants"),
|
@@ -60,5 +61,6 @@ __reExport(cli_exports, require("./route"), module.exports);
|
|
60
61
|
...require("./watch"),
|
61
62
|
...require("./config"),
|
62
63
|
...require("./action"),
|
63
|
-
...require("./route")
|
64
|
+
...require("./route"),
|
65
|
+
...require("./version")
|
64
66
|
});
|
@@ -39,8 +39,8 @@ __export(project_exports, {
|
|
39
39
|
module.exports = __toCommonJS(project_exports);
|
40
40
|
var import_path = __toESM(require("path"));
|
41
41
|
var import_pkg_up = __toESM(require("../../../compiled/pkg-up"));
|
42
|
-
var import_commands = require("../commands");
|
43
42
|
var import_compiled = require("../../compiled");
|
43
|
+
var import_commands = require("../commands");
|
44
44
|
var import_common = require("../common");
|
45
45
|
var import_ensure = require("../ensure");
|
46
46
|
const debug = (0, import_common.createDebugger)("judge-depExists");
|
package/dist/cjs/cli/monorepo.js
CHANGED
@@ -59,14 +59,15 @@ const isPnpmWorkspaces = (root) => import_fs.default.existsSync(import_path.defa
|
|
59
59
|
const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
60
60
|
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
61
61
|
let inMonorepo = false;
|
62
|
+
let monorepoRoot = appDirectory;
|
62
63
|
for (let depth = 0; depth < maxDepth; depth++) {
|
63
64
|
if (isMonorepo(appDirectory)) {
|
64
65
|
inMonorepo = true;
|
65
66
|
break;
|
66
67
|
}
|
67
|
-
|
68
|
+
monorepoRoot = import_path.default.dirname(appDirectory);
|
68
69
|
}
|
69
|
-
return inMonorepo ?
|
70
|
+
return inMonorepo ? monorepoRoot : void 0;
|
70
71
|
};
|
71
72
|
const getMonorepoPackages = (root) => {
|
72
73
|
let packages = [];
|
package/dist/cjs/cli/path.js
CHANGED
@@ -41,9 +41,9 @@ __export(path_exports, {
|
|
41
41
|
splitPathString: () => splitPathString
|
42
42
|
});
|
43
43
|
module.exports = __toCommonJS(path_exports);
|
44
|
-
var import_path = __toESM(require("path"));
|
45
|
-
var import_os = __toESM(require("os"));
|
46
44
|
var import_fs = __toESM(require("fs"));
|
45
|
+
var import_os = __toESM(require("os"));
|
46
|
+
var import_path = __toESM(require("path"));
|
47
47
|
var import_compiled = require("../compiled");
|
48
48
|
const isPathString = (test) => import_path.default.posix.basename(test) !== test || import_path.default.win32.basename(test) !== test;
|
49
49
|
const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
|
package/dist/cjs/cli/port.js
CHANGED
@@ -34,7 +34,8 @@ module.exports = __toCommonJS(port_exports);
|
|
34
34
|
var import_net = __toESM(require("net"));
|
35
35
|
var import_compiled = require("../compiled");
|
36
36
|
var import_logger = require("./logger");
|
37
|
-
const getPort = async (
|
37
|
+
const getPort = async (expectPort, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
|
38
|
+
let port = expectPort;
|
38
39
|
if (typeof port === "string") {
|
39
40
|
port = parseInt(port, 10);
|
40
41
|
}
|
@@ -32,11 +32,11 @@ __export(prettyInstructions_exports, {
|
|
32
32
|
prettyInstructions: () => prettyInstructions
|
33
33
|
});
|
34
34
|
module.exports = __toCommonJS(prettyInstructions_exports);
|
35
|
-
var import_os = __toESM(require("os"));
|
36
35
|
var import_net = require("net");
|
36
|
+
var import_os = __toESM(require("os"));
|
37
37
|
var import_compiled = require("../compiled");
|
38
|
-
var import_is = require("./is");
|
39
38
|
var import_constants = require("./constants");
|
39
|
+
var import_is = require("./is");
|
40
40
|
const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
41
41
|
const getIpv4Interfaces = () => {
|
42
42
|
const interfaces = import_os.default.networkInterfaces();
|
package/dist/cjs/cli/require.js
CHANGED
@@ -26,6 +26,8 @@ __export(require_exports, {
|
|
26
26
|
tryResolve: () => tryResolve
|
27
27
|
});
|
28
28
|
module.exports = __toCommonJS(require_exports);
|
29
|
+
var import_node_path = require("node:path");
|
30
|
+
var import_node_url = require("node:url");
|
29
31
|
var import_fs = require("./fs");
|
30
32
|
async function compatibleRequire(path, interop = true) {
|
31
33
|
if (path.endsWith(".json")) {
|
@@ -36,7 +38,8 @@ async function compatibleRequire(path, interop = true) {
|
|
36
38
|
requiredModule = require(path);
|
37
39
|
} catch (err) {
|
38
40
|
if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
|
39
|
-
|
41
|
+
const modulePath = (0, import_node_path.isAbsolute)(path) ? (0, import_node_url.pathToFileURL)(path).href : path;
|
42
|
+
requiredModule = await import(modulePath);
|
40
43
|
return interop ? requiredModule.default : requiredModule;
|
41
44
|
} else {
|
42
45
|
throw err;
|
package/dist/cjs/cli/route.js
CHANGED
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
19
19
|
var route_exports = {};
|
20
20
|
__export(route_exports, {
|
21
21
|
filterRoutesForServer: () => filterRoutesForServer,
|
22
|
-
filterRoutesLoader: () => filterRoutesLoader
|
22
|
+
filterRoutesLoader: () => filterRoutesLoader,
|
23
|
+
markRoutes: () => markRoutes
|
23
24
|
});
|
24
25
|
module.exports = __toCommonJS(route_exports);
|
25
26
|
var import_compiled = require("../compiled");
|
@@ -58,8 +59,28 @@ function filterRoutesLoader(routes) {
|
|
58
59
|
}).filter((route) => route !== null);
|
59
60
|
return newRoutes;
|
60
61
|
}
|
62
|
+
function markRoutes(routes, routeIds) {
|
63
|
+
return routes.map((route) => {
|
64
|
+
if (route.type !== "nested") {
|
65
|
+
return route;
|
66
|
+
}
|
67
|
+
if (route.children && route.children.length > 0) {
|
68
|
+
route.children = markRoutes(route.children, routeIds);
|
69
|
+
}
|
70
|
+
if (route.children && route.children.length > 0) {
|
71
|
+
route.inValidSSRRoute = route.children.every((child) => {
|
72
|
+
var _child_inValidSSRRoute;
|
73
|
+
return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
|
74
|
+
});
|
75
|
+
} else if (route.id) {
|
76
|
+
route.inValidSSRRoute = !routeIds.includes(route.id);
|
77
|
+
}
|
78
|
+
return route;
|
79
|
+
});
|
80
|
+
}
|
61
81
|
// Annotate the CommonJS export names for ESM import in node:
|
62
82
|
0 && (module.exports = {
|
63
83
|
filterRoutesForServer,
|
64
|
-
filterRoutesLoader
|
84
|
+
filterRoutesLoader,
|
85
|
+
markRoutes
|
65
86
|
});
|
@@ -50,11 +50,11 @@ const memo = (fn) => {
|
|
50
50
|
const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
|
51
51
|
const entryExportFile = import_path.default.join(pwd, `.runtime-exports/${namespace}.js`);
|
52
52
|
const addExport = (statement) => {
|
53
|
-
|
53
|
+
const statementStr = (0, import_path2.normalizeOutputPath)(statement);
|
54
54
|
try {
|
55
55
|
import_compiled.fs.ensureFileSync(entryExportFile);
|
56
|
-
if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(
|
57
|
-
import_compiled.fs.appendFileSync(entryExportFile, `${
|
56
|
+
if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
|
57
|
+
import_compiled.fs.appendFileSync(entryExportFile, `${statementStr}
|
58
58
|
`);
|
59
59
|
}
|
60
60
|
} catch {
|
@@ -0,0 +1,32 @@
|
|
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 version_exports = {};
|
20
|
+
__export(version_exports, {
|
21
|
+
isVersionAtLeast1819: () => isVersionAtLeast1819
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(version_exports);
|
24
|
+
function isVersionAtLeast1819() {
|
25
|
+
const nodeVersion = process.versions.node;
|
26
|
+
const versionArr = nodeVersion.split(".").map(Number);
|
27
|
+
return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
|
28
|
+
}
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
30
|
+
0 && (module.exports = {
|
31
|
+
isVersionAtLeast1819
|
32
|
+
});
|