@modern-js/utils 1.3.6 → 1.3.8-canary.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (317) hide show
  1. package/.eslintrc.js +9 -0
  2. package/CHANGELOG.md +6 -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/FileSizeReporter.d.ts +16 -0
  91. package/dist/FileSizeReporter.js +151 -0
  92. package/dist/alias.d.ts +21 -0
  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/compatRequire.d.ts +8 -0
  99. package/dist/compatRequire.js +28 -0
  100. package/dist/compiled.d.ts +21 -0
  101. package/dist/compiled.js +33 -0
  102. package/dist/constants.d.ts +222 -0
  103. package/dist/constants.js +277 -0
  104. package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
  105. package/dist/debug.js +11 -0
  106. package/dist/emptyDir.d.ts +1 -0
  107. package/dist/emptyDir.js +19 -0
  108. package/dist/{js/modern/ensureAbsolutePath.js → ensureAbsolutePath.d.ts} +1 -3
  109. package/dist/ensureAbsolutePath.js +15 -0
  110. package/dist/findExists.d.ts +6 -0
  111. package/dist/findExists.js +21 -0
  112. package/dist/format.d.ts +16 -0
  113. package/dist/format.js +113 -0
  114. package/dist/generateMetaTags.d.ts +16 -0
  115. package/dist/generateMetaTags.js +48 -0
  116. package/dist/getBrowserslist.d.ts +2 -0
  117. package/dist/getBrowserslist.js +7 -0
  118. package/dist/getCacheIdentifier.d.ts +7 -0
  119. package/dist/getCacheIdentifier.js +24 -0
  120. package/dist/getEntryOptions.d.ts +1 -0
  121. package/dist/getEntryOptions.js +26 -0
  122. package/dist/getPackageManager.d.ts +1 -0
  123. package/dist/getPackageManager.js +47 -0
  124. package/dist/getPort.d.ts +7 -0
  125. package/dist/getPort.js +62 -0
  126. package/dist/getServerConfig.d.ts +1 -0
  127. package/dist/getServerConfig.js +39 -0
  128. package/dist/import.d.ts +5 -0
  129. package/dist/import.js +10 -0
  130. package/dist/index.d.ts +33 -0
  131. package/dist/index.js +45 -0
  132. package/dist/is/index.d.ts +34 -0
  133. package/dist/is/index.js +82 -0
  134. package/dist/is/node-env.d.ts +4 -0
  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/js/modern/monorepo.js +4 -5
  141. package/dist/js/node/monorepo.js +5 -7
  142. package/dist/js/treeshaking/monorepo.js +7 -6
  143. package/dist/logger.d.ts +63 -0
  144. package/dist/logger.js +128 -0
  145. package/dist/monorepo.d.ts +11 -0
  146. package/dist/monorepo.js +80 -0
  147. package/dist/nodeEnv.d.ts +3 -0
  148. package/dist/nodeEnv.js +49 -0
  149. package/dist/path.d.ts +3 -0
  150. package/dist/path.js +14 -0
  151. package/dist/{types/pkgUp.d.ts → pkgUp.d.ts} +1 -1
  152. package/dist/pkgUp.js +8 -0
  153. package/dist/prettyInstructions.d.ts +6 -0
  154. package/dist/prettyInstructions.js +64 -0
  155. package/dist/printBuildError.d.ts +8 -0
  156. package/dist/printBuildError.js +43 -0
  157. package/dist/readTsConfig.d.ts +2 -0
  158. package/dist/readTsConfig.js +19 -0
  159. package/dist/removeSlash.d.ts +3 -0
  160. package/dist/removeSlash.js +9 -0
  161. package/dist/runtimeExports.d.ts +4 -0
  162. package/dist/runtimeExports.js +53 -0
  163. package/dist/ssrHelpers.d.ts +4 -0
  164. package/dist/ssrHelpers.js +7 -0
  165. package/dist/storage.d.ts +5 -0
  166. package/dist/storage.js +61 -0
  167. package/dist/types/FileSizeReporter.d.ts +5 -5
  168. package/dist/types/alias.d.ts +12 -14
  169. package/dist/types/applyOptionsChain.d.ts +5 -5
  170. package/dist/types/clearConsole.d.ts +1 -1
  171. package/dist/types/compatRequire.d.ts +1 -1
  172. package/dist/types/compiled.d.ts +17 -0
  173. package/dist/types/constants.d.ts +165 -162
  174. package/dist/types/debug.d.ts +1 -3
  175. package/dist/types/emptyDir.d.ts +1 -1
  176. package/dist/types/ensureAbsolutePath.d.ts +1 -1
  177. package/dist/types/findExists.d.ts +1 -1
  178. package/dist/types/format.d.ts +5 -5
  179. package/dist/types/generateMetaTags.d.ts +3 -3
  180. package/dist/types/getBrowserslist.d.ts +1 -1
  181. package/dist/types/getCacheIdentifier.d.ts +3 -3
  182. package/dist/types/getEntryOptions.d.ts +1 -1
  183. package/dist/types/getPackageManager.d.ts +1 -1
  184. package/dist/types/getPort.d.ts +1 -1
  185. package/dist/types/getServerConfig.d.ts +1 -0
  186. package/dist/types/import.d.ts +2 -2
  187. package/dist/types/index.d.ts +3 -4
  188. package/dist/types/is/index.d.ts +1 -4
  189. package/dist/types/is/node-env.d.ts +1 -1
  190. package/dist/types/is/platform.d.ts +1 -1
  191. package/dist/types/is/type.d.ts +1 -1
  192. package/dist/types/logger.d.ts +49 -49
  193. package/dist/types/monorepo.d.ts +3 -3
  194. package/dist/types/nodeEnv.d.ts +1 -1
  195. package/dist/types/path.d.ts +1 -1
  196. package/dist/types/prettyInstructions.d.ts +2 -2
  197. package/dist/types/printBuildError.d.ts +1 -1
  198. package/dist/types/readTsConfig.d.ts +1 -1
  199. package/dist/types/removeSlash.d.ts +1 -1
  200. package/dist/types/runtimeExports.d.ts +3 -3
  201. package/dist/types/wait.d.ts +1 -1
  202. package/dist/types/watch.d.ts +4 -4
  203. package/dist/wait.d.ts +2 -0
  204. package/dist/wait.js +7 -0
  205. package/dist/watch.d.ts +8 -0
  206. package/dist/watch.js +64 -0
  207. package/jest.config.js +0 -1
  208. package/package.json +57 -40
  209. package/tests/debug.test.ts +2 -2
  210. package/tests/is.test.ts +27 -0
  211. package/tests/isPlatform.test.ts +19 -0
  212. package/tests/prettyInstructions.test.ts +1 -1
  213. package/tsconfig.json +3 -5
  214. package/dist/js/modern/FileSizeReporter.js +0 -156
  215. package/dist/js/modern/alias.js +0 -74
  216. package/dist/js/modern/applyOptionsChain.js +0 -27
  217. package/dist/js/modern/chalk.js +0 -2
  218. package/dist/js/modern/clearConsole.js +0 -5
  219. package/dist/js/modern/compatRequire.js +0 -26
  220. package/dist/js/modern/constants.js +0 -333
  221. package/dist/js/modern/emptyDir.js +0 -6
  222. package/dist/js/modern/findExists.js +0 -16
  223. package/dist/js/modern/format.js +0 -137
  224. package/dist/js/modern/generateMetaTags.js +0 -49
  225. package/dist/js/modern/getBrowserslist.js +0 -5
  226. package/dist/js/modern/getCacheIdentifier.js +0 -20
  227. package/dist/js/modern/getEntryOptions.js +0 -24
  228. package/dist/js/modern/getPackageManager.js +0 -37
  229. package/dist/js/modern/getPort.js +0 -52
  230. package/dist/js/modern/import.js +0 -11
  231. package/dist/js/modern/index.js +0 -34
  232. package/dist/js/modern/is/index.js +0 -77
  233. package/dist/js/modern/is/node-env.js +0 -5
  234. package/dist/js/modern/is/platform.js +0 -2
  235. package/dist/js/modern/is/type.js +0 -27
  236. package/dist/js/modern/logger.js +0 -152
  237. package/dist/js/modern/nodeEnv.js +0 -31
  238. package/dist/js/modern/path.js +0 -5
  239. package/dist/js/modern/pkgUp.js +0 -2
  240. package/dist/js/modern/prettyInstructions.js +0 -79
  241. package/dist/js/modern/printBuildError.js +0 -40
  242. package/dist/js/modern/readTsConfig.js +0 -13
  243. package/dist/js/modern/removeSlash.js +0 -3
  244. package/dist/js/modern/runtimeExports.js +0 -52
  245. package/dist/js/modern/wait.js +0 -5
  246. package/dist/js/modern/watch.js +0 -43
  247. package/dist/js/node/FileSizeReporter.js +0 -175
  248. package/dist/js/node/alias.js +0 -97
  249. package/dist/js/node/applyOptionsChain.js +0 -37
  250. package/dist/js/node/chalk.js +0 -15
  251. package/dist/js/node/clearConsole.js +0 -14
  252. package/dist/js/node/compatRequire.js +0 -41
  253. package/dist/js/node/constants.js +0 -353
  254. package/dist/js/node/debug.js +0 -19
  255. package/dist/js/node/emptyDir.js +0 -18
  256. package/dist/js/node/ensureAbsolutePath.js +0 -20
  257. package/dist/js/node/findExists.js +0 -27
  258. package/dist/js/node/format.js +0 -141
  259. package/dist/js/node/generateMetaTags.js +0 -58
  260. package/dist/js/node/getBrowserslist.js +0 -17
  261. package/dist/js/node/getCacheIdentifier.js +0 -27
  262. package/dist/js/node/getEntryOptions.js +0 -35
  263. package/dist/js/node/getPackageManager.js +0 -51
  264. package/dist/js/node/getPort.js +0 -67
  265. package/dist/js/node/import.js +0 -19
  266. package/dist/js/node/index.js +0 -465
  267. package/dist/js/node/is/index.js +0 -150
  268. package/dist/js/node/is/node-env.js +0 -23
  269. package/dist/js/node/is/platform.js +0 -14
  270. package/dist/js/node/is/type.js +0 -48
  271. package/dist/js/node/logger.js +0 -162
  272. package/dist/js/node/nodeEnv.js +0 -45
  273. package/dist/js/node/path.js +0 -24
  274. package/dist/js/node/pkgUp.js +0 -15
  275. package/dist/js/node/prettyInstructions.js +0 -95
  276. package/dist/js/node/printBuildError.js +0 -52
  277. package/dist/js/node/readTsConfig.js +0 -28
  278. package/dist/js/node/removeSlash.js +0 -18
  279. package/dist/js/node/runtimeExports.js +0 -68
  280. package/dist/js/node/wait.js +0 -12
  281. package/dist/js/node/watch.js +0 -61
  282. package/dist/js/treeshaking/FileSizeReporter.js +0 -185
  283. package/dist/js/treeshaking/alias.js +0 -72
  284. package/dist/js/treeshaking/applyOptionsChain.js +0 -31
  285. package/dist/js/treeshaking/chalk.js +0 -2
  286. package/dist/js/treeshaking/clearConsole.js +0 -5
  287. package/dist/js/treeshaking/compatRequire.js +0 -29
  288. package/dist/js/treeshaking/constants.js +0 -333
  289. package/dist/js/treeshaking/debug.js +0 -10
  290. package/dist/js/treeshaking/emptyDir.js +0 -37
  291. package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
  292. package/dist/js/treeshaking/findExists.js +0 -33
  293. package/dist/js/treeshaking/format.js +0 -167
  294. package/dist/js/treeshaking/generateMetaTags.js +0 -55
  295. package/dist/js/treeshaking/getBrowserslist.js +0 -7
  296. package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
  297. package/dist/js/treeshaking/getEntryOptions.js +0 -26
  298. package/dist/js/treeshaking/getPackageManager.js +0 -101
  299. package/dist/js/treeshaking/getPort.js +0 -103
  300. package/dist/js/treeshaking/import.js +0 -11
  301. package/dist/js/treeshaking/index.js +0 -34
  302. package/dist/js/treeshaking/is/index.js +0 -81
  303. package/dist/js/treeshaking/is/node-env.js +0 -13
  304. package/dist/js/treeshaking/is/platform.js +0 -6
  305. package/dist/js/treeshaking/is/type.js +0 -29
  306. package/dist/js/treeshaking/logger.js +0 -188
  307. package/dist/js/treeshaking/nodeEnv.js +0 -108
  308. package/dist/js/treeshaking/path.js +0 -11
  309. package/dist/js/treeshaking/pkgUp.js +0 -2
  310. package/dist/js/treeshaking/prettyInstructions.js +0 -100
  311. package/dist/js/treeshaking/printBuildError.js +0 -40
  312. package/dist/js/treeshaking/readTsConfig.js +0 -13
  313. package/dist/js/treeshaking/removeSlash.js +0 -9
  314. package/dist/js/treeshaking/runtimeExports.js +0 -61
  315. package/dist/js/treeshaking/wait.js +0 -8
  316. package/dist/js/treeshaking/watch.js +0 -112
  317. package/dist/types/chalk.d.ts +0 -2
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_SCHEMAS = exports.INTERNAL_PLUGINS = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
4
+ /**
5
+ * hmr socket connect path
6
+ */
7
+ exports.HMR_SOCK_PATH = '/_modern_js_hmr_ws';
8
+ /**
9
+ * route specification file
10
+ */
11
+ exports.ROUTE_SPEC_FILE = 'route.json';
12
+ /**
13
+ * main entry name
14
+ */
15
+ exports.MAIN_ENTRY_NAME = 'main';
16
+ /**
17
+ * open editor request path
18
+ */
19
+ exports.LAUNCH_EDITOR_ENDPOINT = '/__open-stack-frame-in-editor';
20
+ /**
21
+ * server side bundles directory, which relative to dist.
22
+ */
23
+ exports.SERVER_BUNDLE_DIRECTORY = 'bundles';
24
+ /**
25
+ * entry name pattern used for ajv pattern properties.
26
+ */
27
+ exports.ENTRY_NAME_PATTERN = '^[a-zA-Z0-9_-]+$';
28
+ /**
29
+ * SSR server render function name
30
+ */
31
+ exports.SERVER_RENDER_FUNCTION_NAME = 'serverRender';
32
+ /**
33
+ * loadbale manifest json file
34
+ */
35
+ exports.LOADABLE_STATS_FILE = 'loadable-stats.json';
36
+ /**
37
+ * internal specified folder
38
+ */
39
+ exports.API_DIR = 'api';
40
+ exports.SERVER_DIR = 'server';
41
+ exports.SHARED_DIR = 'shared';
42
+ /**
43
+ * Modern.config.ts cached dir
44
+ */
45
+ exports.CONFIG_CACHE_DIR = './node_modules/.node-bundle-require';
46
+ exports.CONFIG_FILE_EXTENSIONS = ['.js', '.ts', '.ejs', '.mjs'];
47
+ /**
48
+ * Serialized config path
49
+ */
50
+ exports.OUTPUT_CONFIG_FILE = 'modern.config.json';
51
+ /**
52
+ * Default server config basename
53
+ */
54
+ exports.DEFAULT_SERVER_CONFIG = 'modern.server-runtime.config';
55
+ /**
56
+ * Internal plugins that work as soon as they are installed.
57
+ */
58
+ exports.INTERNAL_PLUGINS = {
59
+ '@modern-js/app-tools': { cli: '@modern-js/app-tools/cli' },
60
+ '@modern-js/monorepo-tools': { cli: '@modern-js/monorepo-tools/cli' },
61
+ '@modern-js/module-tools': { cli: '@modern-js/module-tools/cli' },
62
+ '@modern-js/runtime': { cli: '@modern-js/runtime/cli' },
63
+ '@modern-js/plugin-less': { cli: '@modern-js/plugin-less/cli' },
64
+ '@modern-js/plugin-sass': { cli: '@modern-js/plugin-sass/cli' },
65
+ '@modern-js/plugin-esbuild': { cli: '@modern-js/plugin-esbuild/cli' },
66
+ '@modern-js/plugin-proxy': { cli: '@modern-js/plugin-proxy/cli' },
67
+ '@modern-js/plugin-ssg': { cli: '@modern-js/plugin-ssg/cli' },
68
+ '@modern-js/plugin-bff': {
69
+ cli: '@modern-js/plugin-bff/cli',
70
+ server: '@modern-js/plugin-bff/server',
71
+ },
72
+ '@modern-js/plugin-electron': { cli: '@modern-js/plugin-electron/cli' },
73
+ '@modern-js/plugin-testing': { cli: '@modern-js/plugin-testing/cli' },
74
+ '@modern-js/plugin-storybook': { cli: '@modern-js/plugin-storybook/cli' },
75
+ '@modern-js/plugin-docsite': { cli: '@modern-js/plugin-docsite/cli' },
76
+ '@modern-js/plugin-express': {
77
+ cli: '@modern-js/plugin-express/cli',
78
+ server: '@modern-js/plugin-express',
79
+ },
80
+ '@modern-js/plugin-egg': {
81
+ cli: '@modern-js/plugin-egg/cli',
82
+ server: '@modern-js/plugin-egg',
83
+ },
84
+ '@modern-js/plugin-koa': {
85
+ cli: '@modern-js/plugin-koa/cli',
86
+ server: '@modern-js/plugin-koa',
87
+ },
88
+ '@modern-js/plugin-nest': {
89
+ cli: '@modern-js/plugin-nest/cli',
90
+ server: '@modern-js/plugin-nest/server',
91
+ },
92
+ '@modern-js/plugin-unbundle': { cli: '@modern-js/plugin-unbundle' },
93
+ '@modern-js/plugin-server-build': { cli: '@modern-js/plugin-server-build' },
94
+ '@modern-js/plugin-server': {
95
+ cli: '@modern-js/plugin-server/cli',
96
+ server: '@modern-js/plugin-server/server',
97
+ },
98
+ '@modern-js/plugin-garfish': {
99
+ cli: '@modern-js/plugin-garfish/cli',
100
+ },
101
+ '@modern-js/plugin-jarvis': { cli: '@modern-js/plugin-jarvis/cli' },
102
+ '@modern-js/plugin-tailwindcss': { cli: '@modern-js/plugin-tailwindcss/cli' },
103
+ '@modern-js/plugin-lambda-fc': { cli: '@modern-js/plugin-lambda-fc/cli' },
104
+ '@modern-js/plugin-lambda-scf': { cli: '@modern-js/plugin-lambda-scf/cli' },
105
+ '@modern-js/plugin-cdn-oss': { cli: '@modern-js/plugin-cdn-oss/cli' },
106
+ '@modern-js/plugin-cdn-cos': { cli: '@modern-js/plugin-cdn-cos/cli' },
107
+ '@modern-js/plugin-static-hosting': {
108
+ cli: '@modern-js/plugin-static-hosting/cli',
109
+ },
110
+ '@modern-js/plugin-polyfill': {
111
+ cli: '@modern-js/plugin-polyfill/cli',
112
+ server: '@modern-js/plugin-polyfill',
113
+ },
114
+ '@modern-js/plugin-multiprocess': {
115
+ cli: '@modern-js/plugin-multiprocess/cli',
116
+ },
117
+ '@modern-js/plugin-nocode': { cli: '@modern-js/plugin-nocode/cli' },
118
+ '@modern-js/plugin-design-token': {
119
+ cli: '@modern-js/plugin-design-token/cli',
120
+ },
121
+ };
122
+ /**
123
+ * The schema registered in the plugin.
124
+ */
125
+ exports.PLUGIN_SCHEMAS = {
126
+ '@modern-js/runtime': [
127
+ {
128
+ target: 'runtime',
129
+ schema: {
130
+ type: 'object',
131
+ additionalProperties: false,
132
+ },
133
+ },
134
+ {
135
+ target: 'runtimeByEntries',
136
+ schema: {
137
+ type: 'object',
138
+ patternProperties: { [exports.ENTRY_NAME_PATTERN]: { type: 'object' } },
139
+ additionalProperties: false,
140
+ },
141
+ },
142
+ ],
143
+ '@modern-js/plugin-bff': [
144
+ {
145
+ target: 'bff',
146
+ schema: {
147
+ type: 'object',
148
+ properties: {
149
+ prefix: {
150
+ type: ['string', 'array'],
151
+ items: { type: 'string' },
152
+ },
153
+ fetcher: { type: 'string' },
154
+ proxy: { type: 'object' },
155
+ requestCreator: { type: 'string' },
156
+ },
157
+ },
158
+ },
159
+ ],
160
+ '@modern-js/plugin-esbuild': [
161
+ {
162
+ target: 'tools.esbuild',
163
+ schema: { typeof: ['object'] },
164
+ },
165
+ ],
166
+ '@modern-js/plugin-less': [
167
+ {
168
+ target: 'tools.less',
169
+ schema: { typeof: ['object', 'function'] },
170
+ },
171
+ ],
172
+ '@modern-js/plugin-sass': [
173
+ {
174
+ target: 'tools.sass',
175
+ schema: { typeof: ['object', 'function'] },
176
+ },
177
+ ],
178
+ '@modern-js/plugin-tailwindcss': [
179
+ {
180
+ target: 'tools.tailwindcss',
181
+ schema: { typeof: ['object', 'function'] },
182
+ },
183
+ ],
184
+ '@modern-js/plugin-proxy': [
185
+ {
186
+ target: 'dev.proxy',
187
+ schema: { typeof: ['string', 'object'] },
188
+ },
189
+ ],
190
+ '@modern-js/plugin-unbundle': [
191
+ {
192
+ target: 'output.disableAutoImportStyle',
193
+ schema: { type: 'boolean' },
194
+ },
195
+ {
196
+ target: 'dev.unbundle',
197
+ schema: {
198
+ type: 'object',
199
+ properties: {
200
+ ignore: {
201
+ type: ['string', 'array'],
202
+ items: { type: 'string' },
203
+ },
204
+ ignoreModuleCache: { type: 'boolean' },
205
+ clearPdnCache: { type: 'boolean' },
206
+ pdnHost: { type: 'string' },
207
+ },
208
+ },
209
+ },
210
+ ],
211
+ '@modern-js/plugin-ssg': [
212
+ {
213
+ target: 'output.ssg',
214
+ schema: {
215
+ oneOf: [
216
+ { type: 'boolean' },
217
+ { type: 'object' },
218
+ { instanceof: 'Function' },
219
+ ],
220
+ },
221
+ },
222
+ ],
223
+ '@modern-js/plugin-ssr': [
224
+ {
225
+ target: 'runtime.ssr',
226
+ schema: { type: ['boolean', 'object'] },
227
+ },
228
+ ],
229
+ '@modern-js/plugin-state': [
230
+ {
231
+ target: 'runtime.state',
232
+ schema: { type: ['boolean', 'object'] },
233
+ },
234
+ ],
235
+ '@modern-js/plugin-design-token': [
236
+ // Legacy Features
237
+ {
238
+ target: 'source.designSystem',
239
+ schema: { typeof: ['object'] },
240
+ },
241
+ {
242
+ target: 'source.designSystem.supportStyledComponents',
243
+ schema: { type: ['boolean'] },
244
+ },
245
+ ],
246
+ '@modern-js/plugin-router': [
247
+ {
248
+ target: 'runtime.router',
249
+ schema: { type: ['boolean', 'object'] },
250
+ },
251
+ ],
252
+ '@modern-js/plugin-testing': [
253
+ {
254
+ target: 'testing',
255
+ schema: { typeof: ['object'] },
256
+ },
257
+ {
258
+ target: 'tools.jest',
259
+ schema: { typeof: ['object', 'function'] },
260
+ },
261
+ ],
262
+ '@modern-js/plugin-garfish': [
263
+ {
264
+ target: 'runtime.masterApp',
265
+ schema: { type: ['boolean', 'object'] },
266
+ },
267
+ {
268
+ target: 'dev.withMasterApp',
269
+ schema: { type: ['object'] },
270
+ },
271
+ {
272
+ target: 'deploy.microFrontend',
273
+ schema: { type: ['boolean', 'object'] },
274
+ },
275
+ ],
276
+ '@modern-js/plugin-nocode': [],
277
+ };
@@ -1,8 +1,6 @@
1
- import debug from 'debug';
2
1
  /**
3
2
  * Create debug function with unified namespace prefix.
4
3
  * @param scope - Custom module name of your debug function.
5
4
  * @returns Debug function which namespace start with modern-js:.
6
5
  */
7
-
8
- export const createDebugger = scope => debug(`modern-js:${scope}`);
6
+ export declare const createDebugger: (scope: string) => import("../compiled/debug").Debugger;
package/dist/debug.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDebugger = void 0;
4
+ const debug_1 = require("../compiled/debug");
5
+ /**
6
+ * Create debug function with unified namespace prefix.
7
+ * @param scope - Custom module name of your debug function.
8
+ * @returns Debug function which namespace start with modern-js:.
9
+ */
10
+ const createDebugger = (scope) => (0, debug_1.debug)(`modern-js:${scope}`);
11
+ exports.createDebugger = createDebugger;
@@ -0,0 +1 @@
1
+ export declare const emptyDir: (dir: string) => Promise<void>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.emptyDir = void 0;
13
+ const compiled_1 = require("./compiled");
14
+ const emptyDir = (dir) => __awaiter(void 0, void 0, void 0, function* () {
15
+ if (yield compiled_1.fs.pathExists(dir)) {
16
+ yield compiled_1.fs.emptyDir(dir);
17
+ }
18
+ });
19
+ exports.emptyDir = emptyDir;
@@ -1,9 +1,7 @@
1
- import path from 'path';
2
1
  /**
3
2
  * ensure absolute file path.
4
3
  * @param base - Base path to resolve relative from.
5
4
  * @param filePath - Aboluste or relative file path.
6
5
  * @returns Resolved absolute file path.
7
6
  */
8
-
9
- export const ensureAbsolutePath = (base, filePath) => path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
7
+ export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ensureAbsolutePath = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ /**
9
+ * ensure absolute file path.
10
+ * @param base - Base path to resolve relative from.
11
+ * @param filePath - Aboluste or relative file path.
12
+ * @returns Resolved absolute file path.
13
+ */
14
+ const ensureAbsolutePath = (base, filePath) => path_1.default.isAbsolute(filePath) ? filePath : path_1.default.resolve(base, filePath);
15
+ exports.ensureAbsolutePath = ensureAbsolutePath;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Find first already exists file.
3
+ * @param files - Asbolute file paths with extension.
4
+ * @returns The file path if exists, or false if no file exists.
5
+ */
6
+ export declare const findExists: (files: string[]) => string | false;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.findExists = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ /**
9
+ * Find first already exists file.
10
+ * @param files - Asbolute file paths with extension.
11
+ * @returns The file path if exists, or false if no file exists.
12
+ */
13
+ const findExists = (files) => {
14
+ for (const file of files) {
15
+ if (fs_1.default.existsSync(file) && fs_1.default.statSync(file).isFile()) {
16
+ return file;
17
+ }
18
+ }
19
+ return false;
20
+ };
21
+ exports.findExists = findExists;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file at
6
+ * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
+ */
8
+ import { StatsCompilation } from 'webpack';
9
+ import type { ProxyDetail, BffProxyOptions } from '@modern-js/types';
10
+ declare function formatWebpackMessages(json: StatsCompilation): {
11
+ errors: string[];
12
+ warnings: string[];
13
+ };
14
+ export { formatWebpackMessages };
15
+ declare function formatProxyOptions(proxyOptions: BffProxyOptions): ProxyDetail[];
16
+ export { formatProxyOptions };
package/dist/format.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /* eslint-disable no-param-reassign */
3
+ /**
4
+ * Copyright (c) 2015-present, Facebook, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file at
8
+ * https://github.com/facebook/create-react-app/blob/master/LICENSE
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.formatProxyOptions = exports.formatWebpackMessages = void 0;
12
+ const friendlySyntaxErrorLabel = 'Syntax error:';
13
+ function isLikelyASyntaxError(message) {
14
+ return message.includes(friendlySyntaxErrorLabel);
15
+ }
16
+ // Cleans up webpack error messages.
17
+ function formatMessage(message) {
18
+ var _a;
19
+ let lines = [];
20
+ // webpack 5 stats error object
21
+ if (typeof message === 'object') {
22
+ message = `${(message.moduleName && `${message.moduleName}\n`)}${message.details || message.stack || message.message}`;
23
+ }
24
+ lines = message.split('\n');
25
+ // Strip webpack-added headers off errors/warnings
26
+ // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
27
+ lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line));
28
+ // Transform parsing error into syntax error
29
+ lines = lines.map(line => {
30
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
31
+ if (!parsingError) {
32
+ return line;
33
+ }
34
+ const [, errorLine, errorColumn, errorMessage] = parsingError;
35
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
36
+ });
37
+ message = lines.join('\n');
38
+ // Smoosh syntax errors (commonly found in CSS)
39
+ message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`);
40
+ lines = message.split('\n');
41
+ // Remove leading newline
42
+ if (lines.length > 2 && lines[1].trim() === '') {
43
+ lines.splice(1, 1);
44
+ }
45
+ // Clean up file name
46
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
47
+ // Cleans up verbose "module not found" messages for files and packages.
48
+ if ((_a = lines[1]) === null || _a === void 0 ? void 0 : _a.startsWith('Module not found: ')) {
49
+ lines = [
50
+ lines[0],
51
+ lines[1]
52
+ .replace('Error: ', '')
53
+ .replace('Module not found: Cannot find file:', 'Cannot find file:')
54
+ .replace('[CaseSensitivePathsPlugin] ', '')
55
+ .replace("Cannot resolve 'file' or 'directory' ", ''),
56
+ ];
57
+ }
58
+ message = lines.join('\n');
59
+ // Internal stacks are generally useless so we strip them... with the
60
+ // exception of stacks containing `webpack:` because they're normally
61
+ // from user code generated by webpack. For more information see
62
+ // https://github.com/facebook/create-react-app/pull/1050
63
+ message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
64
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
65
+ lines = message.split('\n');
66
+ // Remove duplicated newlines
67
+ lines = lines.filter((line, index, arr) => index === 0 ||
68
+ line.trim() !== '' ||
69
+ line.trim() !== arr[index - 1].trim());
70
+ // Reassemble the message
71
+ message = lines.join('\n');
72
+ return message.trim();
73
+ }
74
+ function formatWebpackMessages(json) {
75
+ var _a, _b, _c;
76
+ const formattedErrors = (_a = json.errors) === null || _a === void 0 ? void 0 : _a.map(formatMessage);
77
+ const formattedWarnings = (_b = json.warnings) === null || _b === void 0 ? void 0 : _b.map(formatMessage);
78
+ const result = {
79
+ errors: formattedErrors || [],
80
+ warnings: formattedWarnings || [],
81
+ };
82
+ if ((_c = result.errors) === null || _c === void 0 ? void 0 : _c.some(isLikelyASyntaxError)) {
83
+ // If there are any syntax errors, show just them.
84
+ result.errors = result.errors.filter(isLikelyASyntaxError);
85
+ }
86
+ // First error is usually it.
87
+ if (result.errors.length > 1) {
88
+ result.errors.length = 1;
89
+ }
90
+ return result;
91
+ }
92
+ exports.formatWebpackMessages = formatWebpackMessages;
93
+ /* eslint-enable no-param-reassign */
94
+ function formatProxyOptions(proxyOptions) {
95
+ const formatedProxy = [];
96
+ if (!Array.isArray(proxyOptions)) {
97
+ if ('target' in proxyOptions) {
98
+ formatedProxy.push(proxyOptions);
99
+ }
100
+ else {
101
+ Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce((total, source) => {
102
+ const option = proxyOptions[source];
103
+ total.push(Object.assign({ context: source, changeOrigin: true, logLevel: 'warn' }, (typeof option === 'string' ? { target: option } : option)));
104
+ return total;
105
+ }, []));
106
+ }
107
+ }
108
+ else {
109
+ formatedProxy.push(...proxyOptions);
110
+ }
111
+ return formatedProxy;
112
+ }
113
+ exports.formatProxyOptions = formatProxyOptions;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright JS Foundation and other contributors.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file at
6
+ * https://github.com/jantimon/html-webpack-plugin/blob/main/LICENSE
7
+ *
8
+ * Modified from https://github.com/jantimon/html-webpack-plugin/blob/2f5de7ab9e8bca60e9e200f2e4b4cfab90db28d4/index.js#L800
9
+ */
10
+ export declare type MetaAttributes = {
11
+ [attributeName: string]: string | boolean;
12
+ };
13
+ export interface MetaOptions {
14
+ [name: string]: string | false | MetaAttributes;
15
+ }
16
+ export declare const generateMetaTags: (metaOptions?: MetaOptions | undefined) => string;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateMetaTags = void 0;
4
+ const tagObjectToString = (tagDefinition) => {
5
+ const attributes = Object.keys(tagDefinition.attributes || {})
6
+ .filter(attributeName => tagDefinition.attributes[attributeName] !== false)
7
+ .map(attributeName => {
8
+ if (tagDefinition.attributes[attributeName] === true) {
9
+ return attributeName;
10
+ }
11
+ return `${attributeName}="${tagDefinition.attributes[attributeName]}"`;
12
+ });
13
+ return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${tagDefinition.innerHTML || ''}${tagDefinition.voidTag ? '' : `</${tagDefinition.tagName}>`}`;
14
+ };
15
+ const generateMetaTags = (metaOptions) => {
16
+ if (!metaOptions) {
17
+ return '';
18
+ }
19
+ // Make tags self-closing in case of xhtml
20
+ // Turn { "viewport" : "width=500, initial-scale=1" } into
21
+ // [{ name:"viewport" content:"width=500, initial-scale=1" }]
22
+ const metaTagAttributeObjects = Object.keys(metaOptions)
23
+ .map(metaName => {
24
+ const metaTagContent = metaOptions[metaName];
25
+ return typeof metaTagContent === 'string'
26
+ ? {
27
+ name: metaName,
28
+ content: metaTagContent,
29
+ }
30
+ : metaTagContent;
31
+ })
32
+ .filter(attribute => attribute !== false);
33
+ // Turn [{ name:"viewport" content:"width=500, initial-scale=1" }] into
34
+ // the html-webpack-plugin tag structure
35
+ return metaTagAttributeObjects
36
+ .map(metaTagAttributes => {
37
+ if (metaTagAttributes === false) {
38
+ throw new Error('Invalid meta tag');
39
+ }
40
+ return {
41
+ tagName: 'meta',
42
+ voidTag: true,
43
+ attributes: metaTagAttributes,
44
+ };
45
+ })
46
+ .reduce((memo, tagObject) => `${memo}\n${tagObjectToString(tagObject)}`, '');
47
+ };
48
+ exports.generateMetaTags = generateMetaTags;
@@ -0,0 +1,2 @@
1
+ export declare const defaults: string[];
2
+ export declare const getBrowserslist: (appDirectory: string) => string[];
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBrowserslist = exports.defaults = void 0;
4
+ const compiled_1 = require("./compiled");
5
+ exports.defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
6
+ const getBrowserslist = (appDirectory) => compiled_1.browserslist.loadConfig({ path: appDirectory }) || exports.defaults;
7
+ exports.getBrowserslist = getBrowserslist;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generate cache identifier from some packages and config files.
3
+ */
4
+ export declare function getCacheIdentifier(packages: {
5
+ name: string;
6
+ version: string;
7
+ }[], _files?: string[]): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCacheIdentifier = void 0;
4
+ const is_1 = require("./is");
5
+ /**
6
+ * Generate cache identifier from some packages and config files.
7
+ */
8
+ function getCacheIdentifier(packages, _files) {
9
+ /* eslint-disable no-nested-ternary */
10
+ let cacheIdentifier = (0, is_1.isProd)()
11
+ ? 'production'
12
+ : (0, is_1.isDev)()
13
+ ? 'development'
14
+ : (0, is_1.isTest)()
15
+ ? 'test'
16
+ : '';
17
+ /* eslint-enable no-nested-ternary */
18
+ for (const { name, version } of packages) {
19
+ cacheIdentifier += `:${name}@${version}`;
20
+ }
21
+ // TODO: config file hash
22
+ return cacheIdentifier;
23
+ }
24
+ exports.getCacheIdentifier = getCacheIdentifier;
@@ -0,0 +1 @@
1
+ export declare const getEntryOptions: <T>(name: string, baseOptions?: T | undefined, optionsByEntries?: Record<string, T> | undefined, packageName?: string | undefined) => T | undefined;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEntryOptions = void 0;
4
+ const is_1 = require("./is");
5
+ const constants_1 = require("./constants");
6
+ const getEntryOptions = (name, baseOptions, optionsByEntries, packageName) => {
7
+ if (optionsByEntries) {
8
+ let optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
9
+ // compatible with main entry using packageName as the key
10
+ if (optionsByEntry === undefined &&
11
+ name === constants_1.MAIN_ENTRY_NAME &&
12
+ packageName) {
13
+ optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
14
+ }
15
+ // eslint-disable-next-line no-nested-ternary
16
+ return optionsByEntry !== undefined
17
+ ? (0, is_1.isPlainObject)(optionsByEntry) && (0, is_1.isPlainObject)(baseOptions)
18
+ ? Object.assign(Object.assign({}, baseOptions), optionsByEntry) : optionsByEntry
19
+ : baseOptions;
20
+ }
21
+ else {
22
+ return baseOptions;
23
+ }
24
+ };
25
+ exports.getEntryOptions = getEntryOptions;
26
+ const getOptionsByEntryName = (name, optionsByEntries) => optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : undefined;
@@ -0,0 +1 @@
1
+ export declare function getPackageManager(cwd?: string): Promise<"npm" | "yarn" | "pnpm">;