@modern-js/utils 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/FileSizeReporter.d.ts +5 -5
  3. package/dist/FileSizeReporter.js +143 -136
  4. package/dist/alias.d.ts +14 -12
  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 +131 -105
  21. package/dist/constants.js +298 -277
  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 +3 -3
  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 +1 -1
  51. package/dist/index.js +59 -59
  52. package/dist/is/index.d.ts +12 -1
  53. package/dist/is/index.js +83 -82
  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 +48 -48
  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/nodeEnv.d.ts +1 -1
  65. package/dist/nodeEnv.js +72 -25
  66. package/dist/path.d.ts +3 -1
  67. package/dist/path.js +76 -59
  68. package/dist/pathSerializer.d.ts +6 -6
  69. package/dist/pathSerializer.js +65 -43
  70. package/dist/plugin.d.ts +1 -1
  71. package/dist/plugin.js +45 -26
  72. package/dist/prettyInstructions.d.ts +4 -4
  73. package/dist/prettyInstructions.js +107 -65
  74. package/dist/printBuildError.d.ts +1 -1
  75. package/dist/printBuildError.js +54 -40
  76. package/dist/react.d.ts +1 -1
  77. package/dist/react.js +57 -21
  78. package/dist/readTsConfig.d.ts +1 -1
  79. package/dist/readTsConfig.js +38 -12
  80. package/dist/removeSlash.d.ts +1 -1
  81. package/dist/removeSlash.js +33 -9
  82. package/dist/routes.d.ts +1 -1
  83. package/dist/routes.js +49 -22
  84. package/dist/runtimeExports.d.ts +3 -3
  85. package/dist/runtimeExports.js +59 -39
  86. package/dist/ssr.d.ts +2 -1
  87. package/dist/ssr.js +30 -7
  88. package/dist/storage.d.ts +3 -3
  89. package/dist/storage.js +65 -59
  90. package/dist/test-utils.d.ts +1 -1
  91. package/dist/test-utils.js +30 -24
  92. package/dist/tryResolve.d.ts +2 -1
  93. package/dist/tryResolve.js +45 -33
  94. package/dist/types.d.ts +1 -1
  95. package/dist/types.js +15 -2
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +83 -24
  98. package/dist/wait.d.ts +1 -1
  99. package/dist/wait.js +28 -6
  100. package/dist/watch.d.ts +3 -3
  101. package/dist/watch.js +82 -55
  102. package/package.json +7 -8
@@ -1,72 +1,114 @@
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.prettyInstructions = exports.getAddressUrls = exports.getIpv4Interfaces = exports.isSingleEntry = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const compiled_1 = require("./compiled");
9
- const is_1 = require("./is");
10
- // TODO: remove hard code 'main'
11
- const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === 'main';
12
- exports.isSingleEntry = isSingleEntry;
13
- const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, '$1');
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 prettyInstructions_exports = {};
25
+ __export(prettyInstructions_exports, {
26
+ getAddressUrls: () => getAddressUrls,
27
+ getIpv4Interfaces: () => getIpv4Interfaces,
28
+ isSingleEntry: () => isSingleEntry,
29
+ prettyInstructions: () => prettyInstructions
30
+ });
31
+ module.exports = __toCommonJS(prettyInstructions_exports);
32
+ var import_os = __toESM(require("os"));
33
+ var import_compiled = require("./compiled");
34
+ var import_is = require("./is");
35
+ const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
36
+ const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
14
37
  const getIpv4Interfaces = () => {
15
- const interfaces = os_1.default.networkInterfaces();
16
- const ipv4Interfaces = [];
17
- Object.keys(interfaces).forEach(key => {
18
- interfaces[key].forEach(detail => {
19
- // 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
20
- const familyV4Value = typeof detail.family === 'string' ? 'IPv4' : 4;
21
- if (detail.family === familyV4Value) {
22
- ipv4Interfaces.push(detail);
23
- }
24
- });
38
+ const interfaces = import_os.default.networkInterfaces();
39
+ const ipv4Interfaces = [];
40
+ Object.keys(interfaces).forEach((key) => {
41
+ interfaces[key].forEach((detail) => {
42
+ const familyV4Value = typeof detail.family === "string" ? "IPv4" : 4;
43
+ if (detail.family === familyV4Value) {
44
+ ipv4Interfaces.push(detail);
45
+ }
25
46
  });
26
- return ipv4Interfaces;
47
+ });
48
+ return ipv4Interfaces;
27
49
  };
28
- exports.getIpv4Interfaces = getIpv4Interfaces;
29
- const getAddressUrls = (protocol = 'http', port) => {
30
- const ipv4Interfaces = (0, exports.getIpv4Interfaces)();
31
- return ipv4Interfaces.reduce((memo, detail) => {
32
- let type = 'Network: ';
33
- let url = `${protocol}://${detail.address}:${port}`;
34
- if (detail.address.includes(`localhost`) || detail.internal) {
35
- type = 'Local: ';
36
- url = `${protocol}://localhost:${port}`;
37
- }
38
- memo.push({ type, url });
39
- return memo;
40
- }, []);
50
+ const getAddressUrls = (protocol = "http", port) => {
51
+ const ipv4Interfaces = getIpv4Interfaces();
52
+ return ipv4Interfaces.reduce(
53
+ (memo, detail) => {
54
+ let type = "Network: ";
55
+ let url = `${protocol}://${detail.address}:${port}`;
56
+ if (detail.address.includes(`localhost`) || detail.internal) {
57
+ type = "Local: ";
58
+ url = `${protocol}://localhost:${port}`;
59
+ }
60
+ memo.push({ type, url });
61
+ return memo;
62
+ },
63
+ []
64
+ );
41
65
  };
42
- exports.getAddressUrls = getAddressUrls;
43
66
  const prettyInstructions = (appContext, config) => {
44
- const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
45
- const urls = (0, exports.getAddressUrls)(config.dev.https && (0, is_1.isDev)() ? 'https' : 'http', port);
46
- const routes = !apiOnly
47
- ? serverRoutes.filter(route => route.entryName)
48
- : serverRoutes;
49
- let message = 'App running at:\n\n';
50
- if ((0, exports.isSingleEntry)(entrypoints) || apiOnly) {
51
- message += urls
52
- .map(({ type, url }) => ` ${compiled_1.chalk.bold(`> ${type.padEnd(10)}`)}${compiled_1.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}\n`)
53
- .join('');
54
- }
55
- else {
56
- const maxNameLength = Math.max(...routes.map(r => r.entryName.length));
57
- urls.forEach(({ type, url }) => {
58
- message += ` ${compiled_1.chalk.bold(`> ${type}`)}\n`;
59
- routes.forEach(({ entryName, urlPath, isSSR }) => {
60
- if (!checkedEntries.includes(entryName)) {
61
- return;
62
- }
63
- message += ` ${compiled_1.chalk.yellowBright(isSSR ? 'λ' : '○')} ${compiled_1.chalk.yellowBright(entryName.padEnd(maxNameLength + 8))}${compiled_1.chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
64
- });
65
- });
66
- message += '\n';
67
- message += compiled_1.chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
68
- message += compiled_1.chalk.cyanBright(' ○ (Static) client-side renders as static HTML\n');
69
- }
70
- return message;
67
+ const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
68
+ const urls = getAddressUrls(
69
+ config.dev.https && (0, import_is.isDev)() ? "https" : "http",
70
+ port
71
+ );
72
+ const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
73
+ let message = "App running at:\n\n";
74
+ if (isSingleEntry(entrypoints) || apiOnly) {
75
+ message += urls.map(
76
+ ({ type, url }) => ` ${import_compiled.chalk.bold(`> ${type.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
77
+ normalizeUrl(`${url}/${routes[0].urlPath}`)
78
+ )}
79
+ `
80
+ ).join("");
81
+ } else {
82
+ const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
83
+ urls.forEach(({ type, url }) => {
84
+ message += ` ${import_compiled.chalk.bold(`> ${type}`)}
85
+ `;
86
+ routes.forEach(({ entryName, urlPath, isSSR }) => {
87
+ if (!checkedEntries.includes(entryName)) {
88
+ return;
89
+ }
90
+ message += ` ${import_compiled.chalk.yellowBright(
91
+ isSSR ? "λ" : "○"
92
+ )} ${import_compiled.chalk.yellowBright(
93
+ entryName.padEnd(maxNameLength + 8)
94
+ )}${import_compiled.chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}
95
+ `;
96
+ });
97
+ });
98
+ message += "\n";
99
+ message += import_compiled.chalk.cyanBright(
100
+ " λ (Server) server-side renders at runtime\n"
101
+ );
102
+ message += import_compiled.chalk.cyanBright(
103
+ " ○ (Static) client-side renders as static HTML\n"
104
+ );
105
+ }
106
+ return message;
71
107
  };
72
- exports.prettyInstructions = prettyInstructions;
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ getAddressUrls,
111
+ getIpv4Interfaces,
112
+ isSingleEntry,
113
+ prettyInstructions
114
+ });
@@ -5,4 +5,4 @@
5
5
  * LICENSE file at
6
6
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
7
  */
8
- export declare function printBuildError(err: Error): void;
8
+ export declare function printBuildError(err: Error): void;
@@ -1,43 +1,57 @@
1
- "use strict";
2
- /* eslint-disable eslint-comments/no-unlimited-disable */
3
- /* eslint-disable */
4
- /**
5
- * Copyright (c) 2015-present, Facebook, Inc.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file at
9
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.printBuildError = void 0;
13
- // Modified by Chao Xu (xuchaobei)
14
- const compiled_1 = require("./compiled");
15
- const logger_1 = require("./logger");
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 printBuildError_exports = {};
19
+ __export(printBuildError_exports, {
20
+ printBuildError: () => printBuildError
21
+ });
22
+ module.exports = __toCommonJS(printBuildError_exports);
23
+ var import_compiled = require("./compiled");
24
+ var import_logger = require("./logger");
16
25
  function printBuildError(err) {
17
- const message = err != null && err.message;
18
- const stack = err != null && err.stack;
19
- // Add more helpful message for Terser error
20
- if (stack &&
21
- typeof message === 'string' &&
22
- message.indexOf('from Terser') !== -1) {
23
- try {
24
- const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);
25
- if (!matched) {
26
- throw new Error('Using errors for control flow is bad.');
27
- }
28
- const problemPath = matched[2];
29
- const line = matched[3];
30
- const column = matched[4];
31
- logger_1.logger.error(`Failed to minify the code from this file: \n\n ${compiled_1.chalk.yellow(`\t${problemPath}:${line}${column !== '0' ? ':' + column : ''}`)}\n`);
32
- }
33
- catch (ignored) {
34
- logger_1.logger.error(`Failed to minify the bundle. ${err}\n`);
35
- }
26
+ const message = err != null && err.message;
27
+ const stack = err != null && err.stack;
28
+ if (stack && typeof message === "string" && message.indexOf("from Terser") !== -1) {
29
+ try {
30
+ const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);
31
+ if (!matched) {
32
+ throw new Error("Using errors for control flow is bad.");
33
+ }
34
+ const problemPath = matched[2];
35
+ const line = matched[3];
36
+ const column = matched[4];
37
+ import_logger.logger.error(
38
+ `Failed to minify the code from this file:
39
+
40
+ ${import_compiled.chalk.yellow(
41
+ ` ${problemPath}:${line}${column !== "0" ? ":" + column : ""}`
42
+ )}
43
+ `
44
+ );
45
+ } catch (ignored) {
46
+ import_logger.logger.error(`Failed to minify the bundle. ${err}
47
+ `);
36
48
  }
37
- else {
38
- logger_1.logger.error((message || err) + '\n');
39
- }
40
- logger_1.logger.log();
49
+ } else {
50
+ import_logger.logger.error((message || err) + "\n");
51
+ }
52
+ import_logger.logger.log();
41
53
  }
42
- exports.printBuildError = printBuildError;
43
- /* eslint-enable */
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ printBuildError
57
+ });
package/dist/react.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const isBeyondReact17: (cwd: string) => boolean;
1
+ export declare const isBeyondReact17: (cwd: string) => boolean;
package/dist/react.js CHANGED
@@ -1,24 +1,60 @@
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 __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
4
32
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isBeyondReact17 = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const _1 = require(".");
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var react_exports = {};
39
+ __export(react_exports, {
40
+ isBeyondReact17: () => isBeyondReact17
41
+ });
42
+ module.exports = __toCommonJS(react_exports);
43
+ var import_path = __toESM(require("path"));
44
+ var import__ = require(".");
9
45
  const isBeyondReact17 = (cwd) => {
10
- const pkgPath = path_1.default.join(cwd, 'package.json');
11
- if (!_1.fs.existsSync(pkgPath)) {
12
- return false;
13
- }
14
- const pkgInfo = JSON.parse(_1.fs.readFileSync(pkgPath, 'utf8'));
15
- const deps = {
16
- ...pkgInfo.devDependencies,
17
- ...pkgInfo.dependencies,
18
- };
19
- if (typeof deps.react !== 'string') {
20
- return false;
21
- }
22
- return _1.semver.satisfies(_1.semver.minVersion(deps.react), '>=17.0.0');
46
+ const pkgPath = import_path.default.join(cwd, "package.json");
47
+ if (!import__.fs.existsSync(pkgPath)) {
48
+ return false;
49
+ }
50
+ const pkgInfo = JSON.parse(import__.fs.readFileSync(pkgPath, "utf8"));
51
+ const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
52
+ if (typeof deps.react !== "string") {
53
+ return false;
54
+ }
55
+ return import__.semver.satisfies(import__.semver.minVersion(deps.react), ">=17.0.0");
23
56
  };
24
- exports.isBeyondReact17 = isBeyondReact17;
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ isBeyondReact17
60
+ });
@@ -1,2 +1,2 @@
1
1
  export declare const readTsConfig: (root: string) => any;
2
- export declare const readTsConfigByFile: (filename: string) => any;
2
+ export declare const readTsConfigByFile: (filename: string) => any;
@@ -1,17 +1,43 @@
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.readTsConfigByFile = exports.readTsConfig = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const compiled_1 = require("./compiled");
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 readTsConfig_exports = {};
25
+ __export(readTsConfig_exports, {
26
+ readTsConfig: () => readTsConfig,
27
+ readTsConfigByFile: () => readTsConfigByFile
28
+ });
29
+ module.exports = __toCommonJS(readTsConfig_exports);
30
+ var import_path = __toESM(require("path"));
31
+ var import_compiled = require("./compiled");
9
32
  const readTsConfig = (root) => {
10
- return (0, exports.readTsConfigByFile)(path_1.default.resolve(root, './tsconfig.json'));
33
+ return readTsConfigByFile(import_path.default.resolve(root, "./tsconfig.json"));
11
34
  };
12
- exports.readTsConfig = readTsConfig;
13
35
  const readTsConfigByFile = (filename) => {
14
- const content = compiled_1.fs.readFileSync(path_1.default.resolve(filename), 'utf-8');
15
- return compiled_1.json5.parse(content);
36
+ const content = import_compiled.fs.readFileSync(import_path.default.resolve(filename), "utf-8");
37
+ return import_compiled.json5.parse(content);
16
38
  };
17
- exports.readTsConfigByFile = readTsConfigByFile;
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ readTsConfig,
42
+ readTsConfigByFile
43
+ });
@@ -1,3 +1,3 @@
1
1
  export declare const removeLeadingSlash: (s: string) => string;
2
2
  export declare const removeTailSlash: (s: string) => string;
3
- export declare const removeSlash: (s: string) => string;
3
+ export declare const removeSlash: (s: string) => string;
@@ -1,9 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSlash = exports.removeTailSlash = exports.removeLeadingSlash = void 0;
4
- const removeLeadingSlash = (s) => s.replace(/^\/+/, '');
5
- exports.removeLeadingSlash = removeLeadingSlash;
6
- const removeTailSlash = (s) => s.replace(/\/+$/, '');
7
- exports.removeTailSlash = removeTailSlash;
8
- const removeSlash = (s) => (0, exports.removeLeadingSlash)((0, exports.removeTailSlash)(s));
9
- exports.removeSlash = removeSlash;
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 removeSlash_exports = {};
19
+ __export(removeSlash_exports, {
20
+ removeLeadingSlash: () => removeLeadingSlash,
21
+ removeSlash: () => removeSlash,
22
+ removeTailSlash: () => removeTailSlash
23
+ });
24
+ module.exports = __toCommonJS(removeSlash_exports);
25
+ const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
26
+ const removeTailSlash = (s) => s.replace(/\/+$/, "");
27
+ const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ removeLeadingSlash,
31
+ removeSlash,
32
+ removeTailSlash
33
+ });
package/dist/routes.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const getPathWithoutExt: (filename: string) => string;
2
- export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string) => string;
2
+ export declare const getRouteId: (componentPath: string, routesDir: string, entryName: string) => string;
package/dist/routes.js CHANGED
@@ -1,27 +1,54 @@
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.getRouteId = exports.getPathWithoutExt = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const path_2 = require("./path");
9
- const constants_1 = require("./constants");
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 routes_exports = {};
25
+ __export(routes_exports, {
26
+ getPathWithoutExt: () => getPathWithoutExt,
27
+ getRouteId: () => getRouteId
28
+ });
29
+ module.exports = __toCommonJS(routes_exports);
30
+ var import_path = __toESM(require("path"));
31
+ var import_path2 = require("./path");
32
+ var import_constants = require("./constants");
10
33
  const getPathWithoutExt = (filename) => {
11
- const extname = path_1.default.extname(filename);
12
- return filename.slice(0, -extname.length);
34
+ const extname = import_path.default.extname(filename);
35
+ return filename.slice(0, -extname.length);
13
36
  };
14
- exports.getPathWithoutExt = getPathWithoutExt;
15
37
  const getRouteId = (componentPath, routesDir, entryName) => {
16
- const relativePath = (0, path_2.normalizeToPosixPath)(path_1.default.relative(routesDir, componentPath));
17
- const pathWithoutExt = (0, exports.getPathWithoutExt)(relativePath);
18
- let id = ``;
19
- if (entryName === constants_1.MAIN_ENTRY_NAME) {
20
- id = pathWithoutExt;
21
- }
22
- else {
23
- id = `${entryName}_${pathWithoutExt}`;
24
- }
25
- return id;
38
+ const relativePath = (0, import_path2.normalizeToPosixPath)(
39
+ import_path.default.relative(routesDir, componentPath)
40
+ );
41
+ const pathWithoutExt = getPathWithoutExt(relativePath);
42
+ let id = ``;
43
+ if (entryName === import_constants.MAIN_ENTRY_NAME) {
44
+ id = pathWithoutExt;
45
+ } else {
46
+ id = `${entryName}_${pathWithoutExt}`;
47
+ }
48
+ return id;
26
49
  };
27
- exports.getRouteId = getRouteId;
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ getPathWithoutExt,
53
+ getRouteId
54
+ });
@@ -1,4 +1,4 @@
1
1
  export declare const createRuntimeExportsUtils: (pwd?: any, namespace?: any) => {
2
- addExport: (statement: string) => void;
3
- getPath: () => string;
4
- };
2
+ addExport: (statement: string) => void;
3
+ getPath: () => string;
4
+ };