@modern-js/utils 2.18.0 → 2.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/cjs/{alias.js → cli/alias.js} +3 -3
  3. package/dist/cjs/{applyOptionsChain.js → cli/applyOptionsChain.js} +6 -5
  4. package/dist/cjs/{babel.js → cli/babel.js} +3 -3
  5. package/dist/cjs/cli/common.js +26 -0
  6. package/dist/cjs/{constants.js → cli/constants/index.js} +14 -2
  7. package/dist/cjs/{readTsConfig.js → cli/ensure.js} +10 -9
  8. package/dist/cjs/cli/fs.js +29 -0
  9. package/dist/cjs/{getEntryOptions.js → cli/get/config.js} +2 -2
  10. package/dist/cjs/cli/get/data.js +112 -0
  11. package/dist/cjs/cli/get/index.js +46 -0
  12. package/dist/cjs/cli/index.js +41 -0
  13. package/dist/cjs/{is/index.js → cli/is/config.js} +2 -43
  14. package/dist/cjs/{is/nodeEnv.js → cli/is/env.js} +3 -1
  15. package/dist/cjs/cli/is/index.js +22 -0
  16. package/dist/cjs/cli/is/project.js +92 -0
  17. package/dist/cjs/{is → cli/is}/type.js +3 -1
  18. package/dist/cjs/{logger.js → cli/logger.js} +1 -1
  19. package/dist/cjs/{monorepo.js → cli/monorepo.js} +1 -1
  20. package/dist/cjs/{nodeEnv.js → cli/package.js} +8 -1
  21. package/dist/cjs/{path.js → cli/path.js} +8 -2
  22. package/dist/cjs/{pathSerializer.js → cli/pathSerializer.js} +1 -1
  23. package/dist/cjs/{getPort.js → cli/port.js} +1 -1
  24. package/dist/cjs/{prettyInstructions.js → cli/prettyInstructions.js} +1 -2
  25. package/dist/cjs/{printBuildError.js → cli/print.js} +1 -1
  26. package/dist/cjs/{compatRequire.js → cli/require.js} +21 -3
  27. package/dist/cjs/{routes.js → cli/routes.js} +4 -11
  28. package/dist/cjs/{runtimeExports.js → cli/runtimeExports.js} +1 -1
  29. package/dist/cjs/cli/watch.js +61 -0
  30. package/dist/cjs/index.js +1 -42
  31. package/dist/cjs/runtime/router.js +19 -0
  32. package/dist/cjs/{ssr.js → runtime-node/index.js} +3 -1
  33. package/dist/esm/{alias.js → cli/alias.js} +2 -2
  34. package/dist/esm/{applyOptionsChain.js → cli/applyOptionsChain.js} +2 -1
  35. package/dist/esm/{babel.js → cli/babel.js} +1 -1
  36. package/dist/esm/cli/common.js +10 -0
  37. package/dist/esm/{constants.js → cli/constants/index.js} +1 -1
  38. package/dist/esm/{ensureAbsolutePath.js → cli/ensure.js} +8 -0
  39. package/dist/esm/{findExists.js → cli/fs.js} +6 -1
  40. package/dist/esm/{getEntryOptions.js → cli/get/config.js} +2 -2
  41. package/dist/esm/cli/get/data.js +86 -0
  42. package/dist/esm/cli/get/index.js +13 -0
  43. package/dist/esm/cli/index.js +24 -0
  44. package/dist/esm/{is/index.js → cli/is/config.js} +1 -21
  45. package/dist/esm/{is/nodeEnv.js → cli/is/env.js} +1 -0
  46. package/dist/esm/cli/is/index.js +5 -0
  47. package/dist/esm/cli/is/project.js +67 -0
  48. package/dist/esm/{is → cli/is}/type.js +1 -0
  49. package/dist/esm/{logger.js → cli/logger.js} +1 -1
  50. package/dist/esm/{monorepo.js → cli/monorepo.js} +1 -1
  51. package/dist/esm/{nodeEnv.js → cli/package.js} +7 -1
  52. package/dist/esm/{path.js → cli/path.js} +4 -1
  53. package/dist/esm/{pathSerializer.js → cli/pathSerializer.js} +1 -1
  54. package/dist/esm/{getPort.js → cli/port.js} +1 -1
  55. package/dist/esm/{prettyInstructions.js → cli/prettyInstructions.js} +2 -2
  56. package/dist/esm/{printBuildError.js → cli/print.js} +1 -1
  57. package/dist/esm/{compatRequire.js → cli/require.js} +18 -1
  58. package/dist/esm/{routes.js → cli/routes.js} +2 -2
  59. package/dist/esm/{runtimeExports.js → cli/runtimeExports.js} +1 -1
  60. package/dist/esm/{watch.js → cli/watch.js} +2 -2
  61. package/dist/esm/index.js +1 -42
  62. package/dist/esm/runtime/router.js +2 -0
  63. package/dist/esm/{ssr.js → runtime-node/index.js} +1 -0
  64. package/dist/types/{applyOptionsChain.d.ts → cli/applyOptionsChain.d.ts} +1 -1
  65. package/dist/types/{debug.d.ts → cli/common.d.ts} +3 -1
  66. package/dist/types/{constants.d.ts → cli/constants/index.d.ts} +2 -6
  67. package/dist/types/{ensureAbsolutePath.d.ts → cli/ensure.d.ts} +2 -1
  68. package/dist/types/{findExists.d.ts → cli/fs.d.ts} +2 -1
  69. package/dist/types/cli/get/data.d.ts +9 -0
  70. package/dist/types/cli/get/index.d.ts +4 -0
  71. package/dist/types/cli/index.d.ts +24 -0
  72. package/dist/types/cli/is/config.d.ts +30 -0
  73. package/dist/types/{is/nodeEnv.d.ts → cli/is/env.d.ts} +2 -1
  74. package/dist/types/cli/is/index.d.ts +5 -0
  75. package/dist/types/cli/is/project.d.ts +25 -0
  76. package/dist/types/{is → cli/is}/type.d.ts +9 -1
  77. package/dist/types/{logger.d.ts → cli/logger.d.ts} +1 -1
  78. package/dist/types/cli/package.d.ts +4 -0
  79. package/dist/types/{path.d.ts → cli/path.d.ts} +5 -2
  80. package/dist/types/{prettyInstructions.d.ts → cli/prettyInstructions.d.ts} +0 -3
  81. package/dist/types/{compatRequire.d.ts → cli/require.d.ts} +9 -1
  82. package/dist/types/cli/routes.d.ts +1 -0
  83. package/dist/types/{watch.d.ts → cli/watch.d.ts} +1 -1
  84. package/dist/types/index.d.ts +2 -43
  85. package/dist/types/runtime/router.d.ts +2 -0
  86. package/dist/types/{ssr.d.ts → runtime-node/index.d.ts} +2 -1
  87. package/package.json +55 -92
  88. package/dist/cjs/FileSizeReporter.js +0 -139
  89. package/dist/cjs/analyzeProject.js +0 -68
  90. package/dist/cjs/clearConsole.js +0 -13
  91. package/dist/cjs/debug.js +0 -10
  92. package/dist/cjs/emptyDir.js +0 -14
  93. package/dist/cjs/ensureAbsolutePath.js +0 -15
  94. package/dist/cjs/ensureArray.js +0 -16
  95. package/dist/cjs/findExists.js +0 -22
  96. package/dist/cjs/getBrowserslist.js +0 -24
  97. package/dist/cjs/getCoreJsVersion.js +0 -58
  98. package/dist/cjs/getPackageManager.js +0 -42
  99. package/dist/cjs/getServerConfig.js +0 -55
  100. package/dist/cjs/getTargetDir.js +0 -53
  101. package/dist/cjs/plugin.js +0 -28
  102. package/dist/cjs/react.js +0 -30
  103. package/dist/cjs/removeSlash.js +0 -19
  104. package/dist/cjs/resolve.js +0 -57
  105. package/dist/cjs/types.js +0 -4
  106. package/dist/cjs/version.js +0 -43
  107. package/dist/cjs/wait.js +0 -11
  108. package/dist/cjs/watch.js +0 -96
  109. package/dist/esm/FileSizeReporter.js +0 -121
  110. package/dist/esm/analyzeProject.js +0 -13
  111. package/dist/esm/clearConsole.js +0 -5
  112. package/dist/esm/debug.js +0 -2
  113. package/dist/esm/emptyDir.js +0 -6
  114. package/dist/esm/ensureArray.js +0 -8
  115. package/dist/esm/getBrowserslist.js +0 -9
  116. package/dist/esm/getCoreJsVersion.js +0 -10
  117. package/dist/esm/getPackageManager.js +0 -29
  118. package/dist/esm/getServerConfig.js +0 -7
  119. package/dist/esm/getTargetDir.js +0 -5
  120. package/dist/esm/plugin.js +0 -20
  121. package/dist/esm/react.js +0 -17
  122. package/dist/esm/readTsConfig.js +0 -9
  123. package/dist/esm/removeSlash.js +0 -3
  124. package/dist/esm/resolve.js +0 -41
  125. package/dist/esm/types.js +0 -1
  126. package/dist/esm/version.js +0 -23
  127. package/dist/esm/wait.js +0 -4
  128. package/dist/types/FileSizeReporter.d.ts +0 -16
  129. package/dist/types/analyzeProject.d.ts +0 -2
  130. package/dist/types/clearConsole.d.ts +0 -1
  131. package/dist/types/emptyDir.d.ts +0 -1
  132. package/dist/types/ensureArray.d.ts +0 -1
  133. package/dist/types/getBrowserslist.d.ts +0 -2
  134. package/dist/types/getCoreJsVersion.d.ts +0 -1
  135. package/dist/types/getPackageManager.d.ts +0 -1
  136. package/dist/types/getServerConfig.d.ts +0 -1
  137. package/dist/types/getTargetDir.d.ts +0 -1
  138. package/dist/types/is/index.d.ts +0 -58
  139. package/dist/types/nodeEnv.d.ts +0 -3
  140. package/dist/types/plugin.d.ts +0 -2
  141. package/dist/types/react.d.ts +0 -1
  142. package/dist/types/readTsConfig.d.ts +0 -2
  143. package/dist/types/removeSlash.d.ts +0 -3
  144. package/dist/types/resolve.d.ts +0 -13
  145. package/dist/types/routes.d.ts +0 -2
  146. package/dist/types/types.d.ts +0 -1
  147. package/dist/types/version.d.ts +0 -2
  148. package/dist/types/wait.d.ts +0 -2
  149. /package/dist/cjs/{commands.js → cli/commands.js} +0 -0
  150. /package/dist/cjs/{chainId.js → cli/constants/chainId.js} +0 -0
  151. /package/dist/cjs/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
  152. /package/dist/cjs/{is → cli/is}/platform.js +0 -0
  153. /package/dist/cjs/{testUtils.js → cli/test.js} +0 -0
  154. /package/dist/cjs/{universal → runtime}/nestedRoutes.js +0 -0
  155. /package/dist/cjs/{universal → runtime}/remixRouter.js +0 -0
  156. /package/dist/cjs/{runtime → runtime-browser}/index.js +0 -0
  157. /package/dist/cjs/{runtime → runtime-browser}/parsed.js +0 -0
  158. /package/dist/cjs/{universal → runtime-node}/serialize.js +0 -0
  159. /package/dist/cjs/{storage.js → runtime-node/storage.js} +0 -0
  160. /package/dist/esm/{commands.js → cli/commands.js} +0 -0
  161. /package/dist/esm/{chainId.js → cli/constants/chainId.js} +0 -0
  162. /package/dist/esm/{generateMetaTags.js → cli/generateMetaTags.js} +0 -0
  163. /package/dist/esm/{is → cli/is}/platform.js +0 -0
  164. /package/dist/esm/{testUtils.js → cli/test.js} +0 -0
  165. /package/dist/esm/{universal → runtime}/nestedRoutes.js +0 -0
  166. /package/dist/esm/{universal → runtime}/remixRouter.js +0 -0
  167. /package/dist/esm/{runtime → runtime-browser}/index.js +0 -0
  168. /package/dist/esm/{runtime → runtime-browser}/parsed.js +0 -0
  169. /package/dist/esm/{universal → runtime-node}/serialize.js +0 -0
  170. /package/dist/esm/{storage.js → runtime-node/storage.js} +0 -0
  171. /package/dist/types/{alias.d.ts → cli/alias.d.ts} +0 -0
  172. /package/dist/types/{babel.d.ts → cli/babel.d.ts} +0 -0
  173. /package/dist/types/{commands.d.ts → cli/commands.d.ts} +0 -0
  174. /package/dist/types/{chainId.d.ts → cli/constants/chainId.d.ts} +0 -0
  175. /package/dist/types/{generateMetaTags.d.ts → cli/generateMetaTags.d.ts} +0 -0
  176. /package/dist/types/{getEntryOptions.d.ts → cli/get/config.d.ts} +0 -0
  177. /package/dist/types/{is → cli/is}/platform.d.ts +0 -0
  178. /package/dist/types/{monorepo.d.ts → cli/monorepo.d.ts} +0 -0
  179. /package/dist/types/{pathSerializer.d.ts → cli/pathSerializer.d.ts} +0 -0
  180. /package/dist/types/{getPort.d.ts → cli/port.d.ts} +0 -0
  181. /package/dist/types/{printBuildError.d.ts → cli/print.d.ts} +0 -0
  182. /package/dist/types/{runtimeExports.d.ts → cli/runtimeExports.d.ts} +0 -0
  183. /package/dist/types/{testUtils.d.ts → cli/test.d.ts} +0 -0
  184. /package/dist/types/{universal → runtime}/nestedRoutes.d.ts +0 -0
  185. /package/dist/types/{universal → runtime}/remixRouter.d.ts +0 -0
  186. /package/dist/types/{runtime → runtime-browser}/index.d.ts +0 -0
  187. /package/dist/types/{runtime → runtime-browser}/parsed.d.ts +0 -0
  188. /package/dist/types/{universal → runtime-node}/serialize.d.ts +0 -0
  189. /package/dist/types/{storage.d.ts → runtime-node/storage.d.ts} +0 -0
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getServerConfig", {
6
- enumerable: true,
7
- get: () => getServerConfig
8
- });
9
- const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
10
- const _constants = require("./constants");
11
- const _findExists = require("./findExists");
12
- function _getRequireWildcardCache(nodeInterop) {
13
- if (typeof WeakMap !== "function")
14
- return null;
15
- var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
16
- var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
17
- return (_getRequireWildcardCache = function(nodeInterop2) {
18
- return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
19
- })(nodeInterop);
20
- }
21
- function _interop_require_wildcard(obj, nodeInterop) {
22
- if (!nodeInterop && obj && obj.__esModule) {
23
- return obj;
24
- }
25
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
- return {
27
- default: obj
28
- };
29
- }
30
- var cache = _getRequireWildcardCache(nodeInterop);
31
- if (cache && cache.has(obj)) {
32
- return cache.get(obj);
33
- }
34
- var newObj = {};
35
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
36
- for (var key in obj) {
37
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
38
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
39
- if (desc && (desc.get || desc.set)) {
40
- Object.defineProperty(newObj, key, desc);
41
- } else {
42
- newObj[key] = obj[key];
43
- }
44
- }
45
- }
46
- newObj.default = obj;
47
- if (cache) {
48
- cache.set(obj, newObj);
49
- }
50
- return newObj;
51
- }
52
- const getServerConfig = async (appDirectory, configFile) => {
53
- const configFilePath = (0, _findExists.findExists)(_constants.CONFIG_FILE_EXTENSIONS.map((extension) => _path.resolve(appDirectory, `${configFile}${extension}`)));
54
- return configFilePath;
55
- };
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getTargetDir", {
6
- enumerable: true,
7
- get: () => getTargetDir
8
- });
9
- const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
10
- function _getRequireWildcardCache(nodeInterop) {
11
- if (typeof WeakMap !== "function")
12
- return null;
13
- var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
14
- var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
15
- return (_getRequireWildcardCache = function(nodeInterop2) {
16
- return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
17
- })(nodeInterop);
18
- }
19
- function _interop_require_wildcard(obj, nodeInterop) {
20
- if (!nodeInterop && obj && obj.__esModule) {
21
- return obj;
22
- }
23
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
24
- return {
25
- default: obj
26
- };
27
- }
28
- var cache = _getRequireWildcardCache(nodeInterop);
29
- if (cache && cache.has(obj)) {
30
- return cache.get(obj);
31
- }
32
- var newObj = {};
33
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
34
- for (var key in obj) {
35
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
36
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
37
- if (desc && (desc.get || desc.set)) {
38
- Object.defineProperty(newObj, key, desc);
39
- } else {
40
- newObj[key] = obj[key];
41
- }
42
- }
43
- }
44
- newObj.default = obj;
45
- if (cache) {
46
- cache.set(obj, newObj);
47
- }
48
- return newObj;
49
- }
50
- const getTargetDir = (from, baseDir, targetBaseDir) => {
51
- const relativePath = _path.relative(baseDir, from);
52
- return _path.resolve(targetBaseDir, relativePath);
53
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "getInternalPlugins", {
6
- enumerable: true,
7
- get: () => getInternalPlugins
8
- });
9
- const _constants = require("./constants");
10
- const _is = require("./is");
11
- function getInternalPlugins(appDirectory, internalPlugins = _constants.INTERNAL_CLI_PLUGINS) {
12
- return [
13
- ...Object.keys(internalPlugins).filter((name) => {
14
- const config = internalPlugins[name];
15
- if (typeof config !== "string" && config.forced === true) {
16
- return true;
17
- }
18
- return (0, _is.isDepExists)(appDirectory, name);
19
- }).map((name) => {
20
- const config = internalPlugins[name];
21
- if (typeof config !== "string") {
22
- return config.path;
23
- } else {
24
- return config;
25
- }
26
- })
27
- ];
28
- }
package/dist/cjs/react.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "isBeyondReact17", {
6
- enumerable: true,
7
- get: () => isBeyondReact17
8
- });
9
- const _path = /* @__PURE__ */ _interop_require_default(require("path"));
10
- const _ = require(".");
11
- function _interop_require_default(obj) {
12
- return obj && obj.__esModule ? obj : {
13
- default: obj
14
- };
15
- }
16
- const isBeyondReact17 = (cwd) => {
17
- const pkgPath = _path.default.join(cwd, "package.json");
18
- if (!_.fs.existsSync(pkgPath)) {
19
- return false;
20
- }
21
- const pkgInfo = JSON.parse(_.fs.readFileSync(pkgPath, "utf8"));
22
- const deps = {
23
- ...pkgInfo.devDependencies,
24
- ...pkgInfo.dependencies
25
- };
26
- if (typeof deps.react !== "string") {
27
- return false;
28
- }
29
- return _.semver.satisfies(_.semver.minVersion(deps.react), ">=17.0.0");
30
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- removeLeadingSlash: () => removeLeadingSlash,
14
- removeTailSlash: () => removeTailSlash,
15
- removeSlash: () => removeSlash
16
- });
17
- const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
18
- const removeTailSlash = (s) => s.replace(/\/+$/, "");
19
- const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- tryResolve: () => tryResolve,
14
- isPackageInstalled: () => isPackageInstalled,
15
- getAntdMajorVersion: () => getAntdMajorVersion
16
- });
17
- const _ensureArray = require("./ensureArray");
18
- const tryResolve = (name, resolvePath) => {
19
- let filePath = "";
20
- try {
21
- filePath = require.resolve(name, {
22
- paths: [
23
- resolvePath
24
- ]
25
- });
26
- delete require.cache[filePath];
27
- } catch (err) {
28
- if (err.code === "MODULE_NOT_FOUND") {
29
- throw new Error(`Can not find module ${name}.`);
30
- }
31
- throw err;
32
- }
33
- return filePath;
34
- };
35
- const isPackageInstalled = (name, resolvePaths) => {
36
- try {
37
- require.resolve(name, {
38
- paths: (0, _ensureArray.ensureArray)(resolvePaths)
39
- });
40
- return true;
41
- } catch (err) {
42
- return false;
43
- }
44
- };
45
- const getAntdMajorVersion = (appDirectory) => {
46
- try {
47
- const pkgJsonPath = require.resolve("antd/package.json", {
48
- paths: [
49
- appDirectory
50
- ]
51
- });
52
- const { version } = require(pkgJsonPath);
53
- return Number(version.split(".")[0]);
54
- } catch (err) {
55
- return null;
56
- }
57
- };
package/dist/cjs/types.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- getPnpmVersion: () => getPnpmVersion,
14
- isReact18: () => isReact18
15
- });
16
- const _path = /* @__PURE__ */ _interop_require_default(require("path"));
17
- const _compiled = require("./compiled");
18
- function _interop_require_default(obj) {
19
- return obj && obj.__esModule ? obj : {
20
- default: obj
21
- };
22
- }
23
- async function getPnpmVersion() {
24
- const { stdout } = await (0, _compiled.execa)("pnpm", [
25
- "--version"
26
- ]);
27
- return stdout;
28
- }
29
- const isReact18 = (cwd) => {
30
- const pkgPath = _path.default.join(cwd, "package.json");
31
- if (!_compiled.fs.existsSync(pkgPath)) {
32
- return false;
33
- }
34
- const pkgInfo = JSON.parse(_compiled.fs.readFileSync(pkgPath, "utf8"));
35
- const deps = {
36
- ...pkgInfo.devDependencies,
37
- ...pkgInfo.dependencies
38
- };
39
- if (typeof deps.react !== "string") {
40
- return false;
41
- }
42
- return _compiled.semver.satisfies(_compiled.semver.minVersion(deps.react), ">=18.0.0");
43
- };
package/dist/cjs/wait.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "wait", {
6
- enumerable: true,
7
- get: () => wait
8
- });
9
- const wait = (time = 0) => new Promise((resolve) => {
10
- setTimeout(resolve, time);
11
- });
package/dist/cjs/watch.js DELETED
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for (var name in all)
7
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- WatchChangeType: () => WatchChangeType,
14
- watch: () => watch
15
- });
16
- const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
17
- const _compiled = require("./compiled");
18
- function _getRequireWildcardCache(nodeInterop) {
19
- if (typeof WeakMap !== "function")
20
- return null;
21
- var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
22
- var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
23
- return (_getRequireWildcardCache = function(nodeInterop2) {
24
- return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
25
- })(nodeInterop);
26
- }
27
- function _interop_require_wildcard(obj, nodeInterop) {
28
- if (!nodeInterop && obj && obj.__esModule) {
29
- return obj;
30
- }
31
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
32
- return {
33
- default: obj
34
- };
35
- }
36
- var cache = _getRequireWildcardCache(nodeInterop);
37
- if (cache && cache.has(obj)) {
38
- return cache.get(obj);
39
- }
40
- var newObj = {};
41
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
42
- for (var key in obj) {
43
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
44
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
45
- if (desc && (desc.get || desc.set)) {
46
- Object.defineProperty(newObj, key, desc);
47
- } else {
48
- newObj[key] = obj[key];
49
- }
50
- }
51
- }
52
- newObj.default = obj;
53
- if (cache) {
54
- cache.set(obj, newObj);
55
- }
56
- return newObj;
57
- }
58
- const WatchChangeType = {
59
- ADD: "add",
60
- UNLINK: "unlink",
61
- CHANGE: "change"
62
- };
63
- const watch = (watchDir, runTask, ignored = []) => {
64
- let ready = false;
65
- const watcher = _compiled.chokidar.watch(watchDir, {
66
- ignored
67
- });
68
- watcher.on("ready", () => ready = true);
69
- watcher.on("change", async (filePath) => {
70
- const changedFilePath = _path.resolve(filePath);
71
- await runTask({
72
- changedFilePath,
73
- changeType: WatchChangeType.CHANGE
74
- });
75
- });
76
- watcher.on("add", async (filePath) => {
77
- const changedFilePath = _path.resolve(filePath);
78
- if (ready) {
79
- await runTask({
80
- changedFilePath,
81
- changeType: WatchChangeType.ADD
82
- });
83
- }
84
- });
85
- watcher.on("unlink", async (filePath) => {
86
- const changedFilePath = _path.resolve(filePath);
87
- await runTask({
88
- changedFilePath,
89
- changeType: WatchChangeType.UNLINK
90
- });
91
- });
92
- watcher.on("error", (err) => {
93
- throw err;
94
- });
95
- return watcher;
96
- };
@@ -1,121 +0,0 @@
1
- "use strict";
2
- import fs from "fs";
3
- import path from "path";
4
- import { chalk, filesize, stripAnsi, gzipSize, recursiveReaddir } from "./compiled";
5
- import { logger } from "./logger";
6
- function canReadAsset(asset) {
7
- return /\.(js|css)$/.test(asset) && !/service-worker\.js/.test(asset) && !/precache-manifest\.[0-9a-f]+\.js/.test(asset);
8
- }
9
- function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
10
- var root = previousSizeMap.root;
11
- var sizes = previousSizeMap.sizes;
12
- var assets = (webpackStats.stats || [
13
- webpackStats
14
- ]).map((stats) => stats.toJson({
15
- all: false,
16
- assets: true
17
- }).assets.filter((asset) => canReadAsset(asset.name)).map((asset) => {
18
- var fileContents = fs.readFileSync(path.join(root, asset.name));
19
- var size = fileContents.length;
20
- var gzippedSize = gzipSize.sync(fileContents);
21
- var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
22
- var sizeDifference = getDifferenceLabel(size, previousSize);
23
- var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
24
- return {
25
- folder: path.join(path.basename(buildFolder), path.dirname(asset.name)),
26
- name: path.basename(asset.name),
27
- gzippedSize,
28
- sizeLabel: filesize(size) + (sizeDifference ? " (" + sizeDifference + ")" : ""),
29
- gzipSizeLabel: filesize(gzippedSize) + (gzipSizeDifference ? " (" + gzipSizeDifference + ")" : "")
30
- };
31
- })).reduce((single, all) => all.concat(single), []);
32
- assets.sort((a, b) => b.size - a.size);
33
- var longestSizeLabelLength = Math.max.apply(null, assets.map((a) => stripAnsi(a.sizeLabel).length));
34
- var longestFileNameLength = Math.max.apply(null, assets.map((a) => stripAnsi(a.folder + path.sep + a.name).length));
35
- printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
36
- var suggestBundleSplitting = false;
37
- assets.forEach((asset) => {
38
- var { folder, name, sizeLabel, gzipSizeLabel, gzippedSize } = asset;
39
- var fileNameLength = stripAnsi(folder + path.sep + name).length;
40
- var sizeLength = stripAnsi(sizeLabel).length;
41
- if (sizeLength < longestSizeLabelLength) {
42
- var rightPadding = " ".repeat(longestSizeLabelLength - sizeLength);
43
- sizeLabel += rightPadding;
44
- }
45
- var fileNameLabel = chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name);
46
- if (fileNameLength < longestFileNameLength) {
47
- var rightPadding = " ".repeat(longestFileNameLength - fileNameLength);
48
- fileNameLabel += rightPadding;
49
- }
50
- var isMainBundle = asset.name.indexOf("main.") === 0;
51
- var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
52
- var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
53
- if (isLarge && path.extname(asset.name) === ".js") {
54
- suggestBundleSplitting = true;
55
- }
56
- logger.log(" " + fileNameLabel + " " + sizeLabel + " " + (isLarge ? chalk.yellow(gzipSizeLabel) : gzipSizeLabel));
57
- });
58
- if (suggestBundleSplitting) {
59
- logger.log();
60
- logger.warn("The bundle size is significantly larger than recommended.");
61
- }
62
- }
63
- function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
64
- const longestLengths = [
65
- longestFileNameLength,
66
- longestSizeLabelLength
67
- ];
68
- const headerRow = [
69
- "File",
70
- "Size",
71
- "Gzipped"
72
- ].reduce((prev, cur, index) => {
73
- const length = longestLengths[index];
74
- let curLabel = cur;
75
- if (length) {
76
- curLabel = cur.length < length ? cur + " ".repeat(length - cur.length) : cur;
77
- }
78
- return prev + curLabel + " ";
79
- }, " ");
80
- logger.log(chalk.bold(chalk.blue(headerRow)));
81
- }
82
- function removeFileNameHash(buildFolder, fileName) {
83
- return fileName.replace(buildFolder, "").replace(/\\/g, "/").replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
84
- }
85
- function getDifferenceLabel(currentSize, previousSize) {
86
- var FIFTY_KILOBYTES = 1024 * 50;
87
- var difference = currentSize - previousSize;
88
- var fileSize = !Number.isNaN(difference) ? filesize(difference) : 0;
89
- if (difference >= FIFTY_KILOBYTES) {
90
- return chalk.red("+" + fileSize);
91
- } else if (difference < FIFTY_KILOBYTES && difference > 0) {
92
- return chalk.yellow("+" + fileSize);
93
- } else if (difference < 0) {
94
- return chalk.green(fileSize);
95
- } else {
96
- return "";
97
- }
98
- }
99
- function measureFileSizesBeforeBuild(buildFolder) {
100
- return new Promise((resolve) => {
101
- recursiveReaddir(buildFolder, (err, fileNames) => {
102
- var sizes;
103
- if (!err && fileNames) {
104
- sizes = fileNames.filter(canReadAsset).reduce((memo, fileName) => {
105
- var contents = fs.readFileSync(fileName);
106
- var key = removeFileNameHash(buildFolder, fileName);
107
- memo[key] = [
108
- contents.length,
109
- gzipSize.sync(contents)
110
- ];
111
- return memo;
112
- }, {});
113
- }
114
- resolve({
115
- root: buildFolder,
116
- sizes: sizes || {}
117
- });
118
- });
119
- });
120
- }
121
- export { measureFileSizesBeforeBuild, printFileSizesAfterBuild };
@@ -1,13 +0,0 @@
1
- import * as path from "path";
2
- import { getArgv } from "./commands";
3
- import { fs, minimist } from "./compiled";
4
- export const isApiOnly = async (appDirectory, entryDir) => {
5
- const srcDir = path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src");
6
- const existSrc = await fs.pathExists(srcDir);
7
- const options = minimist(getArgv());
8
- return !existSrc || Boolean(options["api-only"]);
9
- };
10
- export const isWebOnly = async () => {
11
- const options = minimist(getArgv());
12
- return Boolean(options["web-only"]);
13
- };
@@ -1,5 +0,0 @@
1
- export const clearConsole = () => {
2
- if (process.stdout.isTTY && !process.env.DEBUG) {
3
- process.stdout.write("\x1B[H\x1B[2J");
4
- }
5
- };
package/dist/esm/debug.js DELETED
@@ -1,2 +0,0 @@
1
- import { debug } from "../compiled/debug";
2
- export const createDebugger = (scope) => debug(`modern-js:${scope}`);
@@ -1,6 +0,0 @@
1
- import { fs } from "./compiled";
2
- export const emptyDir = async (dir) => {
3
- if (await fs.pathExists(dir)) {
4
- await fs.emptyDir(dir);
5
- }
6
- };
@@ -1,8 +0,0 @@
1
- export const ensureArray = (params) => {
2
- if (Array.isArray(params)) {
3
- return params;
4
- }
5
- return [
6
- params
7
- ];
8
- };
@@ -1,9 +0,0 @@
1
- import { browserslist } from "./compiled";
2
- export const defaults = [
3
- "> 0.01%",
4
- "not dead",
5
- "not op_mini all"
6
- ];
7
- export const getBrowserslist = (appDirectory) => browserslist.loadConfig({
8
- path: appDirectory
9
- }) || defaults;
@@ -1,10 +0,0 @@
1
- import * as fs from "../compiled/fs-extra";
2
- export const getCoreJsVersion = (corejsPkgPath) => {
3
- try {
4
- const { version } = fs.readJSONSync(corejsPkgPath);
5
- const [major, minor] = version.split(".");
6
- return `${major}.${minor}`;
7
- } catch (err) {
8
- return "3";
9
- }
10
- };
@@ -1,29 +0,0 @@
1
- import os from "os";
2
- import path from "path";
3
- import { fs } from "./compiled";
4
- import { canUsePnpm, canUseYarn } from "./nodeEnv";
5
- const MAX_TIMES = 5;
6
- export async function getPackageManager(cwd = process.cwd()) {
7
- let appDirectory = cwd;
8
- let times = 0;
9
- while (os.homedir() !== appDirectory && times < MAX_TIMES) {
10
- times++;
11
- if (fs.existsSync(path.resolve(appDirectory, "pnpm-lock.yaml"))) {
12
- return "pnpm";
13
- }
14
- if (fs.existsSync(path.resolve(appDirectory, "yarn.lock"))) {
15
- return "yarn";
16
- }
17
- if (fs.existsSync(path.resolve(appDirectory, "package-lock.json"))) {
18
- return "npm";
19
- }
20
- appDirectory = path.join(appDirectory, "..");
21
- }
22
- if (await canUsePnpm()) {
23
- return "pnpm";
24
- }
25
- if (await canUseYarn()) {
26
- return "yarn";
27
- }
28
- return "npm";
29
- }
@@ -1,7 +0,0 @@
1
- import * as path from "path";
2
- import { CONFIG_FILE_EXTENSIONS } from "./constants";
3
- import { findExists } from "./findExists";
4
- export const getServerConfig = async (appDirectory, configFile) => {
5
- const configFilePath = findExists(CONFIG_FILE_EXTENSIONS.map((extension) => path.resolve(appDirectory, `${configFile}${extension}`)));
6
- return configFilePath;
7
- };
@@ -1,5 +0,0 @@
1
- import * as path from "path";
2
- export const getTargetDir = (from, baseDir, targetBaseDir) => {
3
- const relativePath = path.relative(baseDir, from);
4
- return path.resolve(targetBaseDir, relativePath);
5
- };
@@ -1,20 +0,0 @@
1
- import { INTERNAL_CLI_PLUGINS } from "./constants";
2
- import { isDepExists } from "./is";
3
- export function getInternalPlugins(appDirectory, internalPlugins = INTERNAL_CLI_PLUGINS) {
4
- return [
5
- ...Object.keys(internalPlugins).filter((name) => {
6
- const config = internalPlugins[name];
7
- if (typeof config !== "string" && config.forced === true) {
8
- return true;
9
- }
10
- return isDepExists(appDirectory, name);
11
- }).map((name) => {
12
- const config = internalPlugins[name];
13
- if (typeof config !== "string") {
14
- return config.path;
15
- } else {
16
- return config;
17
- }
18
- })
19
- ];
20
- }
package/dist/esm/react.js DELETED
@@ -1,17 +0,0 @@
1
- import path from "path";
2
- import { fs, semver } from ".";
3
- export const isBeyondReact17 = (cwd) => {
4
- const pkgPath = path.join(cwd, "package.json");
5
- if (!fs.existsSync(pkgPath)) {
6
- return false;
7
- }
8
- const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
9
- const deps = {
10
- ...pkgInfo.devDependencies,
11
- ...pkgInfo.dependencies
12
- };
13
- if (typeof deps.react !== "string") {
14
- return false;
15
- }
16
- return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
17
- };