@modern-js/utils 2.69.7 → 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/cjs/cli/alias.js +76 -70
  2. package/dist/cjs/cli/applyOptionsChain.js +44 -45
  3. package/dist/cjs/cli/babel.js +100 -119
  4. package/dist/cjs/cli/commands.js +61 -59
  5. package/dist/cjs/cli/common.js +45 -37
  6. package/dist/cjs/cli/config.js +36 -30
  7. package/dist/cjs/cli/constants.js +124 -161
  8. package/dist/cjs/cli/ensure.js +52 -45
  9. package/dist/cjs/cli/fs.js +41 -38
  10. package/dist/cjs/cli/get/config.js +43 -38
  11. package/dist/cjs/cli/get/data.js +108 -125
  12. package/dist/cjs/cli/get/index.js +109 -58
  13. package/dist/cjs/cli/index.js +202 -63
  14. package/dist/cjs/cli/is/config.js +75 -71
  15. package/dist/cjs/cli/is/env.js +49 -37
  16. package/dist/cjs/cli/is/index.js +76 -25
  17. package/dist/cjs/cli/is/project.js +139 -135
  18. package/dist/cjs/cli/is/type.js +65 -49
  19. package/dist/cjs/cli/logger.js +36 -27
  20. package/dist/cjs/cli/monorepo.js +100 -96
  21. package/dist/cjs/cli/package.js +85 -82
  22. package/dist/cjs/cli/path.js +101 -82
  23. package/dist/cjs/cli/port.js +71 -74
  24. package/dist/cjs/cli/prettyInstructions.js +106 -116
  25. package/dist/cjs/cli/require.js +116 -136
  26. package/dist/cjs/cli/route.js +67 -77
  27. package/dist/cjs/cli/runtimeExports.js +16 -70
  28. package/dist/cjs/cli/version.js +53 -42
  29. package/dist/cjs/cli/watch.js +79 -72
  30. package/dist/cjs/compiled.js +199 -128
  31. package/dist/cjs/import.js +58 -33
  32. package/dist/cjs/index.js +69 -23
  33. package/dist/cjs/universal/constants.js +77 -67
  34. package/dist/cjs/universal/index.js +33 -25
  35. package/dist/cjs/universal/path.js +33 -27
  36. package/dist/cjs/universal/pluginDagSort.js +69 -68
  37. package/dist/compiled/address/index.js +171 -1
  38. package/dist/compiled/browserslist/index.js +1329 -1
  39. package/dist/compiled/chalk/index.js +2368 -1
  40. package/dist/compiled/chokidar/index.js +4138 -16
  41. package/dist/compiled/chokidar/index.js.LICENSE.txt +41 -0
  42. package/dist/compiled/commander/index.js +1540 -1
  43. package/dist/compiled/debug/index.js +621 -1
  44. package/dist/compiled/dotenv/index.js +101 -1
  45. package/dist/compiled/dotenv-expand/index.js +54 -1
  46. package/dist/compiled/execa/index.js +1738 -1
  47. package/dist/compiled/fast-glob/index.js +4645 -17
  48. package/dist/compiled/fast-glob/index.js.LICENSE.txt +38 -0
  49. package/dist/compiled/filesize/index.js +193 -4
  50. package/dist/compiled/filesize/index.js.LICENSE.txt +7 -0
  51. package/dist/compiled/fs-extra/index.js +2222 -1
  52. package/dist/compiled/glob/index.js +2011 -1
  53. package/dist/compiled/globby/index.js +690 -1
  54. package/dist/compiled/gzip-size/index.js +157 -1
  55. package/dist/compiled/import-lazy/index.js +45 -1
  56. package/dist/compiled/inquirer/index.js +20162 -4
  57. package/dist/compiled/inquirer/index.js.LICENSE.txt +7 -0
  58. package/dist/compiled/js-yaml/index.js +2188 -1
  59. package/dist/compiled/json5/index.js +983 -1
  60. package/dist/compiled/lodash/index.js +0 -4
  61. package/dist/compiled/mime-types/index.js +108 -6
  62. package/dist/compiled/mime-types/index.js.LICENSE.txt +13 -0
  63. package/dist/compiled/minimist/index.js +202 -1
  64. package/dist/compiled/nanoid/index.js +83 -1
  65. package/dist/compiled/ora/index.js +3936 -3
  66. package/dist/compiled/ora/index.js.LICENSE.txt +1 -0
  67. package/dist/compiled/pkg-up/index.js +177 -1
  68. package/dist/compiled/semver/index.js +1779 -1
  69. package/dist/compiled/signale/index.js +1704 -1
  70. package/dist/compiled/slash/index.js +32 -1
  71. package/dist/compiled/strip-ansi/index.js +34 -1
  72. package/dist/compiled/tsconfig-paths/index.js +629 -1
  73. package/dist/compiled/upath/index.js +135 -1
  74. package/dist/compiled/url-join/index.js +61 -1
  75. package/dist/compiled/webpack-chain/index.js +1475 -1
  76. package/dist/esm/cli/alias.mjs +31 -0
  77. package/dist/esm/cli/applyOptionsChain.mjs +16 -0
  78. package/dist/esm/cli/babel.mjs +76 -0
  79. package/dist/esm/cli/commands.mjs +23 -0
  80. package/dist/esm/cli/common.mjs +11 -0
  81. package/dist/esm/cli/config.mjs +5 -0
  82. package/dist/esm/cli/constants.mjs +29 -0
  83. package/dist/esm/cli/ensure.mjs +9 -0
  84. package/dist/esm/cli/fs.mjs +9 -0
  85. package/dist/esm/cli/get/config.mjs +14 -0
  86. package/dist/esm/cli/get/data.mjs +57 -0
  87. package/dist/esm/cli/get/index.mjs +18 -0
  88. package/dist/{esm-node/cli/index.js → esm/cli/index.mjs} +0 -1
  89. package/dist/esm/cli/is/config.mjs +34 -0
  90. package/dist/esm/cli/is/env.mjs +6 -0
  91. package/dist/esm/cli/is/project.mjs +104 -0
  92. package/dist/esm/cli/is/type.mjs +26 -0
  93. package/dist/esm/cli/logger.mjs +2 -0
  94. package/dist/esm/cli/monorepo.mjs +50 -0
  95. package/dist/esm/cli/package.mjs +51 -0
  96. package/dist/esm/cli/path.mjs +35 -0
  97. package/dist/esm/cli/port.mjs +35 -0
  98. package/dist/esm/cli/prettyInstructions.mjs +68 -0
  99. package/dist/esm/cli/require.mjs +79 -0
  100. package/dist/esm/cli/route.mjs +36 -0
  101. package/dist/esm/cli/runtimeExports.mjs +0 -0
  102. package/dist/esm/cli/version.mjs +21 -0
  103. package/dist/esm/cli/watch.mjs +40 -0
  104. package/dist/esm/compiled.mjs +115 -0
  105. package/dist/esm/import.mjs +25 -0
  106. package/dist/esm/universal/constants.mjs +13 -0
  107. package/dist/{esm-node/universal/index.js → esm/universal/index.mjs} +1 -3
  108. package/dist/esm/universal/path.mjs +2 -0
  109. package/dist/esm/universal/pluginDagSort.mjs +41 -0
  110. package/dist/esm-node/cli/alias.mjs +31 -0
  111. package/dist/esm-node/cli/applyOptionsChain.mjs +16 -0
  112. package/dist/esm-node/cli/babel.mjs +76 -0
  113. package/dist/esm-node/cli/commands.mjs +23 -0
  114. package/dist/esm-node/cli/common.mjs +11 -0
  115. package/dist/esm-node/cli/config.mjs +5 -0
  116. package/dist/esm-node/cli/constants.mjs +29 -0
  117. package/dist/esm-node/cli/ensure.mjs +9 -0
  118. package/dist/esm-node/cli/fs.mjs +9 -0
  119. package/dist/esm-node/cli/get/config.mjs +14 -0
  120. package/dist/esm-node/cli/get/data.mjs +57 -0
  121. package/dist/esm-node/cli/get/index.mjs +18 -0
  122. package/dist/esm-node/cli/index.mjs +22 -0
  123. package/dist/esm-node/cli/is/config.mjs +34 -0
  124. package/dist/esm-node/cli/is/env.mjs +6 -0
  125. package/dist/esm-node/cli/is/index.mjs +4 -0
  126. package/dist/esm-node/cli/is/project.mjs +104 -0
  127. package/dist/esm-node/cli/is/type.mjs +26 -0
  128. package/dist/esm-node/cli/logger.mjs +2 -0
  129. package/dist/esm-node/cli/monorepo.mjs +50 -0
  130. package/dist/esm-node/cli/package.mjs +51 -0
  131. package/dist/esm-node/cli/path.mjs +35 -0
  132. package/dist/esm-node/cli/port.mjs +35 -0
  133. package/dist/esm-node/cli/prettyInstructions.mjs +68 -0
  134. package/dist/esm-node/cli/require.mjs +79 -0
  135. package/dist/esm-node/cli/route.mjs +36 -0
  136. package/dist/esm-node/cli/runtimeExports.mjs +0 -0
  137. package/dist/esm-node/cli/version.mjs +21 -0
  138. package/dist/esm-node/cli/watch.mjs +40 -0
  139. package/dist/esm-node/compiled.mjs +115 -0
  140. package/dist/esm-node/import.mjs +25 -0
  141. package/dist/esm-node/index.mjs +3 -0
  142. package/dist/esm-node/universal/constants.mjs +13 -0
  143. package/dist/esm-node/universal/index.mjs +2 -0
  144. package/dist/esm-node/universal/path.mjs +2 -0
  145. package/dist/esm-node/universal/pluginDagSort.mjs +41 -0
  146. package/dist/types/cli/constants.d.ts +2 -26
  147. package/dist/types/cli/get/data.d.ts +0 -1
  148. package/dist/types/cli/index.d.ts +0 -1
  149. package/dist/types/cli/is/config.d.ts +1 -1
  150. package/dist/types/cli/runtimeExports.d.ts +1 -4
  151. package/dist/types/cli/watch.d.ts +1 -1
  152. package/dist/types/compiled.d.ts +0 -5
  153. package/dist/types/universal/constants.d.ts +4 -7
  154. package/package.json +27 -27
  155. package/rslib.config.mts +140 -0
  156. package/dist/cjs/cli/action.js +0 -55
  157. package/dist/cjs/universal/formatWebpack.js +0 -127
  158. package/dist/esm/cli/action.js +0 -68
  159. package/dist/esm/cli/alias.js +0 -43
  160. package/dist/esm/cli/applyOptionsChain.js +0 -29
  161. package/dist/esm/cli/babel.js +0 -122
  162. package/dist/esm/cli/commands.js +0 -39
  163. package/dist/esm/cli/common.js +0 -20
  164. package/dist/esm/cli/config.js +0 -11
  165. package/dist/esm/cli/constants.js +0 -114
  166. package/dist/esm/cli/ensure.js +0 -16
  167. package/dist/esm/cli/fs.js +0 -65
  168. package/dist/esm/cli/get/config.js +0 -19
  169. package/dist/esm/cli/get/data.js +0 -143
  170. package/dist/esm/cli/get/index.js +0 -38
  171. package/dist/esm/cli/index.js +0 -23
  172. package/dist/esm/cli/is/config.js +0 -70
  173. package/dist/esm/cli/is/env.js +0 -22
  174. package/dist/esm/cli/is/index.js +0 -4
  175. package/dist/esm/cli/is/project.js +0 -146
  176. package/dist/esm/cli/is/type.js +0 -39
  177. package/dist/esm/cli/logger.js +0 -5
  178. package/dist/esm/cli/monorepo.js +0 -82
  179. package/dist/esm/cli/package.js +0 -203
  180. package/dist/esm/cli/path.js +0 -66
  181. package/dist/esm/cli/port.js +0 -97
  182. package/dist/esm/cli/prettyInstructions.js +0 -102
  183. package/dist/esm/cli/require.js +0 -235
  184. package/dist/esm/cli/route.js +0 -64
  185. package/dist/esm/cli/runtimeExports.js +0 -44
  186. package/dist/esm/cli/version.js +0 -26
  187. package/dist/esm/cli/watch.js +0 -112
  188. package/dist/esm/compiled.js +0 -66
  189. package/dist/esm/import.js +0 -11
  190. package/dist/esm/index.js +0 -3
  191. package/dist/esm/universal/constants.js +0 -32
  192. package/dist/esm/universal/formatWebpack.js +0 -95
  193. package/dist/esm/universal/index.js +0 -4
  194. package/dist/esm/universal/path.js +0 -6
  195. package/dist/esm/universal/pluginDagSort.js +0 -73
  196. package/dist/esm-node/cli/action.js +0 -30
  197. package/dist/esm-node/cli/alias.js +0 -40
  198. package/dist/esm-node/cli/applyOptionsChain.js +0 -27
  199. package/dist/esm-node/cli/babel.js +0 -107
  200. package/dist/esm-node/cli/commands.js +0 -39
  201. package/dist/esm-node/cli/common.js +0 -15
  202. package/dist/esm-node/cli/config.js +0 -9
  203. package/dist/esm-node/cli/constants.js +0 -114
  204. package/dist/esm-node/cli/ensure.js +0 -14
  205. package/dist/esm-node/cli/fs.js +0 -18
  206. package/dist/esm-node/cli/get/config.js +0 -19
  207. package/dist/esm-node/cli/get/data.js +0 -96
  208. package/dist/esm-node/cli/get/index.js +0 -22
  209. package/dist/esm-node/cli/is/config.js +0 -50
  210. package/dist/esm-node/cli/is/env.js +0 -12
  211. package/dist/esm-node/cli/is/project.js +0 -105
  212. package/dist/esm-node/cli/is/type.js +0 -36
  213. package/dist/esm-node/cli/logger.js +0 -5
  214. package/dist/esm-node/cli/monorepo.js +0 -67
  215. package/dist/esm-node/cli/package.js +0 -66
  216. package/dist/esm-node/cli/path.js +0 -48
  217. package/dist/esm-node/cli/port.js +0 -48
  218. package/dist/esm-node/cli/prettyInstructions.js +0 -90
  219. package/dist/esm-node/cli/require.js +0 -111
  220. package/dist/esm-node/cli/route.js +0 -60
  221. package/dist/esm-node/cli/runtimeExports.js +0 -38
  222. package/dist/esm-node/cli/version.js +0 -26
  223. package/dist/esm-node/cli/watch.js +0 -45
  224. package/dist/esm-node/compiled.js +0 -66
  225. package/dist/esm-node/import.js +0 -11
  226. package/dist/esm-node/universal/constants.js +0 -32
  227. package/dist/esm-node/universal/formatWebpack.js +0 -102
  228. package/dist/esm-node/universal/path.js +0 -6
  229. package/dist/esm-node/universal/pluginDagSort.js +0 -50
  230. package/dist/types/cli/action.d.ts +0 -2
  231. package/dist/types/universal/formatWebpack.d.ts +0 -26
  232. /package/dist/{esm-node/cli/is/index.js → esm/cli/is/index.mjs} +0 -0
  233. /package/dist/{esm-node/index.js → esm/index.mjs} +0 -0
@@ -1,60 +0,0 @@
1
- import { lodash } from "../compiled";
2
- const { cloneDeep } = lodash;
3
- function filterRoutesForServer(routes) {
4
- const clonedRoutes = cloneDeep(routes);
5
- const newRoutes = clonedRoutes.map((route) => {
6
- if (route.type !== "nested") {
7
- return route;
8
- }
9
- if (route.children && route.children.length > 0) {
10
- route.children = filterRoutesForServer(route.children);
11
- }
12
- if (route.inValidSSRRoute) {
13
- return null;
14
- }
15
- return route;
16
- }).filter((route) => route !== null);
17
- return newRoutes;
18
- }
19
- function filterRoutesLoader(routes) {
20
- const clonedRoutes = cloneDeep(routes);
21
- const newRoutes = clonedRoutes.map((route) => {
22
- if (route.type !== "nested") {
23
- return route;
24
- }
25
- if (route.children && route.children.length > 0) {
26
- route.children = filterRoutesLoader(route.children);
27
- }
28
- if (route.inValidSSRRoute) {
29
- delete route.loader;
30
- delete route.data;
31
- delete route.action;
32
- }
33
- return route;
34
- }).filter((route) => route !== null);
35
- return newRoutes;
36
- }
37
- function markRoutes(routes, routeIds) {
38
- return routes.map((route) => {
39
- if (route.type !== "nested") {
40
- return route;
41
- }
42
- if (route.children && route.children.length > 0) {
43
- route.children = markRoutes(route.children, routeIds);
44
- }
45
- if (route.children && route.children.length > 0) {
46
- route.inValidSSRRoute = route.children.every((child) => {
47
- var _child_inValidSSRRoute;
48
- return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
49
- });
50
- } else if (route.id) {
51
- route.inValidSSRRoute = !routeIds.includes(route.id);
52
- }
53
- return route;
54
- });
55
- }
56
- export {
57
- filterRoutesForServer,
58
- filterRoutesLoader,
59
- markRoutes
60
- };
@@ -1,38 +0,0 @@
1
- import path from "path";
2
- import { fs } from "../compiled";
3
- import { normalizeOutputPath } from "./path";
4
- const memo = (fn) => {
5
- const cache = /* @__PURE__ */ new Map();
6
- return (...params) => {
7
- const stringifiedParams = JSON.stringify(params);
8
- const cachedResult = cache.get(stringifiedParams);
9
- if (cachedResult) {
10
- return cachedResult;
11
- }
12
- const res = fn(...params);
13
- cache.set(stringifiedParams, res);
14
- return res;
15
- };
16
- };
17
- const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
18
- const entryExportFile = path.join(pwd, `.runtime-exports/${namespace}.js`);
19
- const addExport = (statement) => {
20
- const statementStr = normalizeOutputPath(statement);
21
- try {
22
- fs.ensureFileSync(entryExportFile);
23
- if (!fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
24
- fs.appendFileSync(entryExportFile, `${statementStr}
25
- `);
26
- }
27
- } catch {
28
- }
29
- };
30
- const getPath = () => entryExportFile;
31
- return {
32
- addExport,
33
- getPath
34
- };
35
- });
36
- export {
37
- createRuntimeExportsUtils
38
- };
@@ -1,26 +0,0 @@
1
- function isVersionAtLeast1819() {
2
- const nodeVersion = process.versions.node;
3
- const versionArr = nodeVersion.split(".").map(Number);
4
- return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
5
- }
6
- function isVersionAtLeast18() {
7
- const nodeVersion = process.versions.node;
8
- const versionArr = nodeVersion.split(".").map(Number);
9
- return versionArr[0] >= 18;
10
- }
11
- function isVersionAtLeast22() {
12
- const nodeVersion = process.versions.node;
13
- const versionArr = nodeVersion.split(".").map(Number);
14
- return versionArr[0] >= 22;
15
- }
16
- function isVersionAtLeast20() {
17
- const nodeVersion = process.versions.node;
18
- const versionArr = nodeVersion.split(".").map(Number);
19
- return versionArr[0] >= 20;
20
- }
21
- export {
22
- isVersionAtLeast18,
23
- isVersionAtLeast1819,
24
- isVersionAtLeast20,
25
- isVersionAtLeast22
26
- };
@@ -1,45 +0,0 @@
1
- import path from "path";
2
- import { chokidar } from "../compiled";
3
- const WatchChangeType = {
4
- ADD: "add",
5
- UNLINK: "unlink",
6
- CHANGE: "change"
7
- };
8
- const watch = (watchDir, runTask, ignored = []) => {
9
- let ready = false;
10
- const watcher = chokidar.watch(watchDir, {
11
- ignored
12
- });
13
- watcher.on("ready", () => ready = true);
14
- watcher.on("change", async (filePath) => {
15
- const changedFilePath = path.resolve(filePath);
16
- await runTask({
17
- changedFilePath,
18
- changeType: WatchChangeType.CHANGE
19
- });
20
- });
21
- watcher.on("add", async (filePath) => {
22
- const changedFilePath = path.resolve(filePath);
23
- if (ready) {
24
- await runTask({
25
- changedFilePath,
26
- changeType: WatchChangeType.ADD
27
- });
28
- }
29
- });
30
- watcher.on("unlink", async (filePath) => {
31
- const changedFilePath = path.resolve(filePath);
32
- await runTask({
33
- changedFilePath,
34
- changeType: WatchChangeType.UNLINK
35
- });
36
- });
37
- watcher.on("error", (err) => {
38
- throw err;
39
- });
40
- return watcher;
41
- };
42
- export {
43
- WatchChangeType,
44
- watch
45
- };
@@ -1,66 +0,0 @@
1
- import { Import } from "./import";
2
- import { default as default2 } from "../compiled/fs-extra";
3
- import { default as default3 } from "../compiled/ora";
4
- import { default as default4 } from "../compiled/glob";
5
- import { default as default5 } from "../compiled/js-yaml";
6
- import { default as default6 } from "../compiled/chalk";
7
- import { default as default7 } from "../compiled/debug";
8
- import { default as default8 } from "../compiled/slash";
9
- import { default as default9 } from "../compiled/execa";
10
- import { default as default10 } from "../compiled/json5";
11
- import { default as default11 } from "../compiled/upath";
12
- import { default as default12 } from "../compiled/pkg-up";
13
- import { nanoid } from "../compiled/nanoid";
14
- import { default as default13 } from "../compiled/semver";
15
- import { default as default14 } from "../compiled/dotenv";
16
- import { default as default15 } from "../compiled/lodash";
17
- import { default as default16 } from "../compiled/globby";
18
- import { default as default17 } from "../compiled/address";
19
- import { default as default18 } from "../compiled/signale";
20
- import { default as default19 } from "../compiled/url-join";
21
- import { default as default20 } from "../compiled/minimist";
22
- import { default as default21 } from "../compiled/fast-glob";
23
- import { default as default22 } from "../compiled/filesize";
24
- import { default as default23 } from "../compiled/gzip-size";
25
- import { default as default24 } from "../compiled/strip-ansi";
26
- import { default as default25 } from "../compiled/dotenv-expand";
27
- import { default as default26 } from "../compiled/browserslist";
28
- import { program, Command } from "../compiled/commander";
29
- import { Signale } from "../compiled/signale";
30
- const mime = Import.lazy("../compiled/mime-types", require);
31
- const chokidar = Import.lazy("../compiled/chokidar", require);
32
- const inquirer = Import.lazy("../compiled/inquirer", require);
33
- export {
34
- Command,
35
- Signale,
36
- default17 as address,
37
- default26 as browserslist,
38
- default6 as chalk,
39
- chokidar,
40
- default7 as debug,
41
- default14 as dotenv,
42
- default25 as dotenvExpand,
43
- default9 as execa,
44
- default21 as fastGlob,
45
- default22 as filesize,
46
- default2 as fs,
47
- default4 as glob,
48
- default16 as globby,
49
- default23 as gzipSize,
50
- inquirer,
51
- default10 as json5,
52
- default15 as lodash,
53
- mime,
54
- default20 as minimist,
55
- nanoid,
56
- default3 as ora,
57
- default12 as pkgUp,
58
- program,
59
- default13 as semver,
60
- default18 as signale,
61
- default8 as slash,
62
- default24 as stripAnsi,
63
- default11 as upath,
64
- default19 as urlJoin,
65
- default5 as yaml
66
- };
@@ -1,11 +0,0 @@
1
- const lazy = (moduleName, requireFn) => {
2
- const importLazyLocal = require("../compiled/import-lazy")(requireFn);
3
- return importLazyLocal(moduleName);
4
- };
5
- const Import = {
6
- lazy
7
- };
8
- export {
9
- Import,
10
- lazy as lazyImport
11
- };
@@ -1,32 +0,0 @@
1
- const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
2
- const ROUTE_MODULES = `_routeModules`;
3
- const HMR_SOCK_PATH = "/webpack-hmr";
4
- const HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
5
- const LOADER_REPORTER_NAME = `server-loader`;
6
- const ROUTE_SPEC_FILE = "route.json";
7
- const NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
8
- const MAIN_ENTRY_NAME = "main";
9
- const SERVER_BUNDLE_DIRECTORY = "bundles";
10
- const SERVER_RENDER_FUNCTION_NAME = "serverRender";
11
- const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
12
- const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
13
- const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
14
- const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
15
- const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
16
- export {
17
- HMR_SOCK_PATH,
18
- HTML_CHUNKSMAP_SEPARATOR,
19
- LOADER_REPORTER_NAME,
20
- MAIN_ENTRY_NAME,
21
- NESTED_ROUTE_SPEC_FILE,
22
- ROUTE_MANIFEST,
23
- ROUTE_MODULES,
24
- ROUTE_SPEC_FILE,
25
- SERVER_BUNDLE_DIRECTORY,
26
- SERVER_PLUGIN_BFF,
27
- SERVER_PLUGIN_EXPRESS,
28
- SERVER_PLUGIN_KOA,
29
- SERVER_PLUGIN_POLYFILL,
30
- SERVER_PLUGIN_SERVER,
31
- SERVER_RENDER_FUNCTION_NAME
32
- };
@@ -1,102 +0,0 @@
1
- const friendlySyntaxErrorLabel = "SyntaxError:";
2
- function isLikelyASyntaxError(message) {
3
- return message.includes(friendlySyntaxErrorLabel);
4
- }
5
- function formatMessage(stats) {
6
- let lines = [];
7
- let message;
8
- if (typeof stats === "object") {
9
- const fileName = stats.moduleName ? `File: ${stats.moduleName}
10
- ` : "";
11
- const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
12
- const details = stats.details ? `
13
- Details: ${stats.details}
14
- ` : "";
15
- const stack = stats.stack ? `
16
- ${stats.stack}` : "";
17
- message = `${fileName}${mainMessage}${details}${stack}`;
18
- } else {
19
- message = stats;
20
- }
21
- lines = message.split("\n");
22
- lines = lines.map((line) => {
23
- const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
24
- if (!parsingError) {
25
- return line;
26
- }
27
- const [, errorLine, errorColumn, errorMessage] = parsingError;
28
- return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
29
- });
30
- message = lines.join("\n");
31
- message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)
32
- `);
33
- lines = message.split("\n");
34
- if (lines.length > 2 && lines[1].trim() === "") {
35
- lines.splice(1, 1);
36
- }
37
- lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
38
- if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
39
- lines[1] = lines[1].replace("Error: ", "");
40
- }
41
- lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
42
- message = lines.join("\n");
43
- return message.trim();
44
- }
45
- const noop = (message) => message;
46
- const defaultColor = {
47
- gray: noop,
48
- cyan: noop,
49
- green: noop,
50
- yellow: noop,
51
- underline: noop
52
- };
53
- function addErrorTips(errors, color = defaultColor) {
54
- const errorHelpers = [
55
- {
56
- validator(message) {
57
- return (message.includes("You may need an appropriate loader") || message.includes("You may need an additional loader")) && message.includes(".ts");
58
- },
59
- formatter(message) {
60
- return `${message}
61
-
62
- ${color.yellow(`If it is a TypeScript file, you can use "source.include" config to compile it. see ${color.underline("https://modernjs.dev/en/configure/app/source/include.html")}`)}
63
-
64
- ${color.green(`${color.gray("// config file")}
65
- export default {
66
- source: {
67
- include: [
68
- ${color.gray("// add some include rules")}
69
- ]
70
- }
71
- }`)}
72
- `;
73
- }
74
- }
75
- ];
76
- return errors.map((error) => {
77
- const helper = errorHelpers.find((item) => item.validator(error));
78
- return helper ? helper.formatter(error) : error;
79
- });
80
- }
81
- function formatWebpackMessages(json, color = defaultColor) {
82
- var _json_errors, _json_warnings, _result_errors;
83
- const formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
84
- const formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
85
- const result = {
86
- errors: formattedErrors || [],
87
- warnings: formattedWarnings || [],
88
- errorTips: []
89
- };
90
- if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.some(isLikelyASyntaxError)) {
91
- result.errors = result.errors.filter(isLikelyASyntaxError);
92
- }
93
- if (result.errors.length > 1) {
94
- result.errors.length = 1;
95
- }
96
- result.errors = addErrorTips(result.errors, color);
97
- return result;
98
- }
99
- export {
100
- addErrorTips,
101
- formatWebpackMessages
102
- };
@@ -1,6 +0,0 @@
1
- const cutNameByHyphen = (s) => {
2
- return s.split(/[-_]/)[0];
3
- };
4
- export {
5
- cutNameByHyphen
6
- };
@@ -1,50 +0,0 @@
1
- const pluginDagSort = (plugins, key = "name", preKey = "pre", postKey = "post") => {
2
- let allLines = [];
3
- function getPluginByAny(q) {
4
- const target = plugins.find((item) => typeof q === "string" ? item[key] === q : item[key] === q[key]);
5
- if (!target) {
6
- throw new Error(`plugin ${q} not existed`);
7
- }
8
- return target;
9
- }
10
- plugins.forEach((item) => {
11
- var _item_preKey, _item_postKey;
12
- (_item_preKey = item[preKey]) === null || _item_preKey === void 0 ? void 0 : _item_preKey.forEach((p) => {
13
- if (plugins.find((ap) => ap.name === p)) {
14
- allLines.push([
15
- getPluginByAny(p)[key],
16
- getPluginByAny(item)[key]
17
- ]);
18
- }
19
- });
20
- (_item_postKey = item[postKey]) === null || _item_postKey === void 0 ? void 0 : _item_postKey.forEach((pt) => {
21
- if (plugins.find((ap) => ap.name === pt)) {
22
- allLines.push([
23
- getPluginByAny(item)[key],
24
- getPluginByAny(pt)[key]
25
- ]);
26
- }
27
- });
28
- });
29
- let zeroEndPoints = plugins.filter((item) => !allLines.find((l) => l[1] === item[key]));
30
- const sortedPoint = [];
31
- while (zeroEndPoints.length) {
32
- const zep = zeroEndPoints.shift();
33
- sortedPoint.push(getPluginByAny(zep));
34
- allLines = allLines.filter((l) => l[0] !== getPluginByAny(zep)[key]);
35
- const restPoints = plugins.filter((item) => !sortedPoint.find((sp) => sp[key] === item[key]));
36
- zeroEndPoints = restPoints.filter((item) => !allLines.find((l) => l[1] === item[key]));
37
- }
38
- if (allLines.length) {
39
- const restInRingPoints = {};
40
- allLines.forEach((l) => {
41
- restInRingPoints[l[0]] = true;
42
- restInRingPoints[l[1]] = true;
43
- });
44
- throw new Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(",")}`);
45
- }
46
- return sortedPoint;
47
- };
48
- export {
49
- pluginDagSort
50
- };
@@ -1,2 +0,0 @@
1
- export declare const newAction: (config: Record<string, any>, solution: "module" | "mwa" | "monorepo") => Promise<void>;
2
- export declare const upgradeAction: () => Promise<void>;
@@ -1,26 +0,0 @@
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 type { StatsCompilation } from 'webpack';
9
- export declare function addErrorTips(errors: string[], color?: {
10
- gray: (message: string) => string;
11
- cyan: (message: string) => string;
12
- green: (message: string) => string;
13
- yellow: (message: string) => string;
14
- underline: (message: string) => string;
15
- }): string[];
16
- declare function formatWebpackMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>, color?: {
17
- gray: (message: string) => string;
18
- cyan: (message: string) => string;
19
- green: (message: string) => string;
20
- yellow: (message: string) => string;
21
- underline: (message: string) => string;
22
- }): {
23
- errors: string[];
24
- warnings: string[];
25
- };
26
- export { formatWebpackMessages };
File without changes