@modern-js/utils 2.12.0 → 2.12.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. package/dist/{alias.js → cjs/alias.js} +4 -15
  2. package/dist/{analyzeProject.js → cjs/analyzeProject.js} +5 -25
  3. package/dist/{babel.js → cjs/babel.js} +9 -16
  4. package/dist/{compatRequire.js → cjs/compatRequire.js} +4 -17
  5. package/dist/cjs/emptyDir.js +32 -0
  6. package/dist/{getEntryOptions.js → cjs/getEntryOptions.js} +1 -15
  7. package/dist/{getPackageManager.js → cjs/getPackageManager.js} +19 -41
  8. package/dist/{getPort.js → cjs/getPort.js} +4 -24
  9. package/dist/{getServerConfig.js → cjs/getServerConfig.js} +2 -22
  10. package/dist/{logger.js → cjs/logger.js} +5 -16
  11. package/dist/{monorepo.js → cjs/monorepo.js} +4 -15
  12. package/dist/cjs/nodeEnv.js +55 -0
  13. package/dist/{path.js → cjs/path.js} +1 -1
  14. package/dist/{pathSerializer.js → cjs/pathSerializer.js} +1 -1
  15. package/dist/{react.js → cjs/react.js} +4 -15
  16. package/dist/{runtimeExports.js → cjs/runtimeExports.js} +1 -1
  17. package/dist/{universal → cjs/universal}/nestedRoutes.js +2 -19
  18. package/dist/cjs/version.js +59 -0
  19. package/dist/{watch.js → cjs/watch.js} +9 -29
  20. package/dist/esm/FileSizeReporter.js +180 -0
  21. package/dist/esm/alias.js +83 -0
  22. package/dist/esm/analyzeProject.js +168 -0
  23. package/dist/esm/applyOptionsChain.js +26 -0
  24. package/dist/esm/babel.js +169 -0
  25. package/dist/esm/chainId.js +92 -0
  26. package/dist/esm/clearConsole.js +6 -0
  27. package/dist/esm/commands.js +17 -0
  28. package/dist/esm/compatRequire.js +68 -0
  29. package/dist/esm/compiled.js +34 -0
  30. package/dist/esm/constants.js +317 -0
  31. package/dist/esm/debug.js +5 -0
  32. package/dist/esm/emptyDir.js +158 -0
  33. package/dist/esm/ensureAbsolutePath.js +5 -0
  34. package/dist/esm/ensureArray.js +9 -0
  35. package/dist/esm/findExists.js +27 -0
  36. package/dist/esm/generateMetaTags.js +40 -0
  37. package/dist/esm/getBrowserslist.js +12 -0
  38. package/dist/esm/getCoreJsVersion.js +57 -0
  39. package/dist/esm/getEntryOptions.js +45 -0
  40. package/dist/esm/getPackageManager.js +187 -0
  41. package/dist/esm/getPort.js +215 -0
  42. package/dist/esm/getServerConfig.js +145 -0
  43. package/dist/esm/getTargetDir.js +6 -0
  44. package/dist/esm/import.js +8 -0
  45. package/dist/esm/index.js +44 -0
  46. package/dist/esm/is/index.js +85 -0
  47. package/dist/esm/is/nodeEnv.js +16 -0
  48. package/dist/esm/is/platform.js +7 -0
  49. package/dist/esm/is/type.js +25 -0
  50. package/dist/esm/logger.js +207 -0
  51. package/dist/esm/monorepo.js +109 -0
  52. package/dist/esm/nodeEnv.js +258 -0
  53. package/dist/esm/path.js +85 -0
  54. package/dist/esm/pathSerializer.js +85 -0
  55. package/dist/esm/plugin.js +45 -0
  56. package/dist/esm/prettyInstructions.js +96 -0
  57. package/dist/esm/printBuildError.js +24 -0
  58. package/dist/esm/react.js +43 -0
  59. package/dist/esm/readTsConfig.js +10 -0
  60. package/dist/esm/removeSlash.js +10 -0
  61. package/dist/esm/resolve.js +42 -0
  62. package/dist/esm/routes.js +19 -0
  63. package/dist/esm/runtimeExports.js +65 -0
  64. package/dist/esm/ssr.js +3 -0
  65. package/dist/esm/storage.js +36 -0
  66. package/dist/esm/testUtils.js +13 -0
  67. package/dist/esm/types.js +1 -0
  68. package/dist/esm/universal/constants.js +3 -0
  69. package/dist/esm/universal/formatWebpack.js +108 -0
  70. package/dist/esm/universal/nestedRoutes.js +174 -0
  71. package/dist/esm/universal/remixRouter.js +1 -0
  72. package/dist/esm/universal/serialize.js +7 -0
  73. package/dist/esm/version.js +193 -0
  74. package/dist/esm/wait.js +7 -0
  75. package/dist/esm/watch.js +230 -0
  76. package/dist/esm-node/FileSizeReporter.js +133 -0
  77. package/dist/esm-node/alias.js +61 -0
  78. package/dist/esm-node/analyzeProject.js +17 -0
  79. package/dist/esm-node/applyOptionsChain.js +35 -0
  80. package/dist/esm-node/babel.js +105 -0
  81. package/dist/esm-node/chainId.js +173 -0
  82. package/dist/esm-node/clearConsole.js +8 -0
  83. package/dist/esm-node/commands.js +22 -0
  84. package/dist/esm-node/compatRequire.js +42 -0
  85. package/dist/esm-node/compiled.js +77 -0
  86. package/dist/esm-node/constants.js +264 -0
  87. package/dist/esm-node/debug.js +5 -0
  88. package/dist/esm-node/emptyDir.js +9 -0
  89. package/dist/esm-node/ensureAbsolutePath.js +5 -0
  90. package/dist/esm-node/ensureArray.js +9 -0
  91. package/dist/esm-node/findExists.js +12 -0
  92. package/dist/esm-node/generateMetaTags.js +38 -0
  93. package/dist/esm-node/getBrowserslist.js +7 -0
  94. package/dist/esm-node/getCoreJsVersion.js +13 -0
  95. package/dist/esm-node/getEntryOptions.js +17 -0
  96. package/dist/esm-node/getPackageManager.js +32 -0
  97. package/dist/esm-node/getPort.js +59 -0
  98. package/dist/esm-node/getServerConfig.js +14 -0
  99. package/dist/esm-node/getTargetDir.js +8 -0
  100. package/dist/esm-node/import.js +9 -0
  101. package/dist/esm-node/index.js +44 -0
  102. package/dist/esm-node/is/index.js +71 -0
  103. package/dist/esm-node/is/nodeEnv.js +12 -0
  104. package/dist/esm-node/is/platform.js +6 -0
  105. package/dist/esm-node/is/type.js +34 -0
  106. package/dist/esm-node/logger.js +100 -0
  107. package/dist/esm-node/monorepo.js +87 -0
  108. package/dist/esm-node/nodeEnv.js +30 -0
  109. package/dist/esm-node/path.js +50 -0
  110. package/dist/esm-node/pathSerializer.js +46 -0
  111. package/dist/esm-node/plugin.js +23 -0
  112. package/dist/esm-node/prettyInstructions.js +77 -0
  113. package/dist/esm-node/printBuildError.js +34 -0
  114. package/dist/esm-node/react.js +20 -0
  115. package/dist/esm-node/readTsConfig.js +13 -0
  116. package/dist/esm-node/removeSlash.js +8 -0
  117. package/dist/esm-node/resolve.js +38 -0
  118. package/dist/esm-node/routes.js +24 -0
  119. package/dist/esm-node/runtimeExports.js +40 -0
  120. package/dist/esm-node/ssr.js +6 -0
  121. package/dist/esm-node/storage.js +42 -0
  122. package/dist/esm-node/testUtils.js +15 -0
  123. package/dist/esm-node/types.js +0 -0
  124. package/dist/esm-node/universal/constants.js +6 -0
  125. package/dist/esm-node/universal/formatWebpack.js +77 -0
  126. package/dist/esm-node/universal/nestedRoutes.js +93 -0
  127. package/dist/esm-node/universal/remixRouter.js +1 -0
  128. package/dist/esm-node/universal/serialize.js +7 -0
  129. package/dist/esm-node/version.js +25 -0
  130. package/dist/esm-node/wait.js +6 -0
  131. package/dist/esm-node/watch.js +36 -0
  132. package/package.json +2 -2
  133. package/dist/emptyDir.js +0 -52
  134. package/dist/nodeEnv.js +0 -81
  135. package/dist/version.js +0 -92
  136. /package/dist/{FileSizeReporter.js → cjs/FileSizeReporter.js} +0 -0
  137. /package/dist/{applyOptionsChain.js → cjs/applyOptionsChain.js} +0 -0
  138. /package/dist/{chainId.js → cjs/chainId.js} +0 -0
  139. /package/dist/{clearConsole.js → cjs/clearConsole.js} +0 -0
  140. /package/dist/{commands.js → cjs/commands.js} +0 -0
  141. /package/dist/{compiled.js → cjs/compiled.js} +0 -0
  142. /package/dist/{constants.js → cjs/constants.js} +0 -0
  143. /package/dist/{debug.js → cjs/debug.js} +0 -0
  144. /package/dist/{ensureAbsolutePath.js → cjs/ensureAbsolutePath.js} +0 -0
  145. /package/dist/{ensureArray.js → cjs/ensureArray.js} +0 -0
  146. /package/dist/{findExists.js → cjs/findExists.js} +0 -0
  147. /package/dist/{generateMetaTags.js → cjs/generateMetaTags.js} +0 -0
  148. /package/dist/{getBrowserslist.js → cjs/getBrowserslist.js} +0 -0
  149. /package/dist/{getCoreJsVersion.js → cjs/getCoreJsVersion.js} +0 -0
  150. /package/dist/{getTargetDir.js → cjs/getTargetDir.js} +0 -0
  151. /package/dist/{import.js → cjs/import.js} +0 -0
  152. /package/dist/{index.js → cjs/index.js} +0 -0
  153. /package/dist/{is → cjs/is}/index.js +0 -0
  154. /package/dist/{is → cjs/is}/nodeEnv.js +0 -0
  155. /package/dist/{is → cjs/is}/platform.js +0 -0
  156. /package/dist/{is → cjs/is}/type.js +0 -0
  157. /package/dist/{plugin.js → cjs/plugin.js} +0 -0
  158. /package/dist/{prettyInstructions.js → cjs/prettyInstructions.js} +0 -0
  159. /package/dist/{printBuildError.js → cjs/printBuildError.js} +0 -0
  160. /package/dist/{readTsConfig.js → cjs/readTsConfig.js} +0 -0
  161. /package/dist/{removeSlash.js → cjs/removeSlash.js} +0 -0
  162. /package/dist/{resolve.js → cjs/resolve.js} +0 -0
  163. /package/dist/{routes.js → cjs/routes.js} +0 -0
  164. /package/dist/{ssr.js → cjs/ssr.js} +0 -0
  165. /package/dist/{storage.js → cjs/storage.js} +0 -0
  166. /package/dist/{testUtils.js → cjs/testUtils.js} +0 -0
  167. /package/dist/{types.js → cjs/types.js} +0 -0
  168. /package/dist/{universal → cjs/universal}/constants.js +0 -0
  169. /package/dist/{universal → cjs/universal}/formatWebpack.js +0 -0
  170. /package/dist/{universal → cjs/universal}/remixRouter.js +0 -0
  171. /package/dist/{universal → cjs/universal}/serialize.js +0 -0
  172. /package/dist/{wait.js → cjs/wait.js} +0 -0
  173. /package/dist/{FileSizeReporter.d.ts → types/FileSizeReporter.d.ts} +0 -0
  174. /package/dist/{alias.d.ts → types/alias.d.ts} +0 -0
  175. /package/dist/{analyzeProject.d.ts → types/analyzeProject.d.ts} +0 -0
  176. /package/dist/{applyOptionsChain.d.ts → types/applyOptionsChain.d.ts} +0 -0
  177. /package/dist/{babel.d.ts → types/babel.d.ts} +0 -0
  178. /package/dist/{chainId.d.ts → types/chainId.d.ts} +0 -0
  179. /package/dist/{clearConsole.d.ts → types/clearConsole.d.ts} +0 -0
  180. /package/dist/{commands.d.ts → types/commands.d.ts} +0 -0
  181. /package/dist/{compatRequire.d.ts → types/compatRequire.d.ts} +0 -0
  182. /package/dist/{compiled.d.ts → types/compiled.d.ts} +0 -0
  183. /package/dist/{constants.d.ts → types/constants.d.ts} +0 -0
  184. /package/dist/{debug.d.ts → types/debug.d.ts} +0 -0
  185. /package/dist/{emptyDir.d.ts → types/emptyDir.d.ts} +0 -0
  186. /package/dist/{ensureAbsolutePath.d.ts → types/ensureAbsolutePath.d.ts} +0 -0
  187. /package/dist/{ensureArray.d.ts → types/ensureArray.d.ts} +0 -0
  188. /package/dist/{findExists.d.ts → types/findExists.d.ts} +0 -0
  189. /package/dist/{generateMetaTags.d.ts → types/generateMetaTags.d.ts} +0 -0
  190. /package/dist/{getBrowserslist.d.ts → types/getBrowserslist.d.ts} +0 -0
  191. /package/dist/{getCoreJsVersion.d.ts → types/getCoreJsVersion.d.ts} +0 -0
  192. /package/dist/{getEntryOptions.d.ts → types/getEntryOptions.d.ts} +0 -0
  193. /package/dist/{getPackageManager.d.ts → types/getPackageManager.d.ts} +0 -0
  194. /package/dist/{getPort.d.ts → types/getPort.d.ts} +0 -0
  195. /package/dist/{getServerConfig.d.ts → types/getServerConfig.d.ts} +0 -0
  196. /package/dist/{getTargetDir.d.ts → types/getTargetDir.d.ts} +0 -0
  197. /package/dist/{import.d.ts → types/import.d.ts} +0 -0
  198. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  199. /package/dist/{is → types/is}/index.d.ts +0 -0
  200. /package/dist/{is → types/is}/nodeEnv.d.ts +0 -0
  201. /package/dist/{is → types/is}/platform.d.ts +0 -0
  202. /package/dist/{is → types/is}/type.d.ts +0 -0
  203. /package/dist/{logger.d.ts → types/logger.d.ts} +0 -0
  204. /package/dist/{monorepo.d.ts → types/monorepo.d.ts} +0 -0
  205. /package/dist/{nodeEnv.d.ts → types/nodeEnv.d.ts} +0 -0
  206. /package/dist/{path.d.ts → types/path.d.ts} +0 -0
  207. /package/dist/{pathSerializer.d.ts → types/pathSerializer.d.ts} +0 -0
  208. /package/dist/{plugin.d.ts → types/plugin.d.ts} +0 -0
  209. /package/dist/{prettyInstructions.d.ts → types/prettyInstructions.d.ts} +0 -0
  210. /package/dist/{printBuildError.d.ts → types/printBuildError.d.ts} +0 -0
  211. /package/dist/{react.d.ts → types/react.d.ts} +0 -0
  212. /package/dist/{readTsConfig.d.ts → types/readTsConfig.d.ts} +0 -0
  213. /package/dist/{removeSlash.d.ts → types/removeSlash.d.ts} +0 -0
  214. /package/dist/{resolve.d.ts → types/resolve.d.ts} +0 -0
  215. /package/dist/{routes.d.ts → types/routes.d.ts} +0 -0
  216. /package/dist/{runtimeExports.d.ts → types/runtimeExports.d.ts} +0 -0
  217. /package/dist/{ssr.d.ts → types/ssr.d.ts} +0 -0
  218. /package/dist/{storage.d.ts → types/storage.d.ts} +0 -0
  219. /package/dist/{testUtils.d.ts → types/testUtils.d.ts} +0 -0
  220. /package/dist/{types.d.ts → types/types.d.ts} +0 -0
  221. /package/dist/{universal → types/universal}/constants.d.ts +0 -0
  222. /package/dist/{universal → types/universal}/formatWebpack.d.ts +0 -0
  223. /package/dist/{universal → types/universal}/nestedRoutes.d.ts +0 -0
  224. /package/dist/{universal → types/universal}/remixRouter.d.ts +0 -0
  225. /package/dist/{universal → types/universal}/serialize.d.ts +0 -0
  226. /package/dist/{version.d.ts → types/version.d.ts} +0 -0
  227. /package/dist/{wait.d.ts → types/wait.d.ts} +0 -0
  228. /package/dist/{watch.d.ts → types/watch.d.ts} +0 -0
@@ -0,0 +1,85 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import path from "path";
27
+ import os from "os";
28
+ import fs from "fs";
29
+ import { nanoid, upath, lodash as _ } from "./compiled";
30
+ var isPathString = function(test) {
31
+ return path.posix.basename(test) !== test || path.win32.basename(test) !== test;
32
+ };
33
+ var isRelativePath = function(test) {
34
+ return /^\.\.?($|[\\/])/.test(test);
35
+ };
36
+ var normalizeOutputPath = function(s) {
37
+ return s.replace(/\\/g, "\\\\");
38
+ };
39
+ var normalizeToPosixPath = function(p) {
40
+ return upath.normalizeSafe(path.normalize(p || "")).replace(/^([a-zA-Z]+):/, function(_2, m) {
41
+ return "/".concat(m.toLowerCase());
42
+ });
43
+ };
44
+ var getTemplatePath = function(prefix) {
45
+ var _path;
46
+ var tmpRoot = fs.realpathSync(os.tmpdir());
47
+ var parts = [
48
+ tmpRoot
49
+ ];
50
+ prefix && parts.push(prefix);
51
+ parts.push(nanoid());
52
+ return (_path = path).resolve.apply(_path, _toConsumableArray(parts));
53
+ };
54
+ function compilePathMatcherRegExp(match) {
55
+ if (typeof match !== "string") {
56
+ return match;
57
+ }
58
+ var escaped = _.escapeRegExp(match);
59
+ return new RegExp("(?<=\\W|^)".concat(escaped, "(?=\\W|$)"));
60
+ }
61
+ var _joinPathParts = function(_part, i, parts) {
62
+ return _(parts).filter(function(part) {
63
+ return ![
64
+ "/",
65
+ "\\"
66
+ ].includes(part);
67
+ }).tap(function(parts2) {
68
+ return parts2.unshift("");
69
+ }).slice(0, i + 2).join("/");
70
+ };
71
+ function upwardPaths(start) {
72
+ return _(start).split(/[/\\]/).filter(Boolean).map(_joinPathParts).reverse().push("/").value();
73
+ }
74
+ function getRealTemporaryDirectory() {
75
+ var ret = null;
76
+ try {
77
+ ret = os.tmpdir();
78
+ ret = fs.realpathSync(ret);
79
+ } catch (e) {}
80
+ return ret;
81
+ }
82
+ function splitPathString(str) {
83
+ return str.split(/[\\/]/);
84
+ }
85
+ export { _joinPathParts, compilePathMatcherRegExp, getRealTemporaryDirectory, getTemplatePath, isPathString, isRelativePath, normalizeOutputPath, normalizeToPosixPath, splitPathString, upwardPaths };
@@ -0,0 +1,85 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import os from "os";
27
+ import _ from "../compiled/lodash";
28
+ import { compilePathMatcherRegExp, normalizeToPosixPath, getRealTemporaryDirectory, splitPathString, upwardPaths } from "./path";
29
+ var matchUpwardPathsAsUnknown = function(p) {
30
+ return _(upwardPaths(normalizeToPosixPath(p))).map(function(match) {
31
+ return {
32
+ match: match,
33
+ mark: "unknown"
34
+ };
35
+ }).slice(1, -1).value();
36
+ };
37
+ function applyPathMatcher(matcher, str) {
38
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
39
+ var regex = compilePathMatcherRegExp(matcher.match);
40
+ var replacer = function(substring) {
41
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
42
+ args[_key - 1] = arguments[_key];
43
+ }
44
+ var _matcher;
45
+ if (options.minPartials && splitPathString(substring).length < options.minPartials) {
46
+ return substring;
47
+ }
48
+ var ret = typeof matcher.mark === "string" ? matcher.mark : (_matcher = matcher).mark.apply(_matcher, [
49
+ substring
50
+ ].concat(_toConsumableArray(args)));
51
+ return "<".concat(_.snakeCase(ret).toUpperCase(), ">");
52
+ };
53
+ return str.replace(regex, replacer);
54
+ }
55
+ function applyMatcherReplacement(matchers, str) {
56
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
57
+ return matchers.reduce(function(ret, matcher) {
58
+ return applyPathMatcher(matcher, ret, options);
59
+ }, str);
60
+ }
61
+ var createDefaultPathMatchers = function(root) {
62
+ var _ret;
63
+ var ret = [
64
+ {
65
+ match: RegExp("(?<=\\/)(\\.pnpm\\/.+?\\/node_modules)(?=\\/)"),
66
+ mark: "pnpmInner"
67
+ }
68
+ ];
69
+ var tmpdir = getRealTemporaryDirectory();
70
+ tmpdir && ret.push({
71
+ match: tmpdir,
72
+ mark: "temp"
73
+ });
74
+ ret.push({
75
+ match: os.tmpdir(),
76
+ mark: "temp"
77
+ });
78
+ ret.push({
79
+ match: os.homedir(),
80
+ mark: "home"
81
+ });
82
+ (_ret = ret).push.apply(_ret, _toConsumableArray(matchUpwardPathsAsUnknown(root)));
83
+ return ret;
84
+ };
85
+ export { applyMatcherReplacement, applyPathMatcher, createDefaultPathMatchers, matchUpwardPathsAsUnknown };
@@ -0,0 +1,45 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import { INTERNAL_CLI_PLUGINS } from "./constants";
27
+ import { isDepExists } from "./is";
28
+ function getInternalPlugins(appDirectory) {
29
+ var internalPlugins = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : INTERNAL_CLI_PLUGINS;
30
+ return _toConsumableArray(Object.keys(internalPlugins).filter(function(name) {
31
+ var config = internalPlugins[name];
32
+ if (typeof config !== "string" && config.forced === true) {
33
+ return true;
34
+ }
35
+ return isDepExists(appDirectory, name);
36
+ }).map(function(name) {
37
+ var config = internalPlugins[name];
38
+ if (typeof config !== "string") {
39
+ return config.path;
40
+ } else {
41
+ return config;
42
+ }
43
+ }));
44
+ }
45
+ export { getInternalPlugins };
@@ -0,0 +1,96 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import os from "os";
27
+ import { chalk } from "./compiled";
28
+ import { isDev, isSingleEntry } from "./is";
29
+ var normalizeUrl = function(url) {
30
+ return url.replace(/([^:]\/)\/+/g, "$1");
31
+ };
32
+ var getIpv4Interfaces = function() {
33
+ var interfaces = os.networkInterfaces();
34
+ var ipv4Interfaces = [];
35
+ Object.keys(interfaces).forEach(function(key) {
36
+ interfaces[key].forEach(function(detail) {
37
+ var familyV4Value = typeof detail.family === "string" ? "IPv4" : 4;
38
+ if (detail.family === familyV4Value) {
39
+ ipv4Interfaces.push(detail);
40
+ }
41
+ });
42
+ });
43
+ return ipv4Interfaces;
44
+ };
45
+ var getAddressUrls = function() {
46
+ var protocol = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "http", port = arguments.length > 1 ? arguments[1] : void 0;
47
+ var ipv4Interfaces = getIpv4Interfaces();
48
+ return ipv4Interfaces.reduce(function(memo, detail) {
49
+ var label = "Network: ";
50
+ var url = "".concat(protocol, "://").concat(detail.address, ":").concat(port);
51
+ if (detail.address.includes("localhost") || detail.internal) {
52
+ label = "Local: ";
53
+ url = "".concat(protocol, "://localhost:").concat(port);
54
+ }
55
+ memo.push({
56
+ label: label,
57
+ url: url
58
+ });
59
+ return memo;
60
+ }, []);
61
+ };
62
+ var prettyInstructions = function(appContext, config) {
63
+ var entrypoints = appContext.entrypoints, serverRoutes = appContext.serverRoutes, port = appContext.port, apiOnly = appContext.apiOnly, checkedEntries = appContext.checkedEntries;
64
+ var urls = getAddressUrls(config.dev.https && isDev() ? "https" : "http", port);
65
+ var routes = !apiOnly ? serverRoutes.filter(function(route) {
66
+ return route.entryName;
67
+ }) : serverRoutes;
68
+ var message = "App running at:\n\n";
69
+ if (isSingleEntry(entrypoints) || apiOnly) {
70
+ message += urls.map(function(param) {
71
+ var label = param.label, url = param.url;
72
+ return " ".concat(chalk.bold("> ".concat(label.padEnd(10)))).concat(chalk.cyanBright(normalizeUrl("".concat(url, "/").concat(routes[0].urlPath))), "\n");
73
+ }).join("");
74
+ } else {
75
+ var _Math;
76
+ var maxNameLength = (_Math = Math).max.apply(_Math, _toConsumableArray(routes.map(function(r) {
77
+ return r.entryName.length;
78
+ })));
79
+ urls.forEach(function(param) {
80
+ var label = param.label, url = param.url;
81
+ message += " ".concat(chalk.bold("> ".concat(label)), "\n");
82
+ routes.forEach(function(param) {
83
+ var entryName = param.entryName, urlPath = param.urlPath, isSSR = param.isSSR;
84
+ if (!checkedEntries.includes(entryName)) {
85
+ return;
86
+ }
87
+ message += " ".concat(chalk.yellowBright(isSSR ? "λ" : "○"), " ").concat(chalk.yellowBright(entryName.padEnd(maxNameLength + 8))).concat(chalk.cyanBright(normalizeUrl("".concat(url, "/").concat(urlPath))), "\n");
88
+ });
89
+ });
90
+ message += "\n";
91
+ message += chalk.cyanBright(" λ (Server) server-side renders at runtime\n");
92
+ message += chalk.cyanBright(" ○ (Static) client-side renders as static HTML\n");
93
+ }
94
+ return message;
95
+ };
96
+ export { getAddressUrls, getIpv4Interfaces, prettyInstructions };
@@ -0,0 +1,24 @@
1
+ import { chalk } from "./compiled";
2
+ import { logger } from "./logger";
3
+ function printBuildError(err) {
4
+ var message = err != null && err.message;
5
+ var stack = err != null && err.stack;
6
+ if (stack && typeof message === "string" && message.indexOf("from Terser") !== -1) {
7
+ try {
8
+ var matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);
9
+ if (!matched) {
10
+ throw new Error("Using errors for control flow is bad.");
11
+ }
12
+ var problemPath = matched[2];
13
+ var line = matched[3];
14
+ var column = matched[4];
15
+ logger.error("Failed to minify the code from this file: \n\n ".concat(chalk.yellow(" ".concat(problemPath, ":").concat(line).concat(column !== "0" ? ":" + column : "")), "\n"));
16
+ } catch (ignored) {
17
+ logger.error("Failed to minify the bundle. ".concat(err, "\n"));
18
+ }
19
+ } else {
20
+ logger.error((message || err) + "\n");
21
+ }
22
+ logger.log();
23
+ }
24
+ export { printBuildError };
@@ -0,0 +1,43 @@
1
+ function _defineProperty(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _objectSpread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _defineProperty(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ import path from "path";
30
+ import { fs, semver } from ".";
31
+ var isBeyondReact17 = function(cwd) {
32
+ var pkgPath = path.join(cwd, "package.json");
33
+ if (!fs.existsSync(pkgPath)) {
34
+ return false;
35
+ }
36
+ var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
37
+ var deps = _objectSpread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
38
+ if (typeof deps.react !== "string") {
39
+ return false;
40
+ }
41
+ return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
42
+ };
43
+ export { isBeyondReact17 };
@@ -0,0 +1,10 @@
1
+ import path from "path";
2
+ import { fs, json5 } from "./compiled";
3
+ var readTsConfig = function(root) {
4
+ return readTsConfigByFile(path.resolve(root, "./tsconfig.json"));
5
+ };
6
+ var readTsConfigByFile = function(filename) {
7
+ var content = fs.readFileSync(path.resolve(filename), "utf-8");
8
+ return json5.parse(content);
9
+ };
10
+ export { readTsConfig, readTsConfigByFile };
@@ -0,0 +1,10 @@
1
+ var removeLeadingSlash = function(s) {
2
+ return s.replace(/^\/+/, "");
3
+ };
4
+ var removeTailSlash = function(s) {
5
+ return s.replace(/\/+$/, "");
6
+ };
7
+ var removeSlash = function(s) {
8
+ return removeLeadingSlash(removeTailSlash(s));
9
+ };
10
+ export { removeLeadingSlash, removeSlash, removeTailSlash };
@@ -0,0 +1,42 @@
1
+ import { ensureArray } from "./ensureArray";
2
+ var tryResolve = function(name, resolvePath) {
3
+ var filePath = "";
4
+ try {
5
+ filePath = require.resolve(name, {
6
+ paths: [
7
+ resolvePath
8
+ ]
9
+ });
10
+ delete require.cache[filePath];
11
+ } catch (err) {
12
+ if (err.code === "MODULE_NOT_FOUND") {
13
+ throw new Error("Can not find module ".concat(name, "."));
14
+ }
15
+ throw err;
16
+ }
17
+ return filePath;
18
+ };
19
+ var isPackageInstalled = function(name, resolvePaths) {
20
+ try {
21
+ require.resolve(name, {
22
+ paths: ensureArray(resolvePaths)
23
+ });
24
+ return true;
25
+ } catch (err) {
26
+ return false;
27
+ }
28
+ };
29
+ var getAntdMajorVersion = function(appDirectory) {
30
+ try {
31
+ var pkgJsonPath = require.resolve("antd/package.json", {
32
+ paths: [
33
+ appDirectory
34
+ ]
35
+ });
36
+ var version = require(pkgJsonPath).version;
37
+ return Number(version.split(".")[0]);
38
+ } catch (err) {
39
+ return null;
40
+ }
41
+ };
42
+ export { getAntdMajorVersion, isPackageInstalled, tryResolve };
@@ -0,0 +1,19 @@
1
+ import path from "path";
2
+ import { normalizeToPosixPath } from "./path";
3
+ import { MAIN_ENTRY_NAME } from "./constants";
4
+ var getPathWithoutExt = function(filename) {
5
+ var extname = path.extname(filename);
6
+ return filename.slice(0, -extname.length);
7
+ };
8
+ var getRouteId = function(componentPath, routesDir, entryName) {
9
+ var relativePath = normalizeToPosixPath(path.relative(routesDir, componentPath));
10
+ var pathWithoutExt = getPathWithoutExt(relativePath);
11
+ var id = "";
12
+ if (entryName === MAIN_ENTRY_NAME) {
13
+ id = pathWithoutExt;
14
+ } else {
15
+ id = "".concat(entryName, "_").concat(pathWithoutExt);
16
+ }
17
+ return id;
18
+ };
19
+ export { getPathWithoutExt, getRouteId };
@@ -0,0 +1,65 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import path from "path";
27
+ import { fs } from "./compiled";
28
+ import { normalizeOutputPath } from "./path";
29
+ var memo = function(fn) {
30
+ var cache = /* @__PURE__ */ new Map();
31
+ return function() {
32
+ for(var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++){
33
+ params[_key] = arguments[_key];
34
+ }
35
+ var stringifiedParams = JSON.stringify(params);
36
+ var cachedResult = cache.get(stringifiedParams);
37
+ if (cachedResult) {
38
+ return cachedResult;
39
+ }
40
+ var res = fn.apply(void 0, _toConsumableArray(params));
41
+ cache.set(stringifiedParams, res);
42
+ return res;
43
+ };
44
+ };
45
+ var createRuntimeExportsUtils = memo(function() {
46
+ var pwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "index";
47
+ var entryExportFile = path.join(pwd, ".runtime-exports/".concat(namespace, ".js"));
48
+ var addExport = function(statement) {
49
+ statement = normalizeOutputPath(statement);
50
+ try {
51
+ fs.ensureFileSync(entryExportFile);
52
+ if (!fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
53
+ fs.appendFileSync(entryExportFile, "".concat(statement, "\n"));
54
+ }
55
+ } catch (e) {}
56
+ };
57
+ var getPath = function() {
58
+ return entryExportFile;
59
+ };
60
+ return {
61
+ addExport: addExport,
62
+ getPath: getPath
63
+ };
64
+ });
65
+ export { createRuntimeExportsUtils };
@@ -0,0 +1,3 @@
1
+ import { createStorage } from "./storage";
2
+ var _createStorage = createStorage(), run = _createStorage.run, useHeaders = _createStorage.useContext;
3
+ export { run, useHeaders };
@@ -0,0 +1,36 @@
1
+ import * as ah from "async_hooks";
2
+ var createStorage = function() {
3
+ var storage;
4
+ if (typeof ah.AsyncLocalStorage !== "undefined") {
5
+ storage = new ah.AsyncLocalStorage();
6
+ }
7
+ var run = function(context, cb) {
8
+ if (!storage) {
9
+ throw new Error("Unable to use async_hook, please confirm the node version >= 12.17\n ");
10
+ }
11
+ return new Promise(function(resolve, reject) {
12
+ storage.run(context, function() {
13
+ try {
14
+ return resolve(cb());
15
+ } catch (error) {
16
+ return reject(error);
17
+ }
18
+ });
19
+ });
20
+ };
21
+ var useContext = function() {
22
+ if (!storage) {
23
+ throw new Error("Unable to use async_hook, please confirm the node version >= 12.17\n ");
24
+ }
25
+ var context = storage.getStore();
26
+ if (!context) {
27
+ throw new Error("Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules");
28
+ }
29
+ return context;
30
+ };
31
+ return {
32
+ run: run,
33
+ useContext: useContext
34
+ };
35
+ };
36
+ export { createStorage };
@@ -0,0 +1,13 @@
1
+ var initSnapshotSerializer = function(root) {
2
+ expect.addSnapshotSerializer({
3
+ test: function(val) {
4
+ return typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root));
5
+ },
6
+ print: function(val) {
7
+ return(// eslint-disable-next-line no-nested-ternary
8
+ typeof val === "string" ? // eslint-disable-next-line no-nested-ternary
9
+ val.includes("node_modules") ? '"'.concat(val.replace(/.+node_modules/, "").replace(/\\/g, "/"), '"') : val.includes("modern.js") ? '"'.concat(val.replace(/.+modern\.js/, "").replace(/\\/g, "/"), '"') : '"'.concat(val.replace(root, "").replace(/\\/g, "/"), '"') : val);
10
+ }
11
+ });
12
+ };
13
+ export { initSnapshotSerializer };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,3 @@
1
+ var ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
2
+ var HMR_SOCK_PATH = "/webpack-hmr";
3
+ export { HMR_SOCK_PATH, ROUTE_MANIFEST };