@modern-js/utils 2.58.1 → 2.58.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  });
@@ -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 = [];
@@ -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
  }
@@ -19,21 +19,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var require_exports = {};
20
20
  __export(require_exports, {
21
21
  cleanRequireCache: () => cleanRequireCache,
22
- compatRequire: () => compatRequire,
22
+ compatibleRequire: () => compatibleRequire,
23
23
  deleteRequireCache: () => deleteRequireCache,
24
24
  dynamicImport: () => dynamicImport,
25
25
  requireExistModule: () => requireExistModule,
26
26
  tryResolve: () => tryResolve
27
27
  });
28
28
  module.exports = __toCommonJS(require_exports);
29
+ var import_node_path = require("node:path");
29
30
  var import_fs = require("./fs");
30
- const compatRequire = (filePath, interop = true) => {
31
- const mod = require(filePath);
32
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
33
- return rtnESMDefault ? mod.default : mod;
34
- };
31
+ var import_node_url = require("node:url");
32
+ async function compatibleRequire(path, interop = true) {
33
+ if (path.endsWith(".json")) {
34
+ return require(path);
35
+ }
36
+ let requiredModule;
37
+ try {
38
+ requiredModule = require(path);
39
+ } catch (err) {
40
+ if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
41
+ const modulePath = (0, import_node_path.isAbsolute)(path) ? (0, import_node_url.pathToFileURL)(path).href : path;
42
+ requiredModule = await import(modulePath);
43
+ return interop ? requiredModule.default : requiredModule;
44
+ } else {
45
+ throw err;
46
+ }
47
+ }
48
+ return interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule;
49
+ }
35
50
  const dynamicImport = new Function("modulePath", "return import(modulePath)");
36
- const requireExistModule = (filename, opt) => {
51
+ const requireExistModule = async (filename, opt) => {
37
52
  const final = {
38
53
  extensions: [
39
54
  ".ts",
@@ -46,7 +61,7 @@ const requireExistModule = (filename, opt) => {
46
61
  if (!exist) {
47
62
  return null;
48
63
  }
49
- return compatRequire(exist, final.interop);
64
+ return compatibleRequire(exist, final.interop);
50
65
  };
51
66
  const cleanRequireCache = (filelist) => {
52
67
  filelist.forEach((filepath) => {
@@ -81,7 +96,7 @@ const tryResolve = (name, resolvePath) => {
81
96
  // Annotate the CommonJS export names for ESM import in node:
82
97
  0 && (module.exports = {
83
98
  cleanRequireCache,
84
- compatRequire,
99
+ compatibleRequire,
85
100
  deleteRequireCache,
86
101
  dynamicImport,
87
102
  requireExistModule,
@@ -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
+ });
@@ -56,10 +56,7 @@ const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post")
56
56
  sortedPoint.push(getPluginByAny(zep));
57
57
  allLines = allLines.filter((l) => l[0] !== getPluginByAny(zep)[key]);
58
58
  const restPoints = plugins.filter((item) => !sortedPoint.find((sp) => sp[key] === item[key]));
59
- zeroEndPoints = restPoints.filter(
60
- // eslint-disable-next-line @typescript-eslint/no-loop-func
61
- (item) => !allLines.find((l) => l[1] === item[key])
62
- );
59
+ zeroEndPoints = restPoints.filter((item) => !allLines.find((l) => l[1] === item[key]));
63
60
  }
64
61
  if (allLines.length) {
65
62
  const restInRingPoints = {};
@@ -20,3 +20,4 @@ export * from "./watch";
20
20
  export * from "./config";
21
21
  export * from "./action";
22
22
  export * from "./route";
23
+ export * from "./version";
@@ -28,14 +28,15 @@ var isMonorepo = function(root) {
28
28
  var findMonorepoRoot = function(appDirectory) {
29
29
  var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
30
30
  var inMonorepo = false;
31
+ var monorepoRoot = appDirectory;
31
32
  for (var depth = 0; depth < maxDepth; depth++) {
32
33
  if (isMonorepo(appDirectory)) {
33
34
  inMonorepo = true;
34
35
  break;
35
36
  }
36
- appDirectory = path.dirname(appDirectory);
37
+ monorepoRoot = path.dirname(appDirectory);
37
38
  }
38
- return inMonorepo ? appDirectory : void 0;
39
+ return inMonorepo ? monorepoRoot : void 0;
39
40
  };
40
41
  var getMonorepoPackages = function(root) {
41
42
  var packages = [];
@@ -4,13 +4,14 @@ import net from "net";
4
4
  import { chalk } from "../compiled";
5
5
  import { logger } from "./logger";
6
6
  var getPort = function() {
7
- var _ref = _async_to_generator(function(port) {
8
- var _ref2, _ref_tryLimits, tryLimits, _ref_strictPort, strictPort, _ref_slient, slient, original, found, attempts, e;
7
+ var _ref = _async_to_generator(function(expectPort) {
8
+ var _ref2, _ref_tryLimits, tryLimits, _ref_strictPort, strictPort, _ref_slient, slient, port, original, found, attempts, e;
9
9
  var _arguments = arguments;
10
10
  return _ts_generator(this, function(_state) {
11
11
  switch (_state.label) {
12
12
  case 0:
13
13
  _ref2 = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, _ref_tryLimits = _ref2.tryLimits, tryLimits = _ref_tryLimits === void 0 ? 20 : _ref_tryLimits, _ref_strictPort = _ref2.strictPort, strictPort = _ref_strictPort === void 0 ? false : _ref_strictPort, _ref_slient = _ref2.slient, slient = _ref_slient === void 0 ? false : _ref_slient;
14
+ port = expectPort;
14
15
  if (typeof port === "string") {
15
16
  port = parseInt(port, 10);
16
17
  }
@@ -87,7 +88,7 @@ var getPort = function() {
87
88
  }
88
89
  });
89
90
  });
90
- return function getPort2(port) {
91
+ return function getPort2(expectPort) {
91
92
  return _ref.apply(this, arguments);
92
93
  };
93
94
  }();
@@ -1,28 +1,106 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
1
3
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
+ import { isAbsolute } from "node:path";
2
6
  import { findExists } from "./fs";
3
- var compatRequire = function(filePath) {
4
- var interop = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
5
- var mod = require(filePath);
6
- var rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
7
- return rtnESMDefault ? mod.default : mod;
8
- };
7
+ import { pathToFileURL } from "node:url";
8
+ function compatibleRequire(path) {
9
+ return _compatibleRequire.apply(this, arguments);
10
+ }
11
+ function _compatibleRequire() {
12
+ _compatibleRequire = _async_to_generator(function(path) {
13
+ var interop, requiredModule, err, modulePath;
14
+ var _arguments = arguments;
15
+ return _ts_generator(this, function(_state) {
16
+ switch (_state.label) {
17
+ case 0:
18
+ interop = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : true;
19
+ if (path.endsWith(".json")) {
20
+ return [
21
+ 2,
22
+ require(path)
23
+ ];
24
+ }
25
+ _state.label = 1;
26
+ case 1:
27
+ _state.trys.push([
28
+ 1,
29
+ 2,
30
+ ,
31
+ 6
32
+ ]);
33
+ requiredModule = require(path);
34
+ return [
35
+ 3,
36
+ 6
37
+ ];
38
+ case 2:
39
+ err = _state.sent();
40
+ if (!(err.code === "ERR_REQUIRE_ESM" || _instanceof(err, SyntaxError)))
41
+ return [
42
+ 3,
43
+ 4
44
+ ];
45
+ modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
46
+ return [
47
+ 4,
48
+ import(modulePath)
49
+ ];
50
+ case 3:
51
+ requiredModule = _state.sent();
52
+ return [
53
+ 2,
54
+ interop ? requiredModule.default : requiredModule
55
+ ];
56
+ case 4:
57
+ throw err;
58
+ case 5:
59
+ return [
60
+ 3,
61
+ 6
62
+ ];
63
+ case 6:
64
+ return [
65
+ 2,
66
+ interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule
67
+ ];
68
+ }
69
+ });
70
+ });
71
+ return _compatibleRequire.apply(this, arguments);
72
+ }
9
73
  var dynamicImport = new Function("modulePath", "return import(modulePath)");
10
- var requireExistModule = function(filename, opt) {
11
- var final = _object_spread({
12
- extensions: [
13
- ".ts",
14
- ".js"
15
- ],
16
- interop: true
17
- }, opt);
18
- var exist = findExists(final.extensions.map(function(ext) {
19
- return "".concat(filename).concat(ext);
20
- }));
21
- if (!exist) {
22
- return null;
23
- }
24
- return compatRequire(exist, final.interop);
25
- };
74
+ var requireExistModule = function() {
75
+ var _ref = _async_to_generator(function(filename, opt) {
76
+ var final, exist;
77
+ return _ts_generator(this, function(_state) {
78
+ final = _object_spread({
79
+ extensions: [
80
+ ".ts",
81
+ ".js"
82
+ ],
83
+ interop: true
84
+ }, opt);
85
+ exist = findExists(final.extensions.map(function(ext) {
86
+ return "".concat(filename).concat(ext);
87
+ }));
88
+ if (!exist) {
89
+ return [
90
+ 2,
91
+ null
92
+ ];
93
+ }
94
+ return [
95
+ 2,
96
+ compatibleRequire(exist, final.interop)
97
+ ];
98
+ });
99
+ });
100
+ return function requireExistModule2(filename, opt) {
101
+ return _ref.apply(this, arguments);
102
+ };
103
+ }();
26
104
  var cleanRequireCache = function(filelist) {
27
105
  filelist.forEach(function(filepath) {
28
106
  delete require.cache[filepath];
@@ -57,7 +135,7 @@ var tryResolve = function(name, resolvePath) {
57
135
  };
58
136
  export {
59
137
  cleanRequireCache,
60
- compatRequire,
138
+ compatibleRequire,
61
139
  deleteRequireCache,
62
140
  dynamicImport,
63
141
  requireExistModule,
@@ -22,11 +22,11 @@ var createRuntimeExportsUtils = memo(function() {
22
22
  var pwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "index";
23
23
  var entryExportFile = path.join(pwd, ".runtime-exports/".concat(namespace, ".js"));
24
24
  var addExport = function(statement) {
25
- statement = normalizeOutputPath(statement);
25
+ var statementStr = normalizeOutputPath(statement);
26
26
  try {
27
27
  fs.ensureFileSync(entryExportFile);
28
- if (!fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
29
- fs.appendFileSync(entryExportFile, "".concat(statement, "\n"));
28
+ if (!fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
29
+ fs.appendFileSync(entryExportFile, "".concat(statementStr, "\n"));
30
30
  }
31
31
  } catch (e) {
32
32
  }
@@ -0,0 +1,8 @@
1
+ function isVersionAtLeast1819() {
2
+ var nodeVersion = process.versions.node;
3
+ var versionArr = nodeVersion.split(".").map(Number);
4
+ return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
5
+ }
6
+ export {
7
+ isVersionAtLeast1819
8
+ };
@@ -10,14 +10,11 @@ var pluginDagSort = function(plugins) {
10
10
  return sp[key] === item[key];
11
11
  });
12
12
  });
13
- zeroEndPoints = restPoints.filter(
14
- // eslint-disable-next-line @typescript-eslint/no-loop-func
15
- function(item) {
16
- return !allLines.find(function(l) {
17
- return l[1] === item[key];
18
- });
19
- }
20
- );
13
+ zeroEndPoints = restPoints.filter(function(item) {
14
+ return !allLines.find(function(l) {
15
+ return l[1] === item[key];
16
+ });
17
+ });
21
18
  };
22
19
  var key = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "name", preKey = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "pre", postKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "post";
23
20
  var getPluginByAny = function getPluginByAny2(q) {
@@ -20,3 +20,4 @@ export * from "./watch";
20
20
  export * from "./config";
21
21
  export * from "./action";
22
22
  export * from "./route";
23
+ export * from "./version";
@@ -21,14 +21,15 @@ const isPnpmWorkspaces = (root) => fs.existsSync(path.join(root, WORKSPACE_FILES
21
21
  const isMonorepo = (root) => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
22
22
  const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
23
23
  let inMonorepo = false;
24
+ let monorepoRoot = appDirectory;
24
25
  for (let depth = 0; depth < maxDepth; depth++) {
25
26
  if (isMonorepo(appDirectory)) {
26
27
  inMonorepo = true;
27
28
  break;
28
29
  }
29
- appDirectory = path.dirname(appDirectory);
30
+ monorepoRoot = path.dirname(appDirectory);
30
31
  }
31
- return inMonorepo ? appDirectory : void 0;
32
+ return inMonorepo ? monorepoRoot : void 0;
32
33
  };
33
34
  const getMonorepoPackages = (root) => {
34
35
  let packages = [];
@@ -1,7 +1,8 @@
1
1
  import net from "net";
2
2
  import { chalk } from "../compiled";
3
3
  import { logger } from "./logger";
4
- const getPort = async (port, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
4
+ const getPort = async (expectPort, { tryLimits = 20, strictPort = false, slient = false } = {}) => {
5
+ let port = expectPort;
5
6
  if (typeof port === "string") {
6
7
  port = parseInt(port, 10);
7
8
  }
@@ -1,11 +1,26 @@
1
+ import { isAbsolute } from "node:path";
1
2
  import { findExists } from "./fs";
2
- const compatRequire = (filePath, interop = true) => {
3
- const mod = require(filePath);
4
- const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
5
- return rtnESMDefault ? mod.default : mod;
6
- };
3
+ import { pathToFileURL } from "node:url";
4
+ async function compatibleRequire(path, interop = true) {
5
+ if (path.endsWith(".json")) {
6
+ return require(path);
7
+ }
8
+ let requiredModule;
9
+ try {
10
+ requiredModule = require(path);
11
+ } catch (err) {
12
+ if (err.code === "ERR_REQUIRE_ESM" || err instanceof SyntaxError) {
13
+ const modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
14
+ requiredModule = await import(modulePath);
15
+ return interop ? requiredModule.default : requiredModule;
16
+ } else {
17
+ throw err;
18
+ }
19
+ }
20
+ return interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule;
21
+ }
7
22
  const dynamicImport = new Function("modulePath", "return import(modulePath)");
8
- const requireExistModule = (filename, opt) => {
23
+ const requireExistModule = async (filename, opt) => {
9
24
  const final = {
10
25
  extensions: [
11
26
  ".ts",
@@ -18,7 +33,7 @@ const requireExistModule = (filename, opt) => {
18
33
  if (!exist) {
19
34
  return null;
20
35
  }
21
- return compatRequire(exist, final.interop);
36
+ return compatibleRequire(exist, final.interop);
22
37
  };
23
38
  const cleanRequireCache = (filelist) => {
24
39
  filelist.forEach((filepath) => {
@@ -52,7 +67,7 @@ const tryResolve = (name, resolvePath) => {
52
67
  };
53
68
  export {
54
69
  cleanRequireCache,
55
- compatRequire,
70
+ compatibleRequire,
56
71
  deleteRequireCache,
57
72
  dynamicImport,
58
73
  requireExistModule,
@@ -17,11 +17,11 @@ const memo = (fn) => {
17
17
  const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
18
18
  const entryExportFile = path.join(pwd, `.runtime-exports/${namespace}.js`);
19
19
  const addExport = (statement) => {
20
- statement = normalizeOutputPath(statement);
20
+ const statementStr = normalizeOutputPath(statement);
21
21
  try {
22
22
  fs.ensureFileSync(entryExportFile);
23
- if (!fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
24
- fs.appendFileSync(entryExportFile, `${statement}
23
+ if (!fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
24
+ fs.appendFileSync(entryExportFile, `${statementStr}
25
25
  `);
26
26
  }
27
27
  } catch {
@@ -0,0 +1,8 @@
1
+ function isVersionAtLeast1819() {
2
+ const nodeVersion = process.versions.node;
3
+ const versionArr = nodeVersion.split(".").map(Number);
4
+ return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
5
+ }
6
+ export {
7
+ isVersionAtLeast1819
8
+ };
@@ -33,10 +33,7 @@ const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post")
33
33
  sortedPoint.push(getPluginByAny(zep));
34
34
  allLines = allLines.filter((l) => l[0] !== getPluginByAny(zep)[key]);
35
35
  const restPoints = plugins.filter((item) => !sortedPoint.find((sp) => sp[key] === item[key]));
36
- zeroEndPoints = restPoints.filter(
37
- // eslint-disable-next-line @typescript-eslint/no-loop-func
38
- (item) => !allLines.find((l) => l[1] === item[key])
39
- );
36
+ zeroEndPoints = restPoints.filter((item) => !allLines.find((l) => l[1] === item[key]));
40
37
  }
41
38
  if (allLines.length) {
42
39
  const restInRingPoints = {};
@@ -1,3 +1,3 @@
1
- import { BabelConfig, BabelConfigUtils, BabelTransformOptions } from '@modern-js/types';
1
+ import type { BabelConfig, BabelConfigUtils, BabelTransformOptions } from '@modern-js/types';
2
2
  export declare const getBabelUtils: (config: BabelTransformOptions) => BabelConfigUtils;
3
3
  export declare const applyUserBabelConfig: (defaultOptions: BabelTransformOptions, userBabelConfig?: BabelConfig | BabelConfig[], extraBabelUtils?: Partial<BabelConfigUtils>) => BabelTransformOptions;
@@ -1,4 +1,4 @@
1
- import { InternalPlugins } from '@modern-js/types';
1
+ import type { InternalPlugins } from '@modern-js/types';
2
2
  export { NESTED_ROUTE_SPEC_FILE, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_RENDER_FUNCTION_NAME, SERVER_PLUGIN_BFF, SERVER_PLUGIN_EXPRESS, SERVER_PLUGIN_KOA, SERVER_PLUGIN_SERVER, SERVER_PLUGIN_POLYFILL, } from '../universal/constants';
3
3
  export declare const JS_EXTENSIONS: string[];
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { InternalPlugins } from '@modern-js/types';
1
+ import type { InternalPlugins } from '@modern-js/types';
2
2
  export declare function getPackageManager(cwd?: string): Promise<"pnpm" | "npm" | "yarn">;
3
3
  export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
4
4
  export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
@@ -20,3 +20,4 @@ export * from './watch';
20
20
  export * from './config';
21
21
  export * from './action';
22
22
  export * from './route';
23
+ export * from './version';
@@ -5,7 +5,7 @@
5
5
  * @param strictPort - Whether to throw an error when the port is occupied.
6
6
  * @returns Available port number.
7
7
  */
8
- export declare const getPort: (port: string | number, { tryLimits, strictPort, slient, }?: {
8
+ export declare const getPort: (expectPort: string | number, { tryLimits, strictPort, slient, }?: {
9
9
  tryLimits?: number | undefined;
10
10
  strictPort?: boolean | undefined;
11
11
  slient?: boolean | undefined;
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Require function compatible with esm and cjs module.
3
- * @param filePath - File to required.
3
+ * @param path - File to required.
4
4
  * @returns module export object.
5
5
  */
6
- export declare const compatRequire: (filePath: string, interop?: boolean) => any;
6
+ export declare function compatibleRequire(path: string, interop?: boolean): Promise<any>;
7
7
  export declare const dynamicImport: Function;
8
8
  export declare const requireExistModule: (filename: string, opt?: {
9
9
  extensions?: string[];
10
10
  interop?: boolean;
11
- }) => any;
11
+ }) => Promise<any>;
12
12
  export declare const cleanRequireCache: (filelist: string[]) => void;
13
13
  export declare function deleteRequireCache(path: string): void;
14
14
  /**
@@ -0,0 +1 @@
1
+ export declare function isVersionAtLeast1819(): boolean;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.58.1",
18
+ "version": "2.58.2",
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.58.1",
166
- "@scripts/build": "2.58.1",
167
- "@scripts/jest-config": "2.58.1"
165
+ "@scripts/build": "2.58.2",
166
+ "@scripts/jest-config": "2.58.2",
167
+ "@modern-js/types": "2.58.2"
168
168
  },
169
169
  "sideEffects": false,
170
170
  "scripts": {