@modern-js/utils 1.4.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/browserslist/index.js +1 -1
  6. package/compiled/dotenv/index.js +1 -0
  7. package/compiled/dotenv/license +23 -0
  8. package/compiled/dotenv/package.json +1 -0
  9. package/compiled/dotenv/types/index.d.ts +59 -0
  10. package/compiled/dotenv-expand/index.d.ts +15 -0
  11. package/compiled/dotenv-expand/index.js +1 -0
  12. package/compiled/dotenv-expand/license +24 -0
  13. package/compiled/dotenv-expand/package.json +1 -0
  14. package/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  15. package/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
  16. package/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  17. package/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  18. package/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  19. package/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  20. package/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
  21. package/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  22. package/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
  23. package/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  24. package/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
  25. package/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  26. package/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  27. package/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  28. package/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
  29. package/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  30. package/compiled/fast-glob/index.js +37 -0
  31. package/compiled/fast-glob/license +21 -0
  32. package/compiled/fast-glob/out/index.d.ts +27 -0
  33. package/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
  34. package/compiled/fast-glob/out/settings.d.ts +164 -0
  35. package/compiled/fast-glob/out/types/index.d.ts +31 -0
  36. package/compiled/fast-glob/package.json +1 -0
  37. package/compiled/globby/index.d.ts +186 -0
  38. package/compiled/globby/index.js +1 -0
  39. package/compiled/globby/license +9 -0
  40. package/compiled/globby/package.json +1 -0
  41. package/compiled/inquirer/index.d.ts +997 -0
  42. package/compiled/inquirer/index.js +9 -0
  43. package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
  44. package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
  45. package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
  46. package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
  47. package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
  48. package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
  49. package/compiled/inquirer/license +22 -0
  50. package/compiled/inquirer/package.json +1 -0
  51. package/compiled/inquirer/through/index.d.ts +25 -0
  52. package/compiled/json5/index.js +1 -0
  53. package/compiled/json5/lib/index.d.ts +4 -0
  54. package/compiled/json5/lib/parse.d.ts +15 -0
  55. package/compiled/json5/lib/stringify.d.ts +89 -0
  56. package/compiled/json5/package.json +1 -0
  57. package/compiled/lodash/index.js +4 -8
  58. package/compiled/mime-types/index.d.ts +14 -0
  59. package/compiled/mime-types/index.js +14 -0
  60. package/compiled/mime-types/license +23 -0
  61. package/compiled/mime-types/package.json +1 -0
  62. package/compiled/minimist/index.d.ts +95 -0
  63. package/compiled/minimist/index.js +1 -0
  64. package/compiled/minimist/license +18 -0
  65. package/compiled/minimist/package.json +1 -0
  66. package/compiled/ora/cli-spinners/index.d.ts +125 -0
  67. package/compiled/ora/index.d.ts +277 -0
  68. package/compiled/ora/index.js +3 -0
  69. package/compiled/ora/license +9 -0
  70. package/compiled/ora/package.json +1 -0
  71. package/compiled/semver/classes/comparator.d.ts +17 -0
  72. package/compiled/semver/classes/range.d.ts +21 -0
  73. package/compiled/semver/classes/semver.d.ts +62 -0
  74. package/compiled/semver/functions/clean.d.ts +8 -0
  75. package/compiled/semver/functions/cmp.d.ts +16 -0
  76. package/compiled/semver/functions/coerce.d.ts +12 -0
  77. package/compiled/semver/functions/compare-build.d.ts +16 -0
  78. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  79. package/compiled/semver/functions/compare.d.ts +20 -0
  80. package/compiled/semver/functions/diff.d.ts +13 -0
  81. package/compiled/semver/functions/eq.d.ts +9 -0
  82. package/compiled/semver/functions/gt.d.ts +9 -0
  83. package/compiled/semver/functions/gte.d.ts +9 -0
  84. package/compiled/semver/functions/inc.d.ts +15 -0
  85. package/compiled/semver/functions/lt.d.ts +9 -0
  86. package/compiled/semver/functions/lte.d.ts +8 -0
  87. package/compiled/semver/functions/major.d.ts +9 -0
  88. package/compiled/semver/functions/minor.d.ts +9 -0
  89. package/compiled/semver/functions/neq.d.ts +9 -0
  90. package/compiled/semver/functions/parse.d.ts +12 -0
  91. package/compiled/semver/functions/patch.d.ts +9 -0
  92. package/compiled/semver/functions/prerelease.d.ts +12 -0
  93. package/compiled/semver/functions/rcompare.d.ts +15 -0
  94. package/compiled/semver/functions/rsort.d.ts +9 -0
  95. package/compiled/semver/functions/satisfies.d.ts +14 -0
  96. package/compiled/semver/functions/sort.d.ts +9 -0
  97. package/compiled/semver/functions/valid.d.ts +11 -0
  98. package/compiled/semver/index.d.ts +133 -0
  99. package/compiled/semver/index.js +1 -0
  100. package/compiled/semver/internals/identifiers.d.ts +13 -0
  101. package/compiled/semver/license +15 -0
  102. package/compiled/semver/package.json +1 -0
  103. package/compiled/semver/ranges/gtr.d.ts +14 -0
  104. package/compiled/semver/ranges/intersects.d.ts +13 -0
  105. package/compiled/semver/ranges/ltr.d.ts +14 -0
  106. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  107. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  108. package/compiled/semver/ranges/min-version.d.ts +10 -0
  109. package/compiled/semver/ranges/outside.d.ts +15 -0
  110. package/compiled/semver/ranges/simplify.d.ts +14 -0
  111. package/compiled/semver/ranges/subset.d.ts +13 -0
  112. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  113. package/compiled/semver/ranges/valid.d.ts +12 -0
  114. package/compiled/slash/index.d.ts +25 -0
  115. package/compiled/slash/index.js +1 -0
  116. package/compiled/slash/license +9 -0
  117. package/compiled/slash/package.json +1 -0
  118. package/compiled/url-join/index.d.ts +17 -0
  119. package/compiled/url-join/index.js +1 -0
  120. package/compiled/url-join/license +21 -0
  121. package/compiled/url-join/package.json +1 -0
  122. package/dist/alias.js +4 -1
  123. package/dist/analyzeProject.d.ts +1 -0
  124. package/dist/analyzeProject.js +31 -0
  125. package/dist/compiled.d.ts +34 -17
  126. package/dist/compiled.js +59 -21
  127. package/dist/constants.d.ts +1 -1
  128. package/dist/constants.js +1 -1
  129. package/dist/emptyDir.js +4 -13
  130. package/dist/format.js +6 -1
  131. package/dist/getEntryOptions.js +2 -1
  132. package/dist/getPackageManager.js +19 -30
  133. package/dist/getPort.js +3 -12
  134. package/dist/getServerConfig.js +2 -11
  135. package/dist/index.d.ts +2 -2
  136. package/dist/index.js +2 -2
  137. package/dist/logger.d.ts +3 -0
  138. package/dist/logger.js +21 -6
  139. package/dist/monorepo.js +4 -1
  140. package/dist/nodeEnv.js +24 -39
  141. package/dist/prettyInstructions.js +3 -3
  142. package/dist/runtimeExports.js +1 -1
  143. package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
  144. package/dist/{ssrHelpers.js → ssr.js} +0 -0
  145. package/dist/storage.js +1 -1
  146. package/dist/watch.js +9 -18
  147. package/package.json +41 -35
  148. package/tsconfig.json +1 -0
  149. package/dist/getCacheIdentifier.d.ts +0 -7
  150. package/dist/getCacheIdentifier.js +0 -24
  151. package/modern.config.js +0 -6
  152. package/tests/.eslintrc.js +0 -6
  153. package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
  154. package/tests/applyOptionsChain.test.ts +0 -100
  155. package/tests/compatRequire.test.ts +0 -32
  156. package/tests/debug.test.ts +0 -25
  157. package/tests/ensureAbsolutePath.test.ts +0 -16
  158. package/tests/findExists.test.ts +0 -22
  159. package/tests/fixtures/browserlist/develop/package.json +0 -11
  160. package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
  161. package/tests/fixtures/browserlist/pkg/package.json +0 -7
  162. package/tests/fixtures/compat-require/cjs.js +0 -1
  163. package/tests/fixtures/compat-require/empty.js +0 -1
  164. package/tests/fixtures/compat-require/esm.js +0 -5
  165. package/tests/fixtures/compat-require/foo.js +0 -3
  166. package/tests/fixtures/file-exists/a.ejs +0 -0
  167. package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
  168. package/tests/fixtures/file-exists/a.mjs +0 -0
  169. package/tests/fixtures/file-exists/a.ts +0 -0
  170. package/tests/format.test.ts +0 -60
  171. package/tests/generateMetaTags.test.ts +0 -19
  172. package/tests/getBrowserslist.test.ts +0 -32
  173. package/tests/getCacheIdentifier.test.ts +0 -37
  174. package/tests/getEntryOptions.test.ts +0 -53
  175. package/tests/index.test.ts +0 -18
  176. package/tests/is.test.ts +0 -27
  177. package/tests/isPlatform.test.ts +0 -19
  178. package/tests/isType.test.ts +0 -85
  179. package/tests/logger.test.ts +0 -53
  180. package/tests/prettyInstructions.test.ts +0 -139
  181. package/tests/removeSlash.test.ts +0 -19
  182. package/tests/tsconfig.json +0 -11
  183. package/tests/wait.ts +0 -38
@@ -1,21 +1,38 @@
1
- import fs from '../compiled/fs-extra';
2
- import chalk from '../compiled/chalk';
3
- import lodash from '../compiled/lodash';
4
- import signale from '../compiled/signale';
5
- export { fs, chalk, lodash, signale };
1
+ export { default as fs } from '../compiled/fs-extra';
2
+ export { default as ora } from '../compiled/ora';
3
+ export { default as glob } from '../compiled/glob';
4
+ export { default as yaml } from '../compiled/js-yaml';
5
+ export { default as chalk } from '../compiled/chalk';
6
+ export { default as debug } from '../compiled/debug';
7
+ export { default as slash } from '../compiled/slash';
8
+ export { default as execa } from '../compiled/execa';
9
+ export { default as json5 } from '../compiled/json5';
10
+ export { default as upath } from '../compiled/upath';
11
+ export { default as pkgUp } from '../compiled/pkg-up';
12
+ export { default as semver } from '../compiled/semver';
13
+ export { default as dotenv } from '../compiled/dotenv';
14
+ export { default as lodash } from '../compiled/lodash';
15
+ export { default as globby } from '../compiled/globby';
16
+ export { default as address } from '../compiled/address';
17
+ export { default as signale } from '../compiled/signale';
18
+ export { default as urlJoin } from '../compiled/url-join';
19
+ export { default as minimist } from '../compiled/minimist';
20
+ export { default as fastGlob } from '../compiled/fast-glob';
21
+ export { default as filesize } from '../compiled/filesize';
22
+ export { default as gzipSize } from '../compiled/gzip-size';
23
+ export { default as stripAnsi } from '../compiled/strip-ansi';
24
+ export { default as dotenvExpand } from '../compiled/dotenv-expand';
25
+ export { default as browserslist } from '../compiled/browserslist';
26
+ export { default as recursiveReaddir } from '../compiled/recursive-readdir';
6
27
  export { program, Command } from '../compiled/commander';
7
- export { Signale, SignaleOptions } from '../compiled/signale';
28
+ export { Signale, type SignaleOptions } from '../compiled/signale';
8
29
  export type { IOptions as GlobOptions } from '../compiled/glob';
30
+ export type { GlobbyOptions } from '../compiled/globby';
9
31
  export type { FSWatcher, WatchOptions } from '../compiled/chokidar';
10
- export declare const glob: typeof import('../compiled/glob');
11
- export declare const yaml: typeof import('../compiled/js-yaml');
12
- export declare const execa: typeof import('../compiled/execa');
13
- export declare const pkgUp: typeof import('../compiled/pkg-up');
14
- export declare const upath: typeof import('../compiled/upath');
15
- export declare const debug: typeof import('../compiled/debug');
32
+ /**
33
+ * Lazy import some expensive modules that will slow down startup speed.
34
+ * Notice that `csmith-tools build` can not bundle lazy imported modules.
35
+ */
36
+ export declare const mime: typeof import('../compiled/mime-types');
16
37
  export declare const chokidar: typeof import('../compiled/chokidar');
17
- export declare const gzipSize: typeof import('../compiled/gzip-size');
18
- export declare const filesize: typeof import('../compiled/filesize');
19
- export declare const stripAnsi: typeof import('../compiled/strip-ansi');
20
- export declare const browserslist: typeof import('../compiled/browserslist');
21
- export declare const recursiveReaddir: typeof import('../compiled/recursive-readdir');
38
+ export declare const inquirer: typeof import('../compiled/inquirer');
package/dist/compiled.js CHANGED
@@ -3,31 +3,69 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.recursiveReaddir = exports.browserslist = exports.stripAnsi = exports.filesize = exports.gzipSize = exports.chokidar = exports.debug = exports.upath = exports.pkgUp = exports.execa = exports.yaml = exports.glob = exports.SignaleOptions = exports.Signale = exports.Command = exports.program = exports.signale = exports.lodash = exports.chalk = exports.fs = void 0;
7
- const fs_extra_1 = __importDefault(require("../compiled/fs-extra"));
8
- exports.fs = fs_extra_1.default;
9
- const chalk_1 = __importDefault(require("../compiled/chalk"));
10
- exports.chalk = chalk_1.default;
11
- const lodash_1 = __importDefault(require("../compiled/lodash"));
12
- exports.lodash = lodash_1.default;
13
- const signale_1 = __importDefault(require("../compiled/signale"));
14
- exports.signale = signale_1.default;
6
+ exports.inquirer = exports.chokidar = exports.mime = exports.Signale = exports.Command = exports.program = exports.recursiveReaddir = exports.browserslist = exports.dotenvExpand = exports.stripAnsi = exports.gzipSize = exports.filesize = exports.fastGlob = exports.minimist = exports.urlJoin = exports.signale = exports.address = exports.globby = exports.lodash = exports.dotenv = exports.semver = exports.pkgUp = exports.upath = exports.json5 = exports.execa = exports.slash = exports.debug = exports.chalk = exports.yaml = exports.glob = exports.ora = exports.fs = void 0;
15
7
  const import_1 = require("./import");
8
+ var fs_extra_1 = require("../compiled/fs-extra");
9
+ Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return __importDefault(fs_extra_1).default; } });
10
+ var ora_1 = require("../compiled/ora");
11
+ Object.defineProperty(exports, "ora", { enumerable: true, get: function () { return __importDefault(ora_1).default; } });
12
+ var glob_1 = require("../compiled/glob");
13
+ Object.defineProperty(exports, "glob", { enumerable: true, get: function () { return __importDefault(glob_1).default; } });
14
+ var js_yaml_1 = require("../compiled/js-yaml");
15
+ Object.defineProperty(exports, "yaml", { enumerable: true, get: function () { return __importDefault(js_yaml_1).default; } });
16
+ var chalk_1 = require("../compiled/chalk");
17
+ Object.defineProperty(exports, "chalk", { enumerable: true, get: function () { return __importDefault(chalk_1).default; } });
18
+ var debug_1 = require("../compiled/debug");
19
+ Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return __importDefault(debug_1).default; } });
20
+ var slash_1 = require("../compiled/slash");
21
+ Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return __importDefault(slash_1).default; } });
22
+ var execa_1 = require("../compiled/execa");
23
+ Object.defineProperty(exports, "execa", { enumerable: true, get: function () { return __importDefault(execa_1).default; } });
24
+ var json5_1 = require("../compiled/json5");
25
+ Object.defineProperty(exports, "json5", { enumerable: true, get: function () { return __importDefault(json5_1).default; } });
26
+ var upath_1 = require("../compiled/upath");
27
+ Object.defineProperty(exports, "upath", { enumerable: true, get: function () { return __importDefault(upath_1).default; } });
28
+ var pkg_up_1 = require("../compiled/pkg-up");
29
+ Object.defineProperty(exports, "pkgUp", { enumerable: true, get: function () { return __importDefault(pkg_up_1).default; } });
30
+ var semver_1 = require("../compiled/semver");
31
+ Object.defineProperty(exports, "semver", { enumerable: true, get: function () { return __importDefault(semver_1).default; } });
32
+ var dotenv_1 = require("../compiled/dotenv");
33
+ Object.defineProperty(exports, "dotenv", { enumerable: true, get: function () { return __importDefault(dotenv_1).default; } });
34
+ var lodash_1 = require("../compiled/lodash");
35
+ Object.defineProperty(exports, "lodash", { enumerable: true, get: function () { return __importDefault(lodash_1).default; } });
36
+ var globby_1 = require("../compiled/globby");
37
+ Object.defineProperty(exports, "globby", { enumerable: true, get: function () { return __importDefault(globby_1).default; } });
38
+ var address_1 = require("../compiled/address");
39
+ Object.defineProperty(exports, "address", { enumerable: true, get: function () { return __importDefault(address_1).default; } });
40
+ var signale_1 = require("../compiled/signale");
41
+ Object.defineProperty(exports, "signale", { enumerable: true, get: function () { return __importDefault(signale_1).default; } });
42
+ var url_join_1 = require("../compiled/url-join");
43
+ Object.defineProperty(exports, "urlJoin", { enumerable: true, get: function () { return __importDefault(url_join_1).default; } });
44
+ var minimist_1 = require("../compiled/minimist");
45
+ Object.defineProperty(exports, "minimist", { enumerable: true, get: function () { return __importDefault(minimist_1).default; } });
46
+ var fast_glob_1 = require("../compiled/fast-glob");
47
+ Object.defineProperty(exports, "fastGlob", { enumerable: true, get: function () { return __importDefault(fast_glob_1).default; } });
48
+ var filesize_1 = require("../compiled/filesize");
49
+ Object.defineProperty(exports, "filesize", { enumerable: true, get: function () { return __importDefault(filesize_1).default; } });
50
+ var gzip_size_1 = require("../compiled/gzip-size");
51
+ Object.defineProperty(exports, "gzipSize", { enumerable: true, get: function () { return __importDefault(gzip_size_1).default; } });
52
+ var strip_ansi_1 = require("../compiled/strip-ansi");
53
+ Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return __importDefault(strip_ansi_1).default; } });
54
+ var dotenv_expand_1 = require("../compiled/dotenv-expand");
55
+ Object.defineProperty(exports, "dotenvExpand", { enumerable: true, get: function () { return __importDefault(dotenv_expand_1).default; } });
56
+ var browserslist_1 = require("../compiled/browserslist");
57
+ Object.defineProperty(exports, "browserslist", { enumerable: true, get: function () { return __importDefault(browserslist_1).default; } });
58
+ var recursive_readdir_1 = require("../compiled/recursive-readdir");
59
+ Object.defineProperty(exports, "recursiveReaddir", { enumerable: true, get: function () { return __importDefault(recursive_readdir_1).default; } });
16
60
  var commander_1 = require("../compiled/commander");
17
61
  Object.defineProperty(exports, "program", { enumerable: true, get: function () { return commander_1.program; } });
18
62
  Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return commander_1.Command; } });
19
63
  var signale_2 = require("../compiled/signale");
20
64
  Object.defineProperty(exports, "Signale", { enumerable: true, get: function () { return signale_2.Signale; } });
21
- Object.defineProperty(exports, "SignaleOptions", { enumerable: true, get: function () { return signale_2.SignaleOptions; } });
22
- exports.glob = import_1.Import.lazy('../compiled/glob', require);
23
- exports.yaml = import_1.Import.lazy('../compiled/js-yaml', require);
24
- exports.execa = import_1.Import.lazy('../compiled/execa', require);
25
- exports.pkgUp = import_1.Import.lazy('../compiled/pkg-up', require);
26
- exports.upath = import_1.Import.lazy('../compiled/upath', require);
27
- exports.debug = import_1.Import.lazy('../compiled/debug', require);
65
+ /**
66
+ * Lazy import some expensive modules that will slow down startup speed.
67
+ * Notice that `csmith-tools build` can not bundle lazy imported modules.
68
+ */
69
+ exports.mime = import_1.Import.lazy('../compiled/mime-types', require);
28
70
  exports.chokidar = import_1.Import.lazy('../compiled/chokidar', require);
29
- exports.gzipSize = import_1.Import.lazy('../compiled/gzip-size', require);
30
- exports.filesize = import_1.Import.lazy('../compiled/filesize', require);
31
- exports.stripAnsi = import_1.Import.lazy('../compiled/strip-ansi', require);
32
- exports.browserslist = import_1.Import.lazy('../compiled/browserslist', require);
33
- exports.recursiveReaddir = import_1.Import.lazy('../compiled/recursive-readdir', require);
71
+ exports.inquirer = import_1.Import.lazy('../compiled/inquirer', require);
@@ -39,7 +39,7 @@ export declare const SHARED_DIR = "shared";
39
39
  /**
40
40
  * Modern.config.ts cached dir
41
41
  */
42
- export declare const CONFIG_CACHE_DIR = "./node_modules/.node-bundle-require";
42
+ export declare const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
43
43
  export declare const CONFIG_FILE_EXTENSIONS: string[];
44
44
  /**
45
45
  * Serialized config path
package/dist/constants.js CHANGED
@@ -42,7 +42,7 @@ exports.SHARED_DIR = 'shared';
42
42
  /**
43
43
  * Modern.config.ts cached dir
44
44
  */
45
- exports.CONFIG_CACHE_DIR = './node_modules/.node-bundle-require';
45
+ exports.CONFIG_CACHE_DIR = './node_modules/.cache/node-bundle-require';
46
46
  exports.CONFIG_FILE_EXTENSIONS = ['.js', '.ts', '.ejs', '.mjs'];
47
47
  /**
48
48
  * Serialized config path
package/dist/emptyDir.js CHANGED
@@ -1,19 +1,10 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.emptyDir = void 0;
13
4
  const compiled_1 = require("./compiled");
14
- const emptyDir = (dir) => __awaiter(void 0, void 0, void 0, function* () {
15
- if (yield compiled_1.fs.pathExists(dir)) {
16
- yield compiled_1.fs.emptyDir(dir);
5
+ const emptyDir = async (dir) => {
6
+ if (await compiled_1.fs.pathExists(dir)) {
7
+ await compiled_1.fs.emptyDir(dir);
17
8
  }
18
- });
9
+ };
19
10
  exports.emptyDir = emptyDir;
package/dist/format.js CHANGED
@@ -100,7 +100,12 @@ function formatProxyOptions(proxyOptions) {
100
100
  else {
101
101
  Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce((total, source) => {
102
102
  const option = proxyOptions[source];
103
- total.push(Object.assign({ context: source, changeOrigin: true, logLevel: 'warn' }, (typeof option === 'string' ? { target: option } : option)));
103
+ total.push({
104
+ context: source,
105
+ changeOrigin: true,
106
+ logLevel: 'warn',
107
+ ...(typeof option === 'string' ? { target: option } : option),
108
+ });
104
109
  return total;
105
110
  }, []));
106
111
  }
@@ -15,7 +15,8 @@ const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
15
15
  // eslint-disable-next-line no-nested-ternary
16
16
  return optionsByEntry !== undefined
17
17
  ? (0, is_1.isPlainObject)(optionsByEntry) && (0, is_1.isPlainObject)(baseOptions)
18
- ? Object.assign(Object.assign({}, baseOptions), optionsByEntry) : optionsByEntry
18
+ ? { ...baseOptions, ...optionsByEntry }
19
+ : optionsByEntry
19
20
  : baseOptions;
20
21
  }
21
22
  else {
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -18,30 +9,28 @@ const path_1 = __importDefault(require("path"));
18
9
  const compiled_1 = require("./compiled");
19
10
  const nodeEnv_1 = require("./nodeEnv");
20
11
  const MAX_TIMES = 5;
21
- function getPackageManager(cwd = process.cwd()) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- let appDirectory = cwd;
24
- let times = 0;
25
- while (os_1.default.homedir() !== appDirectory && times < MAX_TIMES) {
26
- times++;
27
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
28
- return 'pnpm';
29
- }
30
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
31
- return 'yarn';
32
- }
33
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'package-lock.json'))) {
34
- return 'npm';
35
- }
36
- appDirectory = path_1.default.join(appDirectory, '..');
37
- }
38
- if (yield (0, nodeEnv_1.canUsePnpm)()) {
12
+ async function getPackageManager(cwd = process.cwd()) {
13
+ let appDirectory = cwd;
14
+ 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'))) {
39
18
  return 'pnpm';
40
19
  }
41
- if (yield (0, nodeEnv_1.canUseYarn)()) {
20
+ if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
42
21
  return 'yarn';
43
22
  }
44
- return 'npm';
45
- });
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, '..');
27
+ }
28
+ if (await (0, nodeEnv_1.canUsePnpm)()) {
29
+ return 'pnpm';
30
+ }
31
+ if (await (0, nodeEnv_1.canUseYarn)()) {
32
+ return 'yarn';
33
+ }
34
+ return 'npm';
46
35
  }
47
36
  exports.getPackageManager = getPackageManager;
package/dist/getPort.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -23,7 +14,7 @@ const logger_1 = require("./logger");
23
14
  * @returns Available port number.
24
15
  */
25
16
  /* eslint-disable no-param-reassign, @typescript-eslint/no-loop-func */
26
- const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const getPort = async (port, tryLimits = 20) => {
27
18
  if (typeof port === 'string') {
28
19
  port = parseInt(port, 10);
29
20
  }
@@ -32,7 +23,7 @@ const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, func
32
23
  let attempts = 0;
33
24
  while (!found && attempts <= tryLimits) {
34
25
  try {
35
- yield new Promise((resolve, reject) => {
26
+ await new Promise((resolve, reject) => {
36
27
  const server = net_1.default.createServer();
37
28
  server.unref();
38
29
  server.on('error', reject);
@@ -57,6 +48,6 @@ const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, func
57
48
  logger_1.logger.info(compiled_1.chalk.red(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`));
58
49
  }
59
50
  return port;
60
- });
51
+ };
61
52
  exports.getPort = getPort;
62
53
  /* eslint-enable no-param-reassign, @typescript-eslint/no-loop-func */
@@ -18,22 +18,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
21
  Object.defineProperty(exports, "__esModule", { value: true });
31
22
  exports.getServerConfig = void 0;
32
23
  const path = __importStar(require("path"));
33
24
  const constants_1 = require("./constants");
34
25
  const findExists_1 = require("./findExists");
35
- const getServerConfig = (appDirectory, configFile) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const getServerConfig = async (appDirectory, configFile) => {
36
27
  const configFilePath = (0, findExists_1.findExists)(constants_1.CONFIG_FILE_EXTENSIONS.map(extension => path.resolve(appDirectory, `${configFile}${extension}`)));
37
28
  return configFilePath;
38
- });
29
+ };
39
30
  exports.getServerConfig = getServerConfig;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ export * from './compatRequire';
9
9
  export * from './logger';
10
10
  export * from './constants';
11
11
  export * from './ensureAbsolutePath';
12
- export * from './getCacheIdentifier';
13
12
  export * from './clearConsole';
14
13
  export * from './applyOptionsChain';
15
14
  export * from './getBrowserslist';
@@ -30,4 +29,5 @@ export * from './nodeEnv';
30
29
  export * from './wait';
31
30
  export * from './emptyDir';
32
31
  export * from './getServerConfig';
33
- export * from './ssrHelpers';
32
+ export * from './ssr';
33
+ export * from './analyzeProject';
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ __exportStar(require("./compatRequire"), exports);
21
21
  __exportStar(require("./logger"), exports);
22
22
  __exportStar(require("./constants"), exports);
23
23
  __exportStar(require("./ensureAbsolutePath"), exports);
24
- __exportStar(require("./getCacheIdentifier"), exports);
25
24
  __exportStar(require("./clearConsole"), exports);
26
25
  __exportStar(require("./applyOptionsChain"), exports);
27
26
  __exportStar(require("./getBrowserslist"), exports);
@@ -42,4 +41,5 @@ __exportStar(require("./nodeEnv"), exports);
42
41
  __exportStar(require("./wait"), exports);
43
42
  __exportStar(require("./emptyDir"), exports);
44
43
  __exportStar(require("./getServerConfig"), exports);
45
- __exportStar(require("./ssrHelpers"), exports);
44
+ __exportStar(require("./ssr"), exports);
45
+ __exportStar(require("./analyzeProject"), exports);
package/dist/logger.d.ts CHANGED
@@ -12,6 +12,7 @@ interface InstanceConfiguration {
12
12
  }
13
13
  interface ConstructorOptions {
14
14
  config?: InstanceConfiguration;
15
+ level?: string;
15
16
  types?: Record<string, LoggerConfiguration>;
16
17
  }
17
18
  declare type LoggerFunction = (message?: number | string | Error, ...args: any[]) => void;
@@ -42,6 +43,7 @@ declare const LOG_TYPES: {
42
43
  };
43
44
  declare class Logger {
44
45
  private readonly logCount;
46
+ private readonly level;
45
47
  private history;
46
48
  private readonly config;
47
49
  private readonly types;
@@ -59,5 +61,6 @@ declare type LoggerInterface = {
59
61
  [key in keyof typeof LOG_TYPES]: LoggerFunction;
60
62
  };
61
63
  declare const logger: Logger & LoggerInterface;
64
+ export { Logger };
62
65
  export { logger };
63
66
  export type { LoggerInterface };
package/dist/logger.js CHANGED
@@ -3,9 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logger = void 0;
6
+ exports.logger = exports.Logger = void 0;
7
7
  const chalk_1 = __importDefault(require("../compiled/chalk"));
8
8
  const { grey, underline } = chalk_1.default;
9
+ const LOG_LEVEL = {
10
+ error: 0,
11
+ warn: 1,
12
+ info: 2,
13
+ debug: 3,
14
+ log: 4,
15
+ };
9
16
  const LOG_TYPES = {
10
17
  error: {
11
18
  color: 'red',
@@ -27,7 +34,7 @@ const LOG_TYPES = {
27
34
  label: 'debug',
28
35
  level: 'debug',
29
36
  },
30
- log: { level: 'info' },
37
+ log: { level: 'log' },
31
38
  };
32
39
  const DEFAULT_CONFIG = {
33
40
  displayLabel: true,
@@ -38,8 +45,12 @@ class Logger {
38
45
  constructor(options = {}) {
39
46
  this.logCount = 200;
40
47
  this.history = {};
41
- this.config = Object.assign(Object.assign({}, DEFAULT_CONFIG), (options.config || {}));
42
- this.types = Object.assign(Object.assign({}, LOG_TYPES), (options.types || {}));
48
+ this.level = options.level || LOG_TYPES.log.level;
49
+ this.config = { ...DEFAULT_CONFIG, ...(options.config || {}) };
50
+ this.types = {
51
+ ...LOG_TYPES,
52
+ ...(options.types || {}),
53
+ };
43
54
  this.longestLabel = this.getLongestLabel();
44
55
  Object.keys(this.types).forEach(type => {
45
56
  this[type] = this._log.bind(this, type);
@@ -54,12 +65,15 @@ class Logger {
54
65
  this.history[type].shift();
55
66
  }
56
67
  }
57
- _log(type, message) {
68
+ _log(type, message, ...args) {
58
69
  if (message === undefined) {
59
70
  // eslint-disable-next-line no-console
60
71
  console.log();
61
72
  return;
62
73
  }
74
+ if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
75
+ return;
76
+ }
63
77
  let label = '';
64
78
  let text = '';
65
79
  const logType = this.types[type];
@@ -94,7 +108,7 @@ class Logger {
94
108
  }
95
109
  const log = label.length > 0 ? `${label} ${text}` : text;
96
110
  // eslint-disable-next-line no-console
97
- console.log(log);
111
+ console.log(log, ...args);
98
112
  }
99
113
  getLongestLabel() {
100
114
  let longestLabel = '';
@@ -123,6 +137,7 @@ class Logger {
123
137
  }
124
138
  }
125
139
  }
140
+ exports.Logger = Logger;
126
141
  const logger = new Logger();
127
142
  exports.logger = logger;
128
143
  logger.Logger = Logger;
package/dist/monorepo.js CHANGED
@@ -31,7 +31,10 @@ const isMonorepo = (root) => (0, exports.isLerna)(root) || (0, exports.isYarnWor
31
31
  exports.isMonorepo = isMonorepo;
32
32
  const isModernjsMonorepo = (root) => {
33
33
  const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'package.json'), 'utf8'));
34
- const deps = Object.assign(Object.assign({}, (json.dependencies || {})), (json.devDependencies || {}));
34
+ const deps = {
35
+ ...(json.dependencies || {}),
36
+ ...(json.devDependencies || {}),
37
+ };
35
38
  return Boolean(deps['@modern-js/monorepo-tools']);
36
39
  };
37
40
  exports.isModernjsMonorepo = isModernjsMonorepo;
package/dist/nodeEnv.js CHANGED
@@ -1,49 +1,34 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.canUsePnpm = exports.canUseYarn = exports.canUseNpm = void 0;
13
4
  const compiled_1 = require("./compiled");
14
- function canUseNpm() {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- try {
17
- yield (0, compiled_1.execa)('npm', ['--version'], { env: process.env });
18
- return true;
19
- }
20
- catch (e) {
21
- return false;
22
- }
23
- });
5
+ async function canUseNpm() {
6
+ try {
7
+ await (0, compiled_1.execa)('npm', ['--version'], { env: process.env });
8
+ return true;
9
+ }
10
+ catch (e) {
11
+ return false;
12
+ }
24
13
  }
25
14
  exports.canUseNpm = canUseNpm;
26
- function canUseYarn() {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- try {
29
- yield (0, compiled_1.execa)('yarn', ['--version'], { env: process.env });
30
- return true;
31
- }
32
- catch (e) {
33
- return false;
34
- }
35
- });
15
+ async function canUseYarn() {
16
+ try {
17
+ await (0, compiled_1.execa)('yarn', ['--version'], { env: process.env });
18
+ return true;
19
+ }
20
+ catch (e) {
21
+ return false;
22
+ }
36
23
  }
37
24
  exports.canUseYarn = canUseYarn;
38
- function canUsePnpm() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- try {
41
- yield (0, compiled_1.execa)('pnpm', ['--version'], { env: process.env });
42
- return true;
43
- }
44
- catch (e) {
45
- return false;
46
- }
47
- });
25
+ async function canUsePnpm() {
26
+ try {
27
+ await (0, compiled_1.execa)('pnpm', ['--version'], { env: process.env });
28
+ return true;
29
+ }
30
+ catch (e) {
31
+ return false;
32
+ }
48
33
  }
49
34
  exports.canUsePnpm = canUsePnpm;
@@ -33,13 +33,13 @@ const getAddressUrls = (protocol = 'http', port) => {
33
33
  }, []);
34
34
  };
35
35
  const prettyInstructions = (appContext, config) => {
36
- const { entrypoints, serverRoutes, port, existSrc, checkedEntries } = appContext;
36
+ const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
37
37
  const urls = getAddressUrls(config.dev.https && (0, is_1.isDev)() ? 'https' : 'http', port);
38
- const routes = existSrc
38
+ const routes = !apiOnly
39
39
  ? serverRoutes.filter(route => route.entryName)
40
40
  : serverRoutes;
41
41
  let message = 'App running at:\n\n';
42
- if ((0, exports.isSingleEntry)(entrypoints) || !existSrc) {
42
+ if ((0, exports.isSingleEntry)(entrypoints) || apiOnly) {
43
43
  message += urls
44
44
  .map(({ type, url }) => ` ${compiled_1.chalk.bold(`> ${type.padEnd(10)}`)}${compiled_1.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}\n`)
45
45
  .join('');
@@ -41,7 +41,7 @@ exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
41
41
  compiled_1.fs.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
42
42
  }
43
43
  }
44
- catch (_a) {
44
+ catch {
45
45
  // FIXME:
46
46
  }
47
47
  };
@@ -1,4 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /**
3
+ * ssr helpers
4
+ */
2
5
  import type { IncomingHttpHeaders } from 'http';
3
6
  declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
4
7
  export { run, useHeaders };
File without changes
package/dist/storage.js CHANGED
@@ -49,7 +49,7 @@ const createStorage = () => {
49
49
  }
50
50
  const context = storage.getStore();
51
51
  if (!context) {
52
- throw new Error(`Can't call useContext out of scope, it should be placed on top of the function`);
52
+ throw new Error(`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`);
53
53
  }
54
54
  return context;
55
55
  };