@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.
Files changed (52) hide show
  1. package/dist/cjs/cli/alias.js +1 -1
  2. package/dist/cjs/cli/index.js +3 -1
  3. package/dist/cjs/cli/is/project.js +1 -1
  4. package/dist/cjs/cli/monorepo.js +3 -2
  5. package/dist/cjs/cli/path.js +2 -2
  6. package/dist/cjs/cli/port.js +2 -1
  7. package/dist/cjs/cli/prettyInstructions.js +2 -2
  8. package/dist/cjs/cli/require.js +4 -1
  9. package/dist/cjs/cli/route.js +23 -2
  10. package/dist/cjs/cli/runtimeExports.js +3 -3
  11. package/dist/cjs/cli/version.js +32 -0
  12. package/dist/compiled/better-ajv-errors/index.js +1 -1
  13. package/dist/compiled/recursive-readdir/index.d.ts +21 -0
  14. package/dist/compiled/recursive-readdir/index.js +1 -0
  15. package/dist/compiled/recursive-readdir/license +21 -0
  16. package/dist/compiled/recursive-readdir/package.json +1 -0
  17. package/dist/compiled/webpack-dev-middleware/index.js +7 -0
  18. package/dist/compiled/webpack-dev-middleware/license +20 -0
  19. package/dist/compiled/webpack-dev-middleware/package.json +1 -0
  20. package/dist/compiled/webpack-dev-middleware/types/index.d.ts +262 -0
  21. package/dist/esm/cli/alias.js +1 -1
  22. package/dist/esm/cli/get/data.js +1 -1
  23. package/dist/esm/cli/index.js +1 -0
  24. package/dist/esm/cli/is/project.js +1 -1
  25. package/dist/esm/cli/monorepo.js +3 -2
  26. package/dist/esm/cli/path.js +2 -2
  27. package/dist/esm/cli/port.js +4 -3
  28. package/dist/esm/cli/prettyInstructions.js +2 -2
  29. package/dist/esm/cli/require.js +5 -2
  30. package/dist/esm/cli/route.js +21 -1
  31. package/dist/esm/cli/runtimeExports.js +3 -3
  32. package/dist/esm/cli/version.js +8 -0
  33. package/dist/esm-node/cli/alias.js +1 -1
  34. package/dist/esm-node/cli/get/data.js +1 -1
  35. package/dist/esm-node/cli/index.js +1 -0
  36. package/dist/esm-node/cli/is/project.js +1 -1
  37. package/dist/esm-node/cli/monorepo.js +3 -2
  38. package/dist/esm-node/cli/path.js +2 -2
  39. package/dist/esm-node/cli/port.js +2 -1
  40. package/dist/esm-node/cli/prettyInstructions.js +2 -2
  41. package/dist/esm-node/cli/require.js +4 -1
  42. package/dist/esm-node/cli/route.js +21 -1
  43. package/dist/esm-node/cli/runtimeExports.js +3 -3
  44. package/dist/esm-node/cli/version.js +8 -0
  45. package/dist/types/cli/babel.d.ts +1 -1
  46. package/dist/types/cli/constants.d.ts +1 -1
  47. package/dist/types/cli/get/data.d.ts +1 -1
  48. package/dist/types/cli/index.d.ts +1 -0
  49. package/dist/types/cli/port.d.ts +1 -1
  50. package/dist/types/cli/route.d.ts +1 -0
  51. package/dist/types/cli/version.d.ts +1 -0
  52. package/package.json +4 -4
@@ -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;
@@ -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");
@@ -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
- appDirectory = import_path.default.dirname(appDirectory);
68
+ monorepoRoot = import_path.default.dirname(appDirectory);
68
69
  }
69
- return inMonorepo ? appDirectory : void 0;
70
+ return inMonorepo ? monorepoRoot : void 0;
70
71
  };
71
72
  const getMonorepoPackages = (root) => {
72
73
  let packages = [];
@@ -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);
@@ -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 (port, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
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();
@@ -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
- requiredModule = await import(path);
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;
@@ -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
- statement = (0, import_path2.normalizeOutputPath)(statement);
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(statement)) {
57
- import_compiled.fs.appendFileSync(entryExportFile, `${statement}
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
+ });