@modern-js/utils 2.4.1-beta.0 → 2.5.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/FileSizeReporter.d.ts +5 -5
  3. package/dist/FileSizeReporter.js +143 -136
  4. package/dist/alias.d.ts +16 -14
  5. package/dist/alias.js +94 -54
  6. package/dist/analyzeProject.d.ts +1 -1
  7. package/dist/analyzeProject.js +58 -33
  8. package/dist/applyOptionsChain.d.ts +1 -1
  9. package/dist/applyOptionsChain.js +55 -27
  10. package/dist/chainId.d.ts +256 -184
  11. package/dist/chainId.js +132 -187
  12. package/dist/clearConsole.d.ts +1 -1
  13. package/dist/clearConsole.js +29 -7
  14. package/dist/commands.d.ts +1 -1
  15. package/dist/commands.js +33 -10
  16. package/dist/compatRequire.d.ts +3 -3
  17. package/dist/compatRequire.js +74 -38
  18. package/dist/compiled.d.ts +2 -1
  19. package/dist/compiled.js +137 -72
  20. package/dist/constants.d.ts +127 -105
  21. package/dist/constants.js +298 -281
  22. package/dist/debug.d.ts +1 -1
  23. package/dist/debug.js +28 -11
  24. package/dist/emptyDir.d.ts +1 -1
  25. package/dist/emptyDir.js +51 -9
  26. package/dist/ensureAbsolutePath.d.ts +1 -1
  27. package/dist/ensureAbsolutePath.js +33 -14
  28. package/dist/ensureArray.d.ts +1 -1
  29. package/dist/ensureArray.js +30 -8
  30. package/dist/findExists.d.ts +1 -1
  31. package/dist/findExists.js +37 -17
  32. package/dist/format.d.ts +3 -3
  33. package/dist/format.js +93 -81
  34. package/dist/generateMetaTags.d.ts +4 -4
  35. package/dist/generateMetaTags.js +56 -43
  36. package/dist/getBrowserslist.d.ts +1 -1
  37. package/dist/getBrowserslist.js +31 -7
  38. package/dist/getCoreJsVersion.d.ts +1 -1
  39. package/dist/getCoreJsVersion.js +39 -35
  40. package/dist/getEntryOptions.d.ts +1 -1
  41. package/dist/getEntryOptions.js +51 -24
  42. package/dist/getPackageManager.d.ts +1 -1
  43. package/dist/getPackageManager.js +75 -28
  44. package/dist/getPort.d.ts +7 -4
  45. package/dist/getPort.js +104 -58
  46. package/dist/getServerConfig.d.ts +1 -1
  47. package/dist/getServerConfig.js +61 -32
  48. package/dist/import.d.ts +2 -2
  49. package/dist/import.js +31 -8
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.js +61 -59
  52. package/dist/is/index.d.ts +5 -1
  53. package/dist/is/index.js +81 -94
  54. package/dist/is/node-env.d.ts +1 -1
  55. package/dist/is/node-env.js +39 -17
  56. package/dist/is/platform.d.ts +1 -1
  57. package/dist/is/platform.js +30 -10
  58. package/dist/is/type.d.ts +1 -1
  59. package/dist/is/type.js +48 -22
  60. package/dist/logger.d.ts +51 -51
  61. package/dist/logger.js +127 -95
  62. package/dist/monorepo.d.ts +3 -3
  63. package/dist/monorepo.js +117 -74
  64. package/dist/nestedRoutes.d.ts +9 -0
  65. package/dist/nestedRoutes.js +144 -0
  66. package/dist/nodeEnv.d.ts +1 -1
  67. package/dist/nodeEnv.js +72 -25
  68. package/dist/path.d.ts +3 -1
  69. package/dist/path.js +76 -59
  70. package/dist/pathSerializer.d.ts +7 -7
  71. package/dist/pathSerializer.js +65 -43
  72. package/dist/plugin.d.ts +1 -1
  73. package/dist/plugin.js +45 -26
  74. package/dist/prettyInstructions.d.ts +4 -4
  75. package/dist/prettyInstructions.js +107 -65
  76. package/dist/printBuildError.d.ts +1 -1
  77. package/dist/printBuildError.js +54 -40
  78. package/dist/react.d.ts +1 -1
  79. package/dist/react.js +57 -21
  80. package/dist/readTsConfig.d.ts +1 -1
  81. package/dist/readTsConfig.js +38 -12
  82. package/dist/remix-router.d.ts +1 -0
  83. package/dist/remix-router.js +17 -0
  84. package/dist/removeSlash.d.ts +1 -1
  85. package/dist/removeSlash.js +33 -9
  86. package/dist/routes.d.ts +1 -1
  87. package/dist/routes.js +49 -22
  88. package/dist/runtimeExports.d.ts +3 -3
  89. package/dist/runtimeExports.js +59 -39
  90. package/dist/serialize.d.ts +1 -0
  91. package/dist/serialize.js +36 -0
  92. package/dist/ssr.d.ts +2 -1
  93. package/dist/ssr.js +30 -7
  94. package/dist/storage.d.ts +3 -3
  95. package/dist/storage.js +65 -59
  96. package/dist/test-utils.d.ts +1 -1
  97. package/dist/test-utils.js +30 -24
  98. package/dist/tryResolve.d.ts +2 -1
  99. package/dist/tryResolve.js +45 -33
  100. package/dist/types.d.ts +1 -1
  101. package/dist/types.js +15 -2
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +83 -24
  104. package/dist/wait.d.ts +1 -1
  105. package/dist/wait.js +28 -6
  106. package/dist/watch.d.ts +5 -5
  107. package/dist/watch.js +82 -55
  108. package/package.json +31 -9
@@ -1,38 +1,42 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
24
18
  };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getCoreJsVersion = void 0;
27
- const fs = __importStar(require("../compiled/fs-extra"));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var getCoreJsVersion_exports = {};
25
+ __export(getCoreJsVersion_exports, {
26
+ getCoreJsVersion: () => getCoreJsVersion
27
+ });
28
+ module.exports = __toCommonJS(getCoreJsVersion_exports);
29
+ var fs = __toESM(require("../compiled/fs-extra"));
28
30
  const getCoreJsVersion = (corejsPkgPath) => {
29
- try {
30
- const { version } = fs.readJSONSync(corejsPkgPath);
31
- const [major, minor] = version.split('.');
32
- return `${major}.${minor}`;
33
- }
34
- catch (err) {
35
- return '3';
36
- }
31
+ try {
32
+ const { version } = fs.readJSONSync(corejsPkgPath);
33
+ const [major, minor] = version.split(".");
34
+ return `${major}.${minor}`;
35
+ } catch (err) {
36
+ return "3";
37
+ }
37
38
  };
38
- exports.getCoreJsVersion = getCoreJsVersion;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ getCoreJsVersion
42
+ });
@@ -1 +1 @@
1
- export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string) => T | undefined;
1
+ export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string) => T | undefined;
@@ -1,27 +1,54 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEntryOptions = void 0;
4
- const is_1 = require("./is");
5
- const constants_1 = require("./constants");
6
- const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
7
- if (optionsByEntries) {
8
- let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
9
- // compatible with main entry using packageName as the key
10
- if (optionsByEntry === undefined &&
11
- name === constants_1.MAIN_ENTRY_NAME &&
12
- packageName) {
13
- optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
14
- }
15
- // eslint-disable-next-line no-nested-ternary
16
- return optionsByEntry !== undefined
17
- ? (0, is_1.isPlainObject)(optionsByEntry) && (0, is_1.isPlainObject)(baseOptions)
18
- ? { ...baseOptions, ...optionsByEntry }
19
- : optionsByEntry
20
- : baseOptions;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
21
16
  }
22
- else {
23
- return baseOptions;
17
+ return a;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var getEntryOptions_exports = {};
33
+ __export(getEntryOptions_exports, {
34
+ getEntryOptions: () => getEntryOptions
35
+ });
36
+ module.exports = __toCommonJS(getEntryOptions_exports);
37
+ var import_is = require("./is");
38
+ var import_constants = require("./constants");
39
+ const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
40
+ if (optionsByEntries) {
41
+ let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
42
+ if (optionsByEntry === void 0 && name === import_constants.MAIN_ENTRY_NAME && packageName) {
43
+ optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
24
44
  }
45
+ return optionsByEntry !== void 0 ? (0, import_is.isPlainObject)(optionsByEntry) && (0, import_is.isPlainObject)(baseOptions) ? __spreadValues(__spreadValues({}, baseOptions), optionsByEntry) : optionsByEntry : baseOptions;
46
+ } else {
47
+ return baseOptions;
48
+ }
25
49
  };
26
- exports.getEntryOptions = getEntryOptions;
27
- const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : undefined;
50
+ const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : void 0;
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ getEntryOptions
54
+ });
@@ -1 +1 @@
1
- export declare function getPackageManager(cwd?: string): Promise<"npm" | "yarn" | "pnpm">;
1
+ export declare function getPackageManager(cwd?: string): Promise<"npm" | "yarn" | "pnpm">;
@@ -1,36 +1,83 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPackageManager = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const path_1 = __importDefault(require("path"));
9
- const compiled_1 = require("./compiled");
10
- const nodeEnv_1 = require("./nodeEnv");
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var __async = (__this, __arguments, generator) => {
25
+ return new Promise((resolve, reject) => {
26
+ var fulfilled = (value) => {
27
+ try {
28
+ step(generator.next(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var rejected = (value) => {
34
+ try {
35
+ step(generator.throw(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
+ step((generator = generator.apply(__this, __arguments)).next());
42
+ });
43
+ };
44
+ var getPackageManager_exports = {};
45
+ __export(getPackageManager_exports, {
46
+ getPackageManager: () => getPackageManager
47
+ });
48
+ module.exports = __toCommonJS(getPackageManager_exports);
49
+ var import_os = __toESM(require("os"));
50
+ var import_path = __toESM(require("path"));
51
+ var import_compiled = require("./compiled");
52
+ var import_nodeEnv = require("./nodeEnv");
11
53
  const MAX_TIMES = 5;
12
- async function getPackageManager(cwd = process.cwd()) {
54
+ function getPackageManager() {
55
+ return __async(this, arguments, function* (cwd = process.cwd()) {
13
56
  let appDirectory = cwd;
14
57
  let times = 0;
15
- while (os_1.default.homedir() !== appDirectory && times < MAX_TIMES) {
16
- times++;
17
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
18
- return 'pnpm';
19
- }
20
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
21
- return 'yarn';
22
- }
23
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'package-lock.json'))) {
24
- return 'npm';
25
- }
26
- appDirectory = path_1.default.join(appDirectory, '..');
58
+ while (import_os.default.homedir() !== appDirectory && times < MAX_TIMES) {
59
+ times++;
60
+ if (import_compiled.fs.existsSync(import_path.default.resolve(appDirectory, "pnpm-lock.yaml"))) {
61
+ return "pnpm";
62
+ }
63
+ if (import_compiled.fs.existsSync(import_path.default.resolve(appDirectory, "yarn.lock"))) {
64
+ return "yarn";
65
+ }
66
+ if (import_compiled.fs.existsSync(import_path.default.resolve(appDirectory, "package-lock.json"))) {
67
+ return "npm";
68
+ }
69
+ appDirectory = import_path.default.join(appDirectory, "..");
27
70
  }
28
- if (await (0, nodeEnv_1.canUsePnpm)()) {
29
- return 'pnpm';
71
+ if (yield (0, import_nodeEnv.canUsePnpm)()) {
72
+ return "pnpm";
30
73
  }
31
- if (await (0, nodeEnv_1.canUseYarn)()) {
32
- return 'yarn';
74
+ if (yield (0, import_nodeEnv.canUseYarn)()) {
75
+ return "yarn";
33
76
  }
34
- return 'npm';
77
+ return "npm";
78
+ });
35
79
  }
36
- exports.getPackageManager = getPackageManager;
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ getPackageManager
83
+ });
package/dist/getPort.d.ts CHANGED
@@ -5,7 +5,10 @@
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, }?: {
9
- tryLimits?: number | undefined;
10
- strictPort?: boolean | undefined;
11
- }) => Promise<number>;
8
+ export declare const getPort: (port: string | number, {
9
+ tryLimits,
10
+ strictPort
11
+ }?: {
12
+ tryLimits?: number | undefined;
13
+ strictPort?: boolean | undefined;
14
+ }) => Promise<number>;
package/dist/getPort.js CHANGED
@@ -1,62 +1,108 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
4
10
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPort = void 0;
7
- const net_1 = __importDefault(require("net"));
8
- const compiled_1 = require("./compiled");
9
- const logger_1 = require("./logger");
10
- /**
11
- * Get available free port.
12
- * @param port - Current port want to use.
13
- * @param tryLimits - Maximum number of retries.
14
- * @param strictPort - Whether to throw an error when the port is occupied.
15
- * @returns Available port number.
16
- */
17
- /* eslint-disable no-param-reassign, @typescript-eslint/no-loop-func */
18
- const getPort = async (port, { tryLimits = 20, strictPort = false, } = {}) => {
19
- if (typeof port === 'string') {
20
- port = parseInt(port, 10);
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var __async = (__this, __arguments, generator) => {
25
+ return new Promise((resolve, reject) => {
26
+ var fulfilled = (value) => {
27
+ try {
28
+ step(generator.next(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var rejected = (value) => {
34
+ try {
35
+ step(generator.throw(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
+ step((generator = generator.apply(__this, __arguments)).next());
42
+ });
43
+ };
44
+ var getPort_exports = {};
45
+ __export(getPort_exports, {
46
+ getPort: () => getPort
47
+ });
48
+ module.exports = __toCommonJS(getPort_exports);
49
+ var import_net = __toESM(require("net"));
50
+ var import_compiled = require("./compiled");
51
+ var import_logger = require("./logger");
52
+ const getPort = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (port, {
53
+ tryLimits = 20,
54
+ strictPort = false
55
+ } = {}) {
56
+ if (typeof port === "string") {
57
+ port = parseInt(port, 10);
58
+ }
59
+ if (strictPort) {
60
+ tryLimits = 1;
61
+ }
62
+ const original = port;
63
+ let found = false;
64
+ let attempts = 0;
65
+ while (!found && attempts <= tryLimits) {
66
+ try {
67
+ yield new Promise((resolve, reject) => {
68
+ const server = import_net.default.createServer();
69
+ server.unref();
70
+ server.on("error", reject);
71
+ server.listen(
72
+ {
73
+ port,
74
+ host: "0.0.0.0"
75
+ },
76
+ () => {
77
+ found = true;
78
+ server.close(resolve);
79
+ }
80
+ );
81
+ });
82
+ } catch (e) {
83
+ if (e.code !== "EADDRINUSE") {
84
+ throw e;
85
+ }
86
+ port++;
87
+ attempts++;
21
88
  }
89
+ }
90
+ if (port !== original) {
22
91
  if (strictPort) {
23
- tryLimits = 1;
24
- }
25
- const original = port;
26
- let found = false;
27
- let attempts = 0;
28
- while (!found && attempts <= tryLimits) {
29
- try {
30
- await new Promise((resolve, reject) => {
31
- const server = net_1.default.createServer();
32
- server.unref();
33
- server.on('error', reject);
34
- server.listen({
35
- port,
36
- host: '0.0.0.0',
37
- }, () => {
38
- found = true;
39
- server.close(resolve);
40
- });
41
- });
42
- }
43
- catch (e) {
44
- if (e.code !== 'EADDRINUSE') {
45
- throw e;
46
- }
47
- port++;
48
- attempts++;
49
- }
92
+ throw new Error(
93
+ `Port "${original}" is occupied, please choose another one.`
94
+ );
95
+ } else {
96
+ import_logger.logger.info(
97
+ `Something is already running on port ${original}. ${import_compiled.chalk.yellow(
98
+ `Use port ${port} instead.`
99
+ )}`
100
+ );
50
101
  }
51
- if (port !== original) {
52
- if (strictPort) {
53
- throw new Error(`Port "${original}" is occupied, please choose another one.`);
54
- }
55
- else {
56
- logger_1.logger.info(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`);
57
- }
58
- }
59
- return port;
60
- };
61
- exports.getPort = getPort;
62
- /* eslint-enable no-param-reassign, @typescript-eslint/no-loop-func */
102
+ }
103
+ return port;
104
+ });
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ getPort
108
+ });
@@ -1 +1 @@
1
- export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
1
+ export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
@@ -1,34 +1,63 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
24
18
  };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getServerConfig = void 0;
27
- const path = __importStar(require("path"));
28
- const constants_1 = require("./constants");
29
- const findExists_1 = require("./findExists");
30
- const getServerConfig = async (appDirectory, configFile) => {
31
- const configFilePath = (0, findExists_1.findExists)(constants_1.CONFIG_FILE_EXTENSIONS.map(extension => path.resolve(appDirectory, `${configFile}${extension}`)));
32
- return configFilePath;
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var __async = (__this, __arguments, generator) => {
25
+ return new Promise((resolve, reject) => {
26
+ var fulfilled = (value) => {
27
+ try {
28
+ step(generator.next(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var rejected = (value) => {
34
+ try {
35
+ step(generator.throw(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
+ step((generator = generator.apply(__this, __arguments)).next());
42
+ });
33
43
  };
34
- exports.getServerConfig = getServerConfig;
44
+ var getServerConfig_exports = {};
45
+ __export(getServerConfig_exports, {
46
+ getServerConfig: () => getServerConfig
47
+ });
48
+ module.exports = __toCommonJS(getServerConfig_exports);
49
+ var path = __toESM(require("path"));
50
+ var import_constants = require("./constants");
51
+ var import_findExists = require("./findExists");
52
+ const getServerConfig = (appDirectory, configFile) => __async(void 0, null, function* () {
53
+ const configFilePath = (0, import_findExists.findExists)(
54
+ import_constants.CONFIG_FILE_EXTENSIONS.map(
55
+ (extension) => path.resolve(appDirectory, `${configFile}${extension}`)
56
+ )
57
+ );
58
+ return configFilePath;
59
+ });
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ getServerConfig
63
+ });
package/dist/import.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare const lazy: (moduleName: string, requireFn: (id: string) => unknown) => any;
2
2
  export { lazy as lazyImport };
3
3
  export declare const Import: {
4
- lazy: (moduleName: string, requireFn: (id: string) => unknown) => any;
5
- };
4
+ lazy: (moduleName: string, requireFn: (id: string) => unknown) => any;
5
+ };
package/dist/import.js CHANGED
@@ -1,10 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Import = exports.lazyImport = void 0;
4
- // cover: https://rushstack.io/pages/api/node-core-library.import.lazy/
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 import_exports = {};
19
+ __export(import_exports, {
20
+ Import: () => Import,
21
+ lazyImport: () => lazy
22
+ });
23
+ module.exports = __toCommonJS(import_exports);
5
24
  const lazy = (moduleName, requireFn) => {
6
- const importLazyLocal = require('../compiled/import-lazy')(requireFn);
7
- return importLazyLocal(moduleName);
25
+ const importLazyLocal = require("../compiled/import-lazy")(requireFn);
26
+ return importLazyLocal(moduleName);
8
27
  };
9
- exports.lazyImport = lazy;
10
- exports.Import = { lazy };
28
+ const Import = { lazy };
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ Import,
32
+ lazyImport
33
+ });
package/dist/index.d.ts CHANGED
@@ -42,3 +42,5 @@ export * from './routes';
42
42
  export * from './test-utils';
43
43
  export * from './getCoreJsVersion';
44
44
  export * from './react';
45
+ export * from './nestedRoutes';
46
+ export * from './serialize';