@modern-js/utils 2.21.1 → 2.22.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/FileSizeReporter.d.ts +16 -0
  3. package/dist/FileSizeReporter.js +162 -0
  4. package/dist/alias.d.ts +25 -0
  5. package/dist/alias.js +108 -0
  6. package/dist/analyzeProject.d.ts +2 -0
  7. package/dist/analyzeProject.js +71 -0
  8. package/dist/applyOptionsChain.d.ts +3 -0
  9. package/dist/applyOptionsChain.js +58 -0
  10. package/dist/babel.d.ts +3 -0
  11. package/dist/babel.js +136 -0
  12. package/dist/chainId.d.ts +244 -0
  13. package/dist/chainId.js +196 -0
  14. package/dist/cjs/cli/alias.js +12 -4
  15. package/dist/cjs/cli/applyOptionsChain.js +3 -1
  16. package/dist/cjs/cli/babel.js +6 -2
  17. package/dist/cjs/cli/commands.js +12 -4
  18. package/dist/cjs/cli/common.js +9 -3
  19. package/dist/cjs/cli/constants/chainId.js +3 -1
  20. package/dist/cjs/cli/constants/index.js +93 -31
  21. package/dist/cjs/cli/ensure.js +6 -2
  22. package/dist/cjs/cli/fs.js +6 -2
  23. package/dist/cjs/cli/get/config.js +3 -1
  24. package/dist/cjs/cli/get/data.js +24 -8
  25. package/dist/cjs/cli/get/index.js +6 -2
  26. package/dist/cjs/cli/is/config.js +18 -6
  27. package/dist/cjs/cli/is/env.js +18 -6
  28. package/dist/cjs/cli/is/platform.js +6 -2
  29. package/dist/cjs/cli/is/project.js +21 -7
  30. package/dist/cjs/cli/is/type.js +27 -9
  31. package/dist/cjs/cli/logger.js +6 -2
  32. package/dist/cjs/cli/monorepo.js +21 -7
  33. package/dist/cjs/cli/package.js +12 -4
  34. package/dist/cjs/cli/path.js +39 -13
  35. package/dist/cjs/cli/pathSerializer.js +12 -4
  36. package/dist/cjs/cli/port.js +3 -1
  37. package/dist/cjs/cli/prettyInstructions.js +6 -2
  38. package/dist/cjs/cli/print.js +3 -1
  39. package/dist/cjs/cli/require.js +18 -6
  40. package/dist/cjs/cli/routes.js +3 -1
  41. package/dist/cjs/cli/runtimeExports.js +3 -1
  42. package/dist/cjs/cli/test.js +3 -1
  43. package/dist/cjs/cli/watch.js +6 -2
  44. package/dist/cjs/compiled.js +99 -33
  45. package/dist/cjs/import.js +6 -2
  46. package/dist/cjs/runtime/nestedRoutes.js +6 -2
  47. package/dist/cjs/runtime-browser/parsed.js +8 -2
  48. package/dist/cjs/runtime-node/index.js +9 -3
  49. package/dist/cjs/runtime-node/serialize.js +3 -1
  50. package/dist/cjs/runtime-node/storage.js +3 -1
  51. package/dist/cjs/universal/constants.js +6 -2
  52. package/dist/cjs/universal/formatWebpack.js +3 -1
  53. package/dist/cjs/universal/pluginDagSort.js +3 -1
  54. package/dist/clearConsole.d.ts +1 -0
  55. package/dist/clearConsole.js +31 -0
  56. package/dist/commands.d.ts +4 -0
  57. package/dist/commands.js +48 -0
  58. package/dist/compatRequire.d.ts +13 -0
  59. package/dist/compatRequire.js +82 -0
  60. package/dist/compiled.d.ts +43 -0
  61. package/dist/compiled.js +142 -0
  62. package/dist/constants.d.ts +244 -0
  63. package/dist/constants.js +320 -0
  64. package/dist/debug.d.ts +6 -0
  65. package/dist/debug.js +28 -0
  66. package/dist/emptyDir.d.ts +1 -0
  67. package/dist/emptyDir.js +52 -0
  68. package/dist/ensureAbsolutePath.d.ts +7 -0
  69. package/dist/ensureAbsolutePath.js +38 -0
  70. package/dist/ensureArray.d.ts +1 -0
  71. package/dist/ensureArray.js +32 -0
  72. package/dist/esm/runtime-browser/parsed.js +5 -1
  73. package/dist/findExists.d.ts +6 -0
  74. package/dist/findExists.js +45 -0
  75. package/dist/generateMetaTags.d.ts +16 -0
  76. package/dist/generateMetaTags.js +61 -0
  77. package/dist/getBrowserslist.d.ts +2 -0
  78. package/dist/getBrowserslist.js +31 -0
  79. package/dist/getCoreJsVersion.d.ts +1 -0
  80. package/dist/getCoreJsVersion.js +46 -0
  81. package/dist/getEntryOptions.d.ts +1 -0
  82. package/dist/getEntryOptions.js +54 -0
  83. package/dist/getPackageManager.d.ts +1 -0
  84. package/dist/getPackageManager.js +87 -0
  85. package/dist/getPort.d.ts +14 -0
  86. package/dist/getPort.js +112 -0
  87. package/dist/getServerConfig.d.ts +1 -0
  88. package/dist/getServerConfig.js +67 -0
  89. package/dist/getTargetDir.d.ts +1 -0
  90. package/dist/getTargetDir.js +41 -0
  91. package/dist/import.d.ts +5 -0
  92. package/dist/import.js +33 -0
  93. package/dist/index.d.ts +44 -0
  94. package/dist/index.js +60 -0
  95. package/dist/is/index.d.ts +58 -0
  96. package/dist/is/index.js +114 -0
  97. package/dist/is/nodeEnv.d.ts +8 -0
  98. package/dist/is/nodeEnv.js +39 -0
  99. package/dist/is/platform.d.ts +2 -0
  100. package/dist/is/platform.js +30 -0
  101. package/dist/is/type.d.ts +8 -0
  102. package/dist/is/type.js +64 -0
  103. package/dist/logger.d.ts +65 -0
  104. package/dist/logger.js +145 -0
  105. package/dist/monorepo.d.ts +11 -0
  106. package/dist/monorepo.js +137 -0
  107. package/dist/nodeEnv.d.ts +3 -0
  108. package/dist/nodeEnv.js +81 -0
  109. package/dist/path.d.ts +18 -0
  110. package/dist/path.js +92 -0
  111. package/dist/pathSerializer.d.ts +16 -0
  112. package/dist/pathSerializer.js +76 -0
  113. package/dist/plugin.d.ts +2 -0
  114. package/dist/plugin.js +46 -0
  115. package/dist/prettyInstructions.d.ts +9 -0
  116. package/dist/prettyInstructions.js +112 -0
  117. package/dist/printBuildError.d.ts +8 -0
  118. package/dist/printBuildError.js +57 -0
  119. package/dist/react.d.ts +1 -0
  120. package/dist/react.js +64 -0
  121. package/dist/readTsConfig.d.ts +2 -0
  122. package/dist/readTsConfig.js +47 -0
  123. package/dist/removeSlash.d.ts +3 -0
  124. package/dist/removeSlash.js +33 -0
  125. package/dist/resolve.d.ts +13 -0
  126. package/dist/resolve.js +63 -0
  127. package/dist/routes.d.ts +2 -0
  128. package/dist/routes.js +58 -0
  129. package/dist/runtimeExports.d.ts +4 -0
  130. package/dist/runtimeExports.js +73 -0
  131. package/dist/ssr.d.ts +8 -0
  132. package/dist/ssr.js +30 -0
  133. package/dist/storage.d.ts +5 -0
  134. package/dist/storage.js +75 -0
  135. package/dist/testUtils.d.ts +5 -0
  136. package/dist/testUtils.js +38 -0
  137. package/dist/types.d.ts +1 -0
  138. package/dist/types.js +15 -0
  139. package/dist/universal/constants.d.ts +9 -0
  140. package/dist/universal/constants.js +30 -0
  141. package/dist/universal/formatWebpack.d.ts +13 -0
  142. package/dist/universal/formatWebpack.js +100 -0
  143. package/dist/universal/nestedRoutes.d.ts +8 -0
  144. package/dist/universal/nestedRoutes.js +131 -0
  145. package/dist/universal/remixRouter.d.ts +1 -0
  146. package/dist/universal/remixRouter.js +17 -0
  147. package/dist/universal/serialize.d.ts +1 -0
  148. package/dist/universal/serialize.js +40 -0
  149. package/dist/version.d.ts +2 -0
  150. package/dist/version.js +92 -0
  151. package/dist/wait.d.ts +2 -0
  152. package/dist/wait.js +29 -0
  153. package/dist/watch.d.ts +8 -0
  154. package/dist/watch.js +90 -0
  155. package/package.json +5 -5
package/dist/watch.js ADDED
@@ -0,0 +1,90 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var __async = (__this, __arguments, generator) => {
29
+ return new Promise((resolve, reject) => {
30
+ var fulfilled = (value) => {
31
+ try {
32
+ step(generator.next(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var rejected = (value) => {
38
+ try {
39
+ step(generator.throw(value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ };
44
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
45
+ step((generator = generator.apply(__this, __arguments)).next());
46
+ });
47
+ };
48
+ var watch_exports = {};
49
+ __export(watch_exports, {
50
+ WatchChangeType: () => WatchChangeType,
51
+ watch: () => watch
52
+ });
53
+ module.exports = __toCommonJS(watch_exports);
54
+ var path = __toESM(require("path"));
55
+ var import_compiled = require("./compiled");
56
+ const WatchChangeType = {
57
+ ADD: "add",
58
+ UNLINK: "unlink",
59
+ CHANGE: "change"
60
+ };
61
+ const watch = (watchDir, runTask, ignored = []) => {
62
+ let ready = false;
63
+ const watcher = import_compiled.chokidar.watch(watchDir, {
64
+ ignored
65
+ });
66
+ watcher.on("ready", () => ready = true);
67
+ watcher.on("change", (filePath) => __async(void 0, null, function* () {
68
+ const changedFilePath = path.resolve(filePath);
69
+ yield runTask({ changedFilePath, changeType: WatchChangeType.CHANGE });
70
+ }));
71
+ watcher.on("add", (filePath) => __async(void 0, null, function* () {
72
+ const changedFilePath = path.resolve(filePath);
73
+ if (ready) {
74
+ yield runTask({ changedFilePath, changeType: WatchChangeType.ADD });
75
+ }
76
+ }));
77
+ watcher.on("unlink", (filePath) => __async(void 0, null, function* () {
78
+ const changedFilePath = path.resolve(filePath);
79
+ yield runTask({ changedFilePath, changeType: WatchChangeType.UNLINK });
80
+ }));
81
+ watcher.on("error", (err) => {
82
+ throw err;
83
+ });
84
+ return watcher;
85
+ };
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ WatchChangeType,
89
+ watch
90
+ });
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.21.1",
18
+ "version": "2.22.1-alpha.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -203,7 +203,7 @@
203
203
  }
204
204
  },
205
205
  "dependencies": {
206
- "caniuse-lite": "^1.0.30001451",
206
+ "caniuse-lite": "^1.0.30001489",
207
207
  "lodash": "^4.17.21",
208
208
  "serialize-javascript": "^6.0.0",
209
209
  "react-router-dom": "6.11.2",
@@ -231,9 +231,9 @@
231
231
  "typescript": "^5",
232
232
  "webpack": "^5.82.1",
233
233
  "@types/serialize-javascript": "^5.0.1",
234
- "@modern-js/types": "2.21.1",
235
- "@scripts/jest-config": "2.21.1",
236
- "@scripts/build": "2.21.1"
234
+ "@modern-js/types": "2.22.0",
235
+ "@scripts/build": "2.22.0",
236
+ "@scripts/jest-config": "2.22.0"
237
237
  },
238
238
  "sideEffects": false,
239
239
  "scripts": {