@modern-js/utils 1.3.4 → 1.3.7-alpha.prebundle.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (355) hide show
  1. package/.eslintrc.js +9 -0
  2. package/CHANGELOG.md +18 -0
  3. package/compiled/browserslist/index.d.ts +178 -0
  4. package/compiled/browserslist/index.js +1 -0
  5. package/compiled/browserslist/license +20 -0
  6. package/compiled/browserslist/package.json +1 -0
  7. package/compiled/chalk/index.d.ts +415 -0
  8. package/compiled/chalk/index.js +1 -0
  9. package/compiled/chalk/license +9 -0
  10. package/compiled/chalk/package.json +1 -0
  11. package/compiled/chokidar/anymatch/index.d.ts +19 -0
  12. package/compiled/chokidar/fsevents.node +0 -0
  13. package/compiled/chokidar/index.js +40 -0
  14. package/compiled/chokidar/license +21 -0
  15. package/compiled/chokidar/package.json +1 -0
  16. package/compiled/chokidar/types/index.d.ts +188 -0
  17. package/compiled/commander/index.js +1 -0
  18. package/compiled/commander/license +22 -0
  19. package/compiled/commander/package.json +1 -0
  20. package/compiled/commander/typings/index.d.ts +774 -0
  21. package/compiled/debug/index.d.ts +54 -0
  22. package/compiled/debug/index.js +1 -0
  23. package/compiled/debug/license +20 -0
  24. package/compiled/debug/ms/index.d.ts +25 -0
  25. package/compiled/debug/package.json +1 -0
  26. package/compiled/execa/index.d.ts +564 -0
  27. package/compiled/execa/index.js +1 -0
  28. package/compiled/execa/license +9 -0
  29. package/compiled/execa/package.json +1 -0
  30. package/compiled/filesize/filesize.d.ts +131 -0
  31. package/compiled/filesize/index.js +9 -0
  32. package/compiled/filesize/license +28 -0
  33. package/compiled/filesize/package.json +1 -0
  34. package/compiled/fs-extra/index.d.ts +563 -0
  35. package/compiled/fs-extra/index.js +1 -0
  36. package/compiled/fs-extra/license +15 -0
  37. package/compiled/fs-extra/package.json +1 -0
  38. package/compiled/glob/index.d.ts +91 -0
  39. package/compiled/glob/index.js +1 -0
  40. package/compiled/glob/license +21 -0
  41. package/compiled/glob/minimatch/index.d.ts +204 -0
  42. package/compiled/glob/package.json +1 -0
  43. package/compiled/gzip-size/index.d.ts +96 -0
  44. package/compiled/gzip-size/index.js +1 -0
  45. package/compiled/gzip-size/license +9 -0
  46. package/compiled/gzip-size/package.json +1 -0
  47. package/compiled/import-lazy/index.d.ts +26 -0
  48. package/compiled/import-lazy/index.js +1 -0
  49. package/compiled/import-lazy/license +9 -0
  50. package/compiled/import-lazy/package.json +1 -0
  51. package/compiled/js-yaml/index.d.ts +154 -0
  52. package/compiled/js-yaml/index.js +1 -0
  53. package/compiled/js-yaml/license +21 -0
  54. package/compiled/js-yaml/package.json +1 -0
  55. package/compiled/lodash/common/array.d.ts +2126 -0
  56. package/compiled/lodash/common/collection.d.ts +1930 -0
  57. package/compiled/lodash/common/common.d.ts +280 -0
  58. package/compiled/lodash/common/date.d.ts +23 -0
  59. package/compiled/lodash/common/function.d.ts +1446 -0
  60. package/compiled/lodash/common/lang.d.ts +1693 -0
  61. package/compiled/lodash/common/math.d.ts +405 -0
  62. package/compiled/lodash/common/number.d.ts +131 -0
  63. package/compiled/lodash/common/object.d.ts +2519 -0
  64. package/compiled/lodash/common/seq.d.ts +210 -0
  65. package/compiled/lodash/common/string.d.ts +788 -0
  66. package/compiled/lodash/common/util.d.ts +1220 -0
  67. package/compiled/lodash/index.d.ts +46 -0
  68. package/compiled/lodash/index.js +9 -0
  69. package/compiled/lodash/license +47 -0
  70. package/compiled/lodash/package.json +1 -0
  71. package/compiled/pkg-up/index.d.ts +48 -0
  72. package/compiled/pkg-up/index.js +1 -0
  73. package/compiled/pkg-up/license +9 -0
  74. package/compiled/pkg-up/package.json +1 -0
  75. package/compiled/recursive-readdir/index.d.ts +21 -0
  76. package/compiled/recursive-readdir/index.js +1 -0
  77. package/compiled/recursive-readdir/license +21 -0
  78. package/compiled/recursive-readdir/package.json +1 -0
  79. package/compiled/signale/index.d.ts +162 -0
  80. package/compiled/signale/index.js +1 -0
  81. package/compiled/signale/package.json +1 -0
  82. package/compiled/strip-ansi/index.d.ts +17 -0
  83. package/compiled/strip-ansi/index.js +1 -0
  84. package/compiled/strip-ansi/license +9 -0
  85. package/compiled/strip-ansi/package.json +1 -0
  86. package/compiled/upath/index.js +1 -0
  87. package/compiled/upath/license +22 -0
  88. package/compiled/upath/package.json +1 -0
  89. package/compiled/upath/upath.d.ts +241 -0
  90. package/dist/{types/FileSizeReporter.d.ts → FileSizeReporter.d.ts} +5 -5
  91. package/dist/FileSizeReporter.js +151 -0
  92. package/dist/{types/alias.d.ts → alias.d.ts} +12 -14
  93. package/dist/alias.js +62 -0
  94. package/dist/applyOptionsChain.d.ts +6 -0
  95. package/dist/applyOptionsChain.js +30 -0
  96. package/dist/clearConsole.d.ts +1 -0
  97. package/dist/clearConsole.js +9 -0
  98. package/dist/{types/compatRequire.d.ts → compatRequire.d.ts} +1 -1
  99. package/dist/compatRequire.js +28 -0
  100. package/dist/compiled/upath/index.d.ts +225 -0
  101. package/dist/compiled/upath/index.js +1 -0
  102. package/dist/compiled.d.ts +21 -0
  103. package/dist/compiled.js +33 -0
  104. package/dist/constants.d.ts +209 -0
  105. package/dist/constants.js +264 -0
  106. package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
  107. package/dist/debug.js +11 -0
  108. package/dist/emptyDir.d.ts +1 -0
  109. package/dist/emptyDir.js +19 -0
  110. package/dist/{types/ensureAbsolutePath.d.ts → ensureAbsolutePath.d.ts} +1 -1
  111. package/dist/ensureAbsolutePath.js +15 -0
  112. package/dist/{types/findExists.d.ts → findExists.d.ts} +1 -1
  113. package/dist/findExists.js +21 -0
  114. package/dist/{types/format.d.ts → format.d.ts} +5 -5
  115. package/dist/format.js +113 -0
  116. package/dist/{types/generateMetaTags.d.ts → generateMetaTags.d.ts} +3 -3
  117. package/dist/generateMetaTags.js +48 -0
  118. package/dist/{types/getBrowserslist.d.ts → getBrowserslist.d.ts} +1 -1
  119. package/dist/getBrowserslist.js +7 -0
  120. package/dist/{types/getCacheIdentifier.d.ts → getCacheIdentifier.d.ts} +3 -3
  121. package/dist/getCacheIdentifier.js +24 -0
  122. package/dist/{types/getEntryOptions.d.ts → getEntryOptions.d.ts} +1 -1
  123. package/dist/getEntryOptions.js +26 -0
  124. package/dist/{types/getPackageManager.d.ts → getPackageManager.d.ts} +1 -1
  125. package/dist/getPackageManager.js +47 -0
  126. package/dist/{types/getPort.d.ts → getPort.d.ts} +1 -1
  127. package/dist/getPort.js +62 -0
  128. package/dist/{types/import.d.ts → import.d.ts} +2 -2
  129. package/dist/import.js +10 -0
  130. package/dist/index.d.ts +31 -0
  131. package/dist/index.js +43 -0
  132. package/dist/{types/is → is}/index.d.ts +1 -4
  133. package/dist/is/index.js +82 -0
  134. package/dist/{types/is → is}/node-env.d.ts +1 -1
  135. package/dist/is/node-env.js +12 -0
  136. package/dist/is/platform.d.ts +2 -0
  137. package/dist/is/platform.js +10 -0
  138. package/dist/is/type.d.ts +8 -0
  139. package/dist/is/type.js +38 -0
  140. package/dist/logger.d.ts +63 -0
  141. package/dist/logger.js +128 -0
  142. package/dist/{types/monorepo.d.ts → monorepo.d.ts} +3 -3
  143. package/dist/monorepo.js +80 -0
  144. package/dist/{types/nodeEnv.d.ts → nodeEnv.d.ts} +1 -1
  145. package/dist/nodeEnv.js +49 -0
  146. package/dist/{types/path.d.ts → path.d.ts} +1 -1
  147. package/dist/path.js +14 -0
  148. package/dist/{types/pkgUp.d.ts → pkgUp.d.ts} +1 -1
  149. package/dist/pkgUp.js +8 -0
  150. package/dist/{types/prettyInstructions.d.ts → prettyInstructions.d.ts} +2 -2
  151. package/dist/prettyInstructions.js +64 -0
  152. package/dist/{types/printBuildError.d.ts → printBuildError.d.ts} +1 -1
  153. package/dist/printBuildError.js +43 -0
  154. package/dist/{types/readTsConfig.d.ts → readTsConfig.d.ts} +1 -1
  155. package/dist/readTsConfig.js +19 -0
  156. package/dist/{types/removeSlash.d.ts → removeSlash.d.ts} +1 -1
  157. package/dist/removeSlash.js +9 -0
  158. package/dist/{types/runtimeExports.d.ts → runtimeExports.d.ts} +3 -3
  159. package/dist/runtimeExports.js +53 -0
  160. package/dist/src/FileSizeReporter.d.ts +16 -0
  161. package/dist/src/FileSizeReporter.js +152 -0
  162. package/dist/src/alias.d.ts +21 -0
  163. package/dist/src/alias.js +62 -0
  164. package/dist/src/applyOptionsChain.d.ts +6 -0
  165. package/dist/src/applyOptionsChain.js +30 -0
  166. package/dist/src/clearConsole.d.ts +1 -0
  167. package/dist/src/clearConsole.js +9 -0
  168. package/dist/src/compatRequire.d.ts +8 -0
  169. package/dist/src/compatRequire.js +28 -0
  170. package/dist/src/compiled.d.ts +7 -0
  171. package/dist/src/compiled.js +19 -0
  172. package/dist/src/constants.d.ts +209 -0
  173. package/dist/src/constants.js +264 -0
  174. package/dist/{types → src}/debug.d.ts +1 -2
  175. package/dist/src/debug.js +14 -0
  176. package/dist/src/emptyDir.d.ts +1 -0
  177. package/dist/src/emptyDir.js +22 -0
  178. package/dist/{js/modern/ensureAbsolutePath.js → src/ensureAbsolutePath.d.ts} +1 -3
  179. package/dist/src/ensureAbsolutePath.js +15 -0
  180. package/dist/src/findExists.d.ts +6 -0
  181. package/dist/src/findExists.js +21 -0
  182. package/dist/src/format.d.ts +16 -0
  183. package/dist/src/format.js +115 -0
  184. package/dist/src/generateMetaTags.d.ts +16 -0
  185. package/dist/src/generateMetaTags.js +48 -0
  186. package/dist/src/getBrowserslist.d.ts +2 -0
  187. package/dist/src/getBrowserslist.js +7 -0
  188. package/dist/src/getCacheIdentifier.d.ts +7 -0
  189. package/dist/src/getCacheIdentifier.js +24 -0
  190. package/dist/src/getEntryOptions.d.ts +1 -0
  191. package/dist/src/getEntryOptions.js +26 -0
  192. package/dist/src/getPackageManager.d.ts +1 -0
  193. package/dist/src/getPackageManager.js +47 -0
  194. package/dist/src/getPort.d.ts +7 -0
  195. package/dist/src/getPort.js +62 -0
  196. package/dist/src/import.d.ts +5 -0
  197. package/dist/src/import.js +10 -0
  198. package/dist/{types → src}/index.d.ts +2 -3
  199. package/dist/src/index.js +57 -0
  200. package/dist/src/is/index.d.ts +34 -0
  201. package/dist/src/is/index.js +82 -0
  202. package/dist/src/is/node-env.d.ts +4 -0
  203. package/dist/src/is/node-env.js +12 -0
  204. package/dist/src/is/platform.d.ts +2 -0
  205. package/dist/src/is/platform.js +10 -0
  206. package/dist/src/is/type.d.ts +8 -0
  207. package/dist/src/is/type.js +38 -0
  208. package/dist/src/logger.d.ts +63 -0
  209. package/dist/src/logger.js +129 -0
  210. package/dist/src/monorepo.d.ts +11 -0
  211. package/dist/src/monorepo.js +81 -0
  212. package/dist/src/nodeEnv.d.ts +3 -0
  213. package/dist/src/nodeEnv.js +52 -0
  214. package/dist/src/path.d.ts +3 -0
  215. package/dist/src/path.js +14 -0
  216. package/dist/src/prettyInstructions.d.ts +6 -0
  217. package/dist/src/prettyInstructions.js +64 -0
  218. package/dist/src/printBuildError.d.ts +8 -0
  219. package/dist/src/printBuildError.js +43 -0
  220. package/dist/src/readTsConfig.d.ts +2 -0
  221. package/dist/src/readTsConfig.js +19 -0
  222. package/dist/src/removeSlash.d.ts +3 -0
  223. package/dist/src/removeSlash.js +9 -0
  224. package/dist/src/runtimeExports.d.ts +4 -0
  225. package/dist/src/runtimeExports.js +53 -0
  226. package/dist/{types → src}/wait.d.ts +1 -1
  227. package/dist/src/wait.js +7 -0
  228. package/dist/{types → src}/watch.d.ts +3 -3
  229. package/dist/src/watch.js +65 -0
  230. package/dist/wait.d.ts +2 -0
  231. package/dist/wait.js +7 -0
  232. package/dist/watch.d.ts +8 -0
  233. package/dist/watch.js +64 -0
  234. package/jest.config.js +0 -1
  235. package/package.json +55 -39
  236. package/tests/debug.test.ts +2 -2
  237. package/tests/is.test.ts +27 -0
  238. package/tests/isPlatform.test.ts +19 -0
  239. package/tests/isType.test.ts +70 -2
  240. package/tests/prettyInstructions.test.ts +1 -1
  241. package/tsconfig.json +3 -5
  242. package/dist/js/modern/FileSizeReporter.js +0 -156
  243. package/dist/js/modern/alias.js +0 -74
  244. package/dist/js/modern/applyOptionsChain.js +0 -27
  245. package/dist/js/modern/chalk.js +0 -2
  246. package/dist/js/modern/clearConsole.js +0 -5
  247. package/dist/js/modern/compatRequire.js +0 -26
  248. package/dist/js/modern/constants.js +0 -338
  249. package/dist/js/modern/emptyDir.js +0 -6
  250. package/dist/js/modern/findExists.js +0 -16
  251. package/dist/js/modern/format.js +0 -137
  252. package/dist/js/modern/generateMetaTags.js +0 -49
  253. package/dist/js/modern/getBrowserslist.js +0 -5
  254. package/dist/js/modern/getCacheIdentifier.js +0 -20
  255. package/dist/js/modern/getEntryOptions.js +0 -24
  256. package/dist/js/modern/getPackageManager.js +0 -37
  257. package/dist/js/modern/getPort.js +0 -52
  258. package/dist/js/modern/import.js +0 -11
  259. package/dist/js/modern/index.js +0 -34
  260. package/dist/js/modern/is/index.js +0 -77
  261. package/dist/js/modern/is/node-env.js +0 -5
  262. package/dist/js/modern/is/platform.js +0 -2
  263. package/dist/js/modern/is/type.js +0 -28
  264. package/dist/js/modern/logger.js +0 -152
  265. package/dist/js/modern/monorepo.js +0 -84
  266. package/dist/js/modern/nodeEnv.js +0 -31
  267. package/dist/js/modern/path.js +0 -5
  268. package/dist/js/modern/pkgUp.js +0 -2
  269. package/dist/js/modern/prettyInstructions.js +0 -79
  270. package/dist/js/modern/printBuildError.js +0 -40
  271. package/dist/js/modern/readTsConfig.js +0 -13
  272. package/dist/js/modern/removeSlash.js +0 -3
  273. package/dist/js/modern/runtimeExports.js +0 -52
  274. package/dist/js/modern/wait.js +0 -5
  275. package/dist/js/modern/watch.js +0 -43
  276. package/dist/js/node/FileSizeReporter.js +0 -175
  277. package/dist/js/node/alias.js +0 -97
  278. package/dist/js/node/applyOptionsChain.js +0 -37
  279. package/dist/js/node/chalk.js +0 -15
  280. package/dist/js/node/clearConsole.js +0 -14
  281. package/dist/js/node/compatRequire.js +0 -41
  282. package/dist/js/node/constants.js +0 -358
  283. package/dist/js/node/debug.js +0 -19
  284. package/dist/js/node/emptyDir.js +0 -18
  285. package/dist/js/node/ensureAbsolutePath.js +0 -20
  286. package/dist/js/node/findExists.js +0 -27
  287. package/dist/js/node/format.js +0 -141
  288. package/dist/js/node/generateMetaTags.js +0 -58
  289. package/dist/js/node/getBrowserslist.js +0 -17
  290. package/dist/js/node/getCacheIdentifier.js +0 -27
  291. package/dist/js/node/getEntryOptions.js +0 -35
  292. package/dist/js/node/getPackageManager.js +0 -51
  293. package/dist/js/node/getPort.js +0 -67
  294. package/dist/js/node/import.js +0 -19
  295. package/dist/js/node/index.js +0 -465
  296. package/dist/js/node/is/index.js +0 -150
  297. package/dist/js/node/is/node-env.js +0 -23
  298. package/dist/js/node/is/platform.js +0 -14
  299. package/dist/js/node/is/type.js +0 -49
  300. package/dist/js/node/logger.js +0 -162
  301. package/dist/js/node/monorepo.js +0 -118
  302. package/dist/js/node/nodeEnv.js +0 -45
  303. package/dist/js/node/path.js +0 -24
  304. package/dist/js/node/pkgUp.js +0 -15
  305. package/dist/js/node/prettyInstructions.js +0 -95
  306. package/dist/js/node/printBuildError.js +0 -52
  307. package/dist/js/node/readTsConfig.js +0 -28
  308. package/dist/js/node/removeSlash.js +0 -18
  309. package/dist/js/node/runtimeExports.js +0 -68
  310. package/dist/js/node/wait.js +0 -12
  311. package/dist/js/node/watch.js +0 -61
  312. package/dist/js/treeshaking/FileSizeReporter.js +0 -185
  313. package/dist/js/treeshaking/alias.js +0 -72
  314. package/dist/js/treeshaking/applyOptionsChain.js +0 -31
  315. package/dist/js/treeshaking/chalk.js +0 -2
  316. package/dist/js/treeshaking/clearConsole.js +0 -5
  317. package/dist/js/treeshaking/compatRequire.js +0 -29
  318. package/dist/js/treeshaking/constants.js +0 -338
  319. package/dist/js/treeshaking/debug.js +0 -10
  320. package/dist/js/treeshaking/emptyDir.js +0 -37
  321. package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
  322. package/dist/js/treeshaking/findExists.js +0 -33
  323. package/dist/js/treeshaking/format.js +0 -167
  324. package/dist/js/treeshaking/generateMetaTags.js +0 -55
  325. package/dist/js/treeshaking/getBrowserslist.js +0 -7
  326. package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
  327. package/dist/js/treeshaking/getEntryOptions.js +0 -26
  328. package/dist/js/treeshaking/getPackageManager.js +0 -101
  329. package/dist/js/treeshaking/getPort.js +0 -103
  330. package/dist/js/treeshaking/import.js +0 -11
  331. package/dist/js/treeshaking/index.js +0 -34
  332. package/dist/js/treeshaking/is/index.js +0 -81
  333. package/dist/js/treeshaking/is/node-env.js +0 -13
  334. package/dist/js/treeshaking/is/platform.js +0 -6
  335. package/dist/js/treeshaking/is/type.js +0 -30
  336. package/dist/js/treeshaking/logger.js +0 -188
  337. package/dist/js/treeshaking/monorepo.js +0 -95
  338. package/dist/js/treeshaking/nodeEnv.js +0 -108
  339. package/dist/js/treeshaking/path.js +0 -11
  340. package/dist/js/treeshaking/pkgUp.js +0 -2
  341. package/dist/js/treeshaking/prettyInstructions.js +0 -100
  342. package/dist/js/treeshaking/printBuildError.js +0 -40
  343. package/dist/js/treeshaking/readTsConfig.js +0 -13
  344. package/dist/js/treeshaking/removeSlash.js +0 -9
  345. package/dist/js/treeshaking/runtimeExports.js +0 -61
  346. package/dist/js/treeshaking/wait.js +0 -8
  347. package/dist/js/treeshaking/watch.js +0 -112
  348. package/dist/types/applyOptionsChain.d.ts +0 -6
  349. package/dist/types/chalk.d.ts +0 -2
  350. package/dist/types/clearConsole.d.ts +0 -1
  351. package/dist/types/constants.d.ts +0 -219
  352. package/dist/types/emptyDir.d.ts +0 -1
  353. package/dist/types/is/platform.d.ts +0 -2
  354. package/dist/types/is/type.d.ts +0 -8
  355. package/dist/types/logger.d.ts +0 -63
package/package.json CHANGED
@@ -11,72 +11,87 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.3.4",
14
+ "version": "1.3.7-alpha.prebundle.0",
15
15
  "jsnext:source": "./src/index.ts",
16
- "types": "./dist/types/index.d.ts",
17
- "main": "./dist/js/node/index.js",
18
- "module": "./dist/js/treeshaking/index.js",
19
- "jsnext:modern": "./dist/js/modern/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "main": "./dist/index.js",
18
+ "module": "./dist/index.js",
19
+ "jsnext:modern": "./dist/index.js",
20
20
  "exports": {
21
21
  ".": {
22
- "node": {
23
- "jsnext:source": "./src/index.ts",
24
- "import": "./dist/js/modern/index.js",
25
- "require": "./dist/js/node/index.js"
26
- },
27
- "default": "./dist/js/treeshaking/index.js"
22
+ "jsnext:source": "./src/index.ts",
23
+ "default": "./dist/index.js"
28
24
  },
29
25
  "./format": {
30
26
  "jsnext:source": "./src/format.ts",
31
- "default": "./dist/js/treeshaking/format.js"
27
+ "default": "./dist/format.js"
32
28
  },
33
29
  "./constants": {
34
30
  "jsnext:source": "./src/constants.ts",
35
- "default": "./dist/js/treeshaking/constants.js"
31
+ "default": "./dist/constants.js"
32
+ },
33
+ "./lodash": {
34
+ "jsnext:source": "./compiled/lodash/index.js",
35
+ "default": "./compiled/lodash/index.js"
36
+ },
37
+ "./strip-ansi": {
38
+ "jsnext:source": "./compiled/strip-ansi/index.js",
39
+ "default": "./compiled/strip-ansi/index.js"
36
40
  }
37
41
  },
38
42
  "typesVersions": {
39
43
  "*": {
40
44
  "format": [
41
- "./dist/types/format.d.ts"
45
+ "./dist/format.d.ts"
42
46
  ],
43
47
  "constants": [
44
- "./dist/types/constants.d.ts"
48
+ "./dist/constants.d.ts"
49
+ ],
50
+ "lodash": [
51
+ "./compiled/lodash/index.d.ts"
52
+ ],
53
+ "strip-ansi": [
54
+ "./compiled/strip-ansi/index.d.ts"
45
55
  ]
46
56
  }
47
57
  },
48
58
  "dependencies": {
49
59
  "@babel/runtime": "^7",
50
- "@types/fs-extra": "^9.0.12",
51
- "browserslist": "^4.16.7",
52
- "chalk": "^4.1.2",
53
- "chokidar": "^3.5.2",
54
- "debug": "^4.3.2",
55
- "filesize": "^7.0.0",
56
- "fs-extra": "^10.0.0",
57
- "glob": "^7.1.7",
58
- "gzip-size": "^6.0.0",
59
- "import-lazy": "^4.0.0",
60
- "pkg-up": "^3.1.0",
61
- "recursive-readdir": "^2.2.2",
62
- "strip-ansi": "6.0.0",
63
- "upath": "^2.0.1",
64
- "yaml": "^1.10.2",
65
- "execa": "5",
66
60
  "typescript": "^4"
67
61
  },
68
62
  "devDependencies": {
69
- "@types/debug": "^4.1.7",
70
- "@types/fs-extra": "^9.0.12",
63
+ "@modern-js/types": "^1.3.6",
64
+ "@scripts/build": "0.0.0",
65
+ "@scripts/jest-config": "0.0.0",
66
+ "@types/debug": "4.1.7",
67
+ "@types/fs-extra": "9.0.13",
71
68
  "@types/glob": "^7.1.4",
72
69
  "@types/jest": "^26",
70
+ "@types/js-yaml": "4.0.5",
71
+ "@types/lodash": "4.14.181",
73
72
  "@types/node": "^14",
74
- "@types/recursive-readdir": "^2.2.0",
75
- "webpack": "^5.54.0",
76
- "@scripts/build": "0.0.0",
73
+ "@types/recursive-readdir": "2.2.0",
74
+ "@types/signale": "1.4.4",
75
+ "browserslist": "4.20.2",
76
+ "chalk": "4.1.2",
77
+ "chokidar": "3.5.3",
78
+ "commander": "8.3.0",
79
+ "debug": "4.3.4",
80
+ "execa": "5.1.1",
81
+ "filesize": "8.0.7",
82
+ "fs-extra": "10.0.1",
83
+ "glob": "7.2.0",
84
+ "gzip-size": "6.0.0",
85
+ "import-lazy": "4.0.0",
77
86
  "jest": "^27",
78
- "@scripts/jest-config": "0.0.0",
79
- "@modern-js/types": "^1.3.4"
87
+ "js-yaml": "4.1.0",
88
+ "lodash": "4.17.21",
89
+ "pkg-up": "3.1.0",
90
+ "recursive-readdir": "2.2.2",
91
+ "signale": "1.4.0",
92
+ "strip-ansi": "6.0.1",
93
+ "upath": "2.0.1",
94
+ "webpack": "^5.71.0"
80
95
  },
81
96
  "sideEffects": false,
82
97
  "publishConfig": {
@@ -85,7 +100,8 @@
85
100
  },
86
101
  "scripts": {
87
102
  "new": "modern new",
88
- "build": "modern build",
103
+ "dev": "tsc --watch",
104
+ "build": "tsc",
89
105
  "test": "jest --passWithNoTests"
90
106
  },
91
107
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
@@ -1,5 +1,5 @@
1
- import debug from 'debug';
2
- import stripAnsi from 'strip-ansi';
1
+ import { debug } from '../src/compiled';
2
+ import { stripAnsi } from '../src';
3
3
  import { createDebugger } from '../src/debug';
4
4
 
5
5
  describe('debug utility', () => {
@@ -0,0 +1,27 @@
1
+ import { isEmpty, isFastRefresh } from '../src/is';
2
+
3
+ describe('validate', () => {
4
+ it('should validate empty object correctly', () => {
5
+ expect(isEmpty({})).toBeTruthy();
6
+ expect(isEmpty({ foo: 'bar' })).toBeFalsy();
7
+ });
8
+
9
+ it('should validate fast refresh correctly', () => {
10
+ const { NODE_ENV, FAST_REFRESH } = process.env;
11
+
12
+ process.env.NODE_ENV = 'development';
13
+ process.env.FAST_REFRESH = 'true';
14
+ expect(isFastRefresh()).toBeTruthy();
15
+
16
+ process.env.NODE_ENV = 'production';
17
+ process.env.FAST_REFRESH = 'true';
18
+ expect(isFastRefresh()).toBeFalsy();
19
+
20
+ process.env.NODE_ENV = 'development';
21
+ process.env.FAST_REFRESH = 'false';
22
+ expect(isFastRefresh()).toBeFalsy();
23
+
24
+ process.env.NODE_ENV = NODE_ENV;
25
+ process.env.FAST_REFRESH = FAST_REFRESH;
26
+ });
27
+ });
@@ -0,0 +1,19 @@
1
+ import { isNodeJS, isBrowser } from '../src/is/platform';
2
+
3
+ describe('validate platform', () => {
4
+ it('should validate Node.js correctly', () => {
5
+ expect(isNodeJS()).toBeTruthy();
6
+ });
7
+
8
+ it('should validate browser correctly', () => {
9
+ const windowSpy = jest.spyOn(window, 'window', 'get');
10
+
11
+ windowSpy.mockImplementation((): any => undefined);
12
+ expect(isBrowser()).toBeFalsy();
13
+
14
+ windowSpy.mockImplementation((): any => global);
15
+ expect(isBrowser()).toBeTruthy();
16
+
17
+ windowSpy.mockRestore();
18
+ });
19
+ });
@@ -1,4 +1,12 @@
1
- import { isString, isUndefined } from '../src/is/type';
1
+ import {
2
+ isArray,
3
+ isObject,
4
+ isString,
5
+ isRegExp,
6
+ isPromise,
7
+ isUndefined,
8
+ isPlainObject,
9
+ } from '../src/is/type';
2
10
 
3
11
  describe('validate type', () => {
4
12
  it('should validate string correctly', () => {
@@ -8,10 +16,70 @@ describe('validate type', () => {
8
16
  expect(isString(123)).toBeFalsy();
9
17
  });
10
18
 
11
- it('should validate undeinfed correctly', () => {
19
+ it('should validate undefined correctly', () => {
12
20
  expect(isUndefined(undefined)).toBeTruthy();
13
21
  expect(isUndefined(null)).toBeFalsy();
14
22
  expect(isUndefined('')).toBeFalsy();
15
23
  expect(isUndefined(123)).toBeFalsy();
16
24
  });
25
+
26
+ it('should validate array correctly', () => {
27
+ expect(isArray(undefined)).toBeFalsy();
28
+ expect(isArray(null)).toBeFalsy();
29
+ expect(isArray('')).toBeFalsy();
30
+ expect(isArray(123)).toBeFalsy();
31
+ expect(isArray({})).toBeFalsy();
32
+ expect(isArray([])).toBeTruthy();
33
+ });
34
+
35
+ it('should validate object correctly', () => {
36
+ expect(isObject(1)).toBeFalsy();
37
+ expect(isObject('1')).toBeFalsy();
38
+ expect(isObject(undefined)).toBeFalsy();
39
+ expect(isObject(null)).toBeFalsy();
40
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
41
+ expect(isObject(() => {})).toBeFalsy();
42
+ expect(isObject({})).toBeTruthy();
43
+ expect(isObject([])).toBeTruthy();
44
+ expect(isObject(/foo/)).toBeTruthy();
45
+ });
46
+
47
+ it('should validate plain object correctly', () => {
48
+ expect(isPlainObject(1)).toBeFalsy();
49
+ expect(isPlainObject('1')).toBeFalsy();
50
+ expect(isPlainObject(undefined)).toBeFalsy();
51
+ expect(isPlainObject(null)).toBeFalsy();
52
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
53
+ expect(isPlainObject(() => {})).toBeFalsy();
54
+ expect(isPlainObject({})).toBeTruthy();
55
+ expect(isPlainObject([])).toBeFalsy();
56
+ expect(isPlainObject(/foo/)).toBeFalsy();
57
+ });
58
+
59
+ it('should validate RegExp correctly', () => {
60
+ expect(isRegExp(1)).toBeFalsy();
61
+ expect(isRegExp('1')).toBeFalsy();
62
+ expect(isRegExp(undefined)).toBeFalsy();
63
+ expect(isRegExp(null)).toBeFalsy();
64
+ expect(isRegExp({})).toBeFalsy();
65
+ expect(isRegExp([])).toBeFalsy();
66
+ expect(isRegExp(/foo/)).toBeTruthy();
67
+ });
68
+
69
+ it('should validate Promise correctly', () => {
70
+ expect(isPromise(1)).toBeFalsy();
71
+ expect(isPromise('1')).toBeFalsy();
72
+ expect(isPromise(undefined)).toBeFalsy();
73
+ expect(isPromise(null)).toBeFalsy();
74
+ expect(isPromise({})).toBeFalsy();
75
+ expect(isPromise([])).toBeFalsy();
76
+ expect(isPromise(/foo/)).toBeFalsy();
77
+ expect(
78
+ isPromise(
79
+ new Promise<void>(resolve => {
80
+ resolve();
81
+ }),
82
+ ),
83
+ ).toBeTruthy();
84
+ });
17
85
  });
@@ -57,7 +57,7 @@ jest.mock('os', () => {
57
57
  };
58
58
  });
59
59
 
60
- jest.mock('chalk', () => ({
60
+ jest.mock('../compiled/chalk', () => ({
61
61
  __esModule: true,
62
62
  default: {
63
63
  bold: jest.fn(str => str),
package/tsconfig.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "extends": "@modern-js/tsconfig/base",
3
3
  "compilerOptions": {
4
- "declaration": false,
5
- "allowJs": true,
6
- "jsx": "preserve",
4
+ "declaration": true,
5
+ "outDir": "./dist",
7
6
  "baseUrl": "./",
8
- "isolatedModules": true,
9
- "paths": {}
7
+ "isolatedModules": true
10
8
  },
11
9
  "include": ["src"]
12
10
  }
@@ -1,156 +0,0 @@
1
- /* eslint-disable eslint-comments/no-unlimited-disable */
2
-
3
- /* eslint-disable */
4
-
5
- /**
6
- * Copyright (c) 2015-present, Facebook, Inc.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file at
10
- * https://github.com/facebook/create-react-app/blob/master/LICENSE
11
- */
12
- // Modified by Chao Xu (xuchaobei)
13
- 'use strict';
14
-
15
- import fs from 'fs';
16
- import path from 'path';
17
- import chalk from 'chalk';
18
- import filesize from 'filesize';
19
- import recursive from 'recursive-readdir';
20
- import stripAnsi from 'strip-ansi';
21
- import gzipSize from 'gzip-size';
22
- import { logger } from "./logger";
23
-
24
- function canReadAsset(asset) {
25
- return /\.(js|css)$/.test(asset) && !/service-worker\.js/.test(asset) && !/precache-manifest\.[0-9a-f]+\.js/.test(asset);
26
- } // Prints a detailed summary of build files.
27
-
28
-
29
- function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
30
- var root = previousSizeMap.root;
31
- var sizes = previousSizeMap.sizes;
32
- var assets = (webpackStats.stats || [webpackStats]).map(stats => stats.toJson({
33
- all: false,
34
- assets: true
35
- }).assets.filter(asset => canReadAsset(asset.name)).map(asset => {
36
- var fileContents = fs.readFileSync(path.join(root, asset.name));
37
- var size = fileContents.length;
38
- var gzippedSize = gzipSize.sync(fileContents);
39
- var [previousSize, previousGzipSize] = sizes[removeFileNameHash(root, asset.name)] || [];
40
- var sizeDifference = getDifferenceLabel(size, previousSize);
41
- var gzipSizeDifference = getDifferenceLabel(gzippedSize, previousGzipSize);
42
- return {
43
- folder: path.join(path.basename(buildFolder), path.dirname(asset.name)),
44
- name: path.basename(asset.name),
45
- gzippedSize: gzippedSize,
46
- sizeLabel: filesize(size) + (sizeDifference ? ' (' + sizeDifference + ')' : ''),
47
- gzipSizeLabel: filesize(gzippedSize) + (gzipSizeDifference ? ' (' + gzipSizeDifference + ')' : '')
48
- };
49
- })).reduce((single, all) => all.concat(single), []);
50
- assets.sort((a, b) => b.size - a.size);
51
- var longestSizeLabelLength = Math.max.apply(null, assets.map(a => stripAnsi(a.sizeLabel).length));
52
- var longestFileNameLength = Math.max.apply(null, assets.map(a => stripAnsi(a.folder + path.sep + a.name).length));
53
- printFileSizesHeader(longestFileNameLength, longestSizeLabelLength);
54
- var suggestBundleSplitting = false;
55
- assets.forEach(asset => {
56
- var {
57
- folder,
58
- name,
59
- sizeLabel,
60
- gzipSizeLabel,
61
- gzippedSize
62
- } = asset;
63
- var fileNameLength = stripAnsi(folder + path.sep + name).length;
64
- var sizeLength = stripAnsi(sizeLabel).length;
65
-
66
- if (sizeLength < longestSizeLabelLength) {
67
- var rightPadding = ' '.repeat(longestSizeLabelLength - sizeLength);
68
- sizeLabel += rightPadding;
69
- }
70
-
71
- var fileNameLabel = chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name);
72
-
73
- if (fileNameLength < longestFileNameLength) {
74
- var rightPadding = ' '.repeat(longestFileNameLength - fileNameLength);
75
- fileNameLabel += rightPadding;
76
- }
77
-
78
- var isMainBundle = asset.name.indexOf('main.') === 0;
79
- var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
80
- var isLarge = maxRecommendedSize && gzippedSize > maxRecommendedSize;
81
-
82
- if (isLarge && path.extname(asset.name) === '.js') {
83
- suggestBundleSplitting = true;
84
- }
85
-
86
- logger.log(' ' + fileNameLabel + ' ' + sizeLabel + ' ' + (isLarge ? chalk.yellow(gzipSizeLabel) : gzipSizeLabel));
87
- });
88
-
89
- if (suggestBundleSplitting) {
90
- logger.log();
91
- logger.warn('The bundle size is significantly larger than recommended.');
92
- }
93
- }
94
-
95
- function printFileSizesHeader(longestFileNameLength, longestSizeLabelLength) {
96
- const longestLengths = [longestFileNameLength, longestSizeLabelLength];
97
- const headerRow = ['File', 'Size', 'Gzipped'].reduce((prev, cur, index) => {
98
- const length = longestLengths[index];
99
- let curLabel = cur;
100
-
101
- if (length) {
102
- curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur;
103
- }
104
-
105
- return prev + curLabel + ' ';
106
- }, ' ');
107
- logger.log(chalk.bold(chalk.blue(headerRow)));
108
- }
109
-
110
- function removeFileNameHash(buildFolder, fileName) {
111
- return fileName.replace(buildFolder, '').replace(/\\/g, '/').replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
112
- } // Input: 1024, 2048
113
- // Output: "(+1 KB)"
114
-
115
-
116
- function getDifferenceLabel(currentSize, previousSize) {
117
- var FIFTY_KILOBYTES = 1024 * 50;
118
- var difference = currentSize - previousSize;
119
- var fileSize = !Number.isNaN(difference) ? filesize(difference) : 0;
120
-
121
- if (difference >= FIFTY_KILOBYTES) {
122
- return chalk.red('+' + fileSize);
123
- } else if (difference < FIFTY_KILOBYTES && difference > 0) {
124
- return chalk.yellow('+' + fileSize);
125
- } else if (difference < 0) {
126
- return chalk.green(fileSize);
127
- } else {
128
- return '';
129
- }
130
- }
131
-
132
- function measureFileSizesBeforeBuild(buildFolder) {
133
- return new Promise(resolve => {
134
- recursive(buildFolder, (err, fileNames) => {
135
- var sizes;
136
-
137
- if (!err && fileNames) {
138
- sizes = fileNames.filter(canReadAsset).reduce((memo, fileName) => {
139
- var contents = fs.readFileSync(fileName);
140
- var key = removeFileNameHash(buildFolder, fileName); // save both the original size and gzip size
141
-
142
- memo[key] = [contents.length, gzipSize.sync(contents)];
143
- return memo;
144
- }, {});
145
- }
146
-
147
- resolve({
148
- root: buildFolder,
149
- sizes: sizes || {}
150
- });
151
- });
152
- });
153
- }
154
-
155
- export { measureFileSizesBeforeBuild, printFileSizesAfterBuild };
156
- /* eslint-enable */
@@ -1,74 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- import fs from 'fs';
8
- import path from 'path';
9
- import chalk from 'chalk';
10
- import { readTsConfigByFile } from "./readTsConfig";
11
- import { applyOptionsChain } from "./applyOptionsChain";
12
- export const validAlias = (modernConfig, {
13
- tsconfigPath
14
- }) => {
15
- const {
16
- source: {
17
- alias
18
- }
19
- } = modernConfig;
20
-
21
- if (!alias) {
22
- return null;
23
- }
24
-
25
- const isTsProject = fs.existsSync(tsconfigPath);
26
-
27
- if (!isTsProject) {
28
- return null;
29
- }
30
-
31
- const userAlias = getUserAlias(alias);
32
-
33
- if (Object.keys(userAlias).length > 0) {
34
- return chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
35
- }
36
-
37
- return null;
38
- };
39
- export const getAlias = (aliasOption, option) => {
40
- const isTsProject = fs.existsSync(option.tsconfigPath);
41
- let aliasConfig;
42
-
43
- if (!isTsProject) {
44
- aliasConfig = {
45
- absoluteBaseUrl: option.appDirectory,
46
- paths: applyOptionsChain({
47
- '@': ['./src']
48
- }, aliasOption),
49
- isTsPath: false,
50
- isTsProject
51
- };
52
- } else {
53
- var _tsconfig$compilerOpt, _tsconfig$compilerOpt2;
54
-
55
- const tsconfig = readTsConfigByFile(option.tsconfigPath);
56
- const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt === void 0 ? void 0 : _tsconfig$compilerOpt.baseUrl;
57
- aliasConfig = {
58
- absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
59
- paths: _objectSpread(_objectSpread({}, aliasOption || {}), tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig$compilerOpt2 = tsconfig.compilerOptions) === null || _tsconfig$compilerOpt2 === void 0 ? void 0 : _tsconfig$compilerOpt2.paths),
60
- isTsPath: true,
61
- isTsProject
62
- };
63
- }
64
-
65
- return aliasConfig;
66
- }; // filter invalid ts paths that are not array
67
-
68
- export const getUserAlias = (alias = {}) => Object.keys(alias).reduce((o, k) => {
69
- if (Array.isArray(alias[k])) {
70
- o[k] = alias[k];
71
- }
72
-
73
- return o;
74
- }, {});
@@ -1,27 +0,0 @@
1
- // eslint-disable-next-line import/no-useless-path-segments
2
- import { isFunction, logger, isPlainObject } from "./index";
3
- export const applyOptionsChain = (defaults, options, utils, mergeFn = Object.assign) => {
4
- if (!options) {
5
- return defaults;
6
- }
7
-
8
- if (isPlainObject(options)) {
9
- return mergeFn(defaults, options);
10
- } else if (isFunction(options)) {
11
- const ret = options(defaults, utils);
12
-
13
- if (ret) {
14
- if (!isPlainObject(ret)) {
15
- logger.warn(`${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`);
16
- }
17
-
18
- return ret;
19
- }
20
- } else if (Array.isArray(options)) {
21
- return options.reduce((memo, cur) => applyOptionsChain(memo, cur, utils, mergeFn), defaults);
22
- } else {
23
- throw new Error(`applyOptionsChain error:\ndefault options is: ${JSON.stringify(defaults)}`);
24
- }
25
-
26
- return defaults;
27
- };
@@ -1,2 +0,0 @@
1
- import chalk from 'chalk';
2
- export { chalk };
@@ -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
- };
@@ -1,26 +0,0 @@
1
- import { findExists } from "./findExists";
2
- /**
3
- * Require function compatible with esm and cjs module.
4
- * @param filePath - File to required.
5
- * @returns module export object.
6
- */
7
-
8
- export const compatRequire = filePath => {
9
- const mod = require(filePath);
10
-
11
- return mod !== null && mod !== void 0 && mod.__esModule ? mod.default : mod;
12
- };
13
- export const requireExistModule = (filename, extensions = ['.ts', '.js']) => {
14
- const exist = findExists(extensions.map(ext => `${filename}${ext}`));
15
-
16
- if (!exist) {
17
- return null;
18
- }
19
-
20
- return compatRequire(exist);
21
- };
22
- export const cleanRequireCache = filelist => {
23
- filelist.forEach(filepath => {
24
- delete require.cache[filepath];
25
- });
26
- };