@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,235 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
- import { isAbsolute } from "node:path";
5
- import { pathToFileURL } from "node:url";
6
- import { findExists } from "./fs";
7
- function compatibleRequire(path) {
8
- return _compatibleRequire.apply(this, arguments);
9
- }
10
- function _compatibleRequire() {
11
- _compatibleRequire = _async_to_generator(function(path) {
12
- var interop, requiredModule, err, modulePath, timestamp;
13
- var _arguments = arguments;
14
- return _ts_generator(this, function(_state) {
15
- switch (_state.label) {
16
- case 0:
17
- interop = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : true;
18
- if (path.endsWith(".json")) {
19
- return [
20
- 2,
21
- require(path)
22
- ];
23
- }
24
- _state.label = 1;
25
- case 1:
26
- _state.trys.push([
27
- 1,
28
- 2,
29
- ,
30
- 9
31
- ]);
32
- requiredModule = require(path);
33
- return [
34
- 3,
35
- 9
36
- ];
37
- case 2:
38
- err = _state.sent();
39
- if (!(err.code === "ERR_REQUIRE_ESM"))
40
- return [
41
- 3,
42
- 7
43
- ];
44
- modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
45
- if (!(process.env.NODE_ENV === "development"))
46
- return [
47
- 3,
48
- 4
49
- ];
50
- timestamp = Date.now();
51
- return [
52
- 4,
53
- import("".concat(modulePath, "?t=").concat(timestamp))
54
- ];
55
- case 3:
56
- requiredModule = _state.sent();
57
- return [
58
- 3,
59
- 6
60
- ];
61
- case 4:
62
- return [
63
- 4,
64
- import(modulePath)
65
- ];
66
- case 5:
67
- requiredModule = _state.sent();
68
- _state.label = 6;
69
- case 6:
70
- return [
71
- 2,
72
- interop ? requiredModule.default : requiredModule
73
- ];
74
- case 7:
75
- throw err;
76
- case 8:
77
- return [
78
- 3,
79
- 9
80
- ];
81
- case 9:
82
- return [
83
- 2,
84
- interop && (requiredModule === null || requiredModule === void 0 ? void 0 : requiredModule.__esModule) ? requiredModule.default : requiredModule
85
- ];
86
- }
87
- });
88
- });
89
- return _compatibleRequire.apply(this, arguments);
90
- }
91
- function loadFromProject(moduleName, appDir) {
92
- return _loadFromProject.apply(this, arguments);
93
- }
94
- function _loadFromProject() {
95
- _loadFromProject = _async_to_generator(function(moduleName, appDir) {
96
- var requiredModule, paths, modulePath, createRequire, _$require, modulePath1, moduleUrl, error;
97
- return _ts_generator(this, function(_state) {
98
- switch (_state.label) {
99
- case 0:
100
- paths = [
101
- appDir,
102
- process.cwd()
103
- ];
104
- _state.label = 1;
105
- case 1:
106
- _state.trys.push([
107
- 1,
108
- 6,
109
- ,
110
- 7
111
- ]);
112
- if (!(typeof require !== "undefined"))
113
- return [
114
- 3,
115
- 2
116
- ];
117
- modulePath = require.resolve(moduleName, {
118
- paths
119
- });
120
- requiredModule = require(modulePath);
121
- return [
122
- 3,
123
- 5
124
- ];
125
- case 2:
126
- return [
127
- 4,
128
- import("node:module")
129
- ];
130
- case 3:
131
- createRequire = _state.sent().createRequire;
132
- _$require = createRequire(import.meta.url);
133
- modulePath1 = _$require.resolve(moduleName, {
134
- paths
135
- });
136
- moduleUrl = pathToFileURL(modulePath1).href;
137
- return [
138
- 4,
139
- import(moduleUrl)
140
- ];
141
- case 4:
142
- requiredModule = _state.sent();
143
- _state.label = 5;
144
- case 5:
145
- return [
146
- 2,
147
- requiredModule.default || requiredModule
148
- ];
149
- case 6:
150
- error = _state.sent();
151
- if (error.code === "MODULE_NOT_FOUND") {
152
- throw new Error("Cannot find module ".concat(moduleName, "."));
153
- }
154
- throw error;
155
- case 7:
156
- return [
157
- 2
158
- ];
159
- }
160
- });
161
- });
162
- return _loadFromProject.apply(this, arguments);
163
- }
164
- var dynamicImport = new Function("modulePath", "return import(modulePath)");
165
- var requireExistModule = function() {
166
- var _ref = _async_to_generator(function(filename, opt) {
167
- var final, exist;
168
- return _ts_generator(this, function(_state) {
169
- final = _object_spread({
170
- extensions: [
171
- ".ts",
172
- ".js"
173
- ],
174
- interop: true
175
- }, opt);
176
- exist = findExists(final.extensions.map(function(ext) {
177
- return "".concat(filename).concat(ext);
178
- }));
179
- if (!exist) {
180
- return [
181
- 2,
182
- null
183
- ];
184
- }
185
- return [
186
- 2,
187
- compatibleRequire(exist, final.interop)
188
- ];
189
- });
190
- });
191
- return function requireExistModule2(filename, opt) {
192
- return _ref.apply(this, arguments);
193
- };
194
- }();
195
- var cleanRequireCache = function(filelist) {
196
- filelist.forEach(function(filepath) {
197
- delete require.cache[filepath];
198
- });
199
- };
200
- function deleteRequireCache(path) {
201
- if (require.cache[path]) {
202
- delete require.cache[path];
203
- }
204
- if (module.children) {
205
- module.children = module.children.filter(function(item) {
206
- return item.filename !== path;
207
- });
208
- }
209
- }
210
- var tryResolve = function(name, resolvePath) {
211
- var filePath = "";
212
- try {
213
- filePath = require.resolve(name, {
214
- paths: [
215
- resolvePath
216
- ]
217
- });
218
- delete require.cache[filePath];
219
- } catch (err) {
220
- if (err.code === "MODULE_NOT_FOUND") {
221
- throw new Error("Can not find module ".concat(name, "."));
222
- }
223
- throw err;
224
- }
225
- return filePath;
226
- };
227
- export {
228
- cleanRequireCache,
229
- compatibleRequire,
230
- deleteRequireCache,
231
- dynamicImport,
232
- loadFromProject,
233
- requireExistModule,
234
- tryResolve
235
- };
@@ -1,64 +0,0 @@
1
- import { lodash } from "../compiled";
2
- var cloneDeep = lodash.cloneDeep;
3
- function filterRoutesForServer(routes) {
4
- var clonedRoutes = cloneDeep(routes);
5
- var newRoutes = clonedRoutes.map(function(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(function(route) {
17
- return route !== null;
18
- });
19
- return newRoutes;
20
- }
21
- function filterRoutesLoader(routes) {
22
- var clonedRoutes = cloneDeep(routes);
23
- var newRoutes = clonedRoutes.map(function(route) {
24
- if (route.type !== "nested") {
25
- return route;
26
- }
27
- if (route.children && route.children.length > 0) {
28
- route.children = filterRoutesLoader(route.children);
29
- }
30
- if (route.inValidSSRRoute) {
31
- delete route.loader;
32
- delete route.data;
33
- delete route.action;
34
- }
35
- return route;
36
- }).filter(function(route) {
37
- return route !== null;
38
- });
39
- return newRoutes;
40
- }
41
- function markRoutes(routes, routeIds) {
42
- return routes.map(function(route) {
43
- if (route.type !== "nested") {
44
- return route;
45
- }
46
- if (route.children && route.children.length > 0) {
47
- route.children = markRoutes(route.children, routeIds);
48
- }
49
- if (route.children && route.children.length > 0) {
50
- route.inValidSSRRoute = route.children.every(function(child) {
51
- var _child_inValidSSRRoute;
52
- return (_child_inValidSSRRoute = child.inValidSSRRoute) !== null && _child_inValidSSRRoute !== void 0 ? _child_inValidSSRRoute : false;
53
- });
54
- } else if (route.id) {
55
- route.inValidSSRRoute = !routeIds.includes(route.id);
56
- }
57
- return route;
58
- });
59
- }
60
- export {
61
- filterRoutesForServer,
62
- filterRoutesLoader,
63
- markRoutes
64
- };
@@ -1,44 +0,0 @@
1
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
- import path from "path";
3
- import { fs } from "../compiled";
4
- import { normalizeOutputPath } from "./path";
5
- var memo = function(fn) {
6
- var cache = /* @__PURE__ */ new Map();
7
- return function() {
8
- for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
9
- params[_key] = arguments[_key];
10
- }
11
- var stringifiedParams = JSON.stringify(params);
12
- var cachedResult = cache.get(stringifiedParams);
13
- if (cachedResult) {
14
- return cachedResult;
15
- }
16
- var res = fn.apply(void 0, _to_consumable_array(params));
17
- cache.set(stringifiedParams, res);
18
- return res;
19
- };
20
- };
21
- var createRuntimeExportsUtils = memo(function() {
22
- var pwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "index";
23
- var entryExportFile = path.join(pwd, ".runtime-exports/".concat(namespace, ".js"));
24
- var addExport = function(statement) {
25
- var statementStr = normalizeOutputPath(statement);
26
- try {
27
- fs.ensureFileSync(entryExportFile);
28
- if (!fs.readFileSync(entryExportFile, "utf8").includes(statementStr)) {
29
- fs.appendFileSync(entryExportFile, "".concat(statementStr, "\n"));
30
- }
31
- } catch (e) {
32
- }
33
- };
34
- var getPath = function() {
35
- return entryExportFile;
36
- };
37
- return {
38
- addExport,
39
- getPath
40
- };
41
- });
42
- export {
43
- createRuntimeExportsUtils
44
- };
@@ -1,26 +0,0 @@
1
- function isVersionAtLeast1819() {
2
- var nodeVersion = process.versions.node;
3
- var versionArr = nodeVersion.split(".").map(Number);
4
- return versionArr[0] > 18 || versionArr[0] === 18 && versionArr[1] >= 19;
5
- }
6
- function isVersionAtLeast18() {
7
- var nodeVersion = process.versions.node;
8
- var versionArr = nodeVersion.split(".").map(Number);
9
- return versionArr[0] >= 18;
10
- }
11
- function isVersionAtLeast22() {
12
- var nodeVersion = process.versions.node;
13
- var versionArr = nodeVersion.split(".").map(Number);
14
- return versionArr[0] >= 22;
15
- }
16
- function isVersionAtLeast20() {
17
- var nodeVersion = process.versions.node;
18
- var versionArr = nodeVersion.split(".").map(Number);
19
- return versionArr[0] >= 20;
20
- }
21
- export {
22
- isVersionAtLeast18,
23
- isVersionAtLeast1819,
24
- isVersionAtLeast20,
25
- isVersionAtLeast22
26
- };
@@ -1,112 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import path from "path";
4
- import { chokidar } from "../compiled";
5
- var WatchChangeType = {
6
- ADD: "add",
7
- UNLINK: "unlink",
8
- CHANGE: "change"
9
- };
10
- var watch = function(watchDir, runTask) {
11
- var ignored = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
12
- var ready = false;
13
- var watcher = chokidar.watch(watchDir, {
14
- ignored
15
- });
16
- watcher.on("ready", function() {
17
- return ready = true;
18
- });
19
- watcher.on("change", function() {
20
- var _ref = _async_to_generator(function(filePath) {
21
- var changedFilePath;
22
- return _ts_generator(this, function(_state) {
23
- switch (_state.label) {
24
- case 0:
25
- changedFilePath = path.resolve(filePath);
26
- return [
27
- 4,
28
- runTask({
29
- changedFilePath,
30
- changeType: WatchChangeType.CHANGE
31
- })
32
- ];
33
- case 1:
34
- _state.sent();
35
- return [
36
- 2
37
- ];
38
- }
39
- });
40
- });
41
- return function(filePath) {
42
- return _ref.apply(this, arguments);
43
- };
44
- }());
45
- watcher.on("add", function() {
46
- var _ref = _async_to_generator(function(filePath) {
47
- var changedFilePath;
48
- return _ts_generator(this, function(_state) {
49
- switch (_state.label) {
50
- case 0:
51
- changedFilePath = path.resolve(filePath);
52
- if (!ready)
53
- return [
54
- 3,
55
- 2
56
- ];
57
- return [
58
- 4,
59
- runTask({
60
- changedFilePath,
61
- changeType: WatchChangeType.ADD
62
- })
63
- ];
64
- case 1:
65
- _state.sent();
66
- _state.label = 2;
67
- case 2:
68
- return [
69
- 2
70
- ];
71
- }
72
- });
73
- });
74
- return function(filePath) {
75
- return _ref.apply(this, arguments);
76
- };
77
- }());
78
- watcher.on("unlink", function() {
79
- var _ref = _async_to_generator(function(filePath) {
80
- var changedFilePath;
81
- return _ts_generator(this, function(_state) {
82
- switch (_state.label) {
83
- case 0:
84
- changedFilePath = path.resolve(filePath);
85
- return [
86
- 4,
87
- runTask({
88
- changedFilePath,
89
- changeType: WatchChangeType.UNLINK
90
- })
91
- ];
92
- case 1:
93
- _state.sent();
94
- return [
95
- 2
96
- ];
97
- }
98
- });
99
- });
100
- return function(filePath) {
101
- return _ref.apply(this, arguments);
102
- };
103
- }());
104
- watcher.on("error", function(err) {
105
- throw err;
106
- });
107
- return watcher;
108
- };
109
- export {
110
- WatchChangeType,
111
- watch
112
- };
@@ -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
- var mime = Import.lazy("../compiled/mime-types", require);
31
- var chokidar = Import.lazy("../compiled/chokidar", require);
32
- var 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
- var lazy = function(moduleName, requireFn) {
2
- var importLazyLocal = require("../compiled/import-lazy")(requireFn);
3
- return importLazyLocal(moduleName);
4
- };
5
- var Import = {
6
- lazy
7
- };
8
- export {
9
- Import,
10
- lazy as lazyImport
11
- };
package/dist/esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./compiled";
2
- export * from "./cli";
3
- export * from "./import";
@@ -1,32 +0,0 @@
1
- var ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
2
- var ROUTE_MODULES = "_routeModules";
3
- var HMR_SOCK_PATH = "/webpack-hmr";
4
- var HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
5
- var LOADER_REPORTER_NAME = "server-loader";
6
- var ROUTE_SPEC_FILE = "route.json";
7
- var NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
8
- var MAIN_ENTRY_NAME = "main";
9
- var SERVER_BUNDLE_DIRECTORY = "bundles";
10
- var SERVER_RENDER_FUNCTION_NAME = "serverRender";
11
- var SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
12
- var SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
13
- var SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
14
- var SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
15
- var 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,95 +0,0 @@
1
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
2
- import { _ as _type_of } from "@swc/helpers/_/_type_of";
3
- var friendlySyntaxErrorLabel = "SyntaxError:";
4
- function isLikelyASyntaxError(message) {
5
- return message.includes(friendlySyntaxErrorLabel);
6
- }
7
- function formatMessage(stats) {
8
- var lines = [];
9
- var message;
10
- if ((typeof stats === "undefined" ? "undefined" : _type_of(stats)) === "object") {
11
- var fileName = stats.moduleName ? "File: ".concat(stats.moduleName, "\n") : "";
12
- var mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
13
- var details = stats.details ? "\nDetails: ".concat(stats.details, "\n") : "";
14
- var stack = stats.stack ? "\n".concat(stats.stack) : "";
15
- message = "".concat(fileName).concat(mainMessage).concat(details).concat(stack);
16
- } else {
17
- message = stats;
18
- }
19
- lines = message.split("\n");
20
- lines = lines.map(function(line) {
21
- var parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
22
- if (!parsingError) {
23
- return line;
24
- }
25
- var _parsingError = _sliced_to_array(parsingError, 4), errorLine = _parsingError[1], errorColumn = _parsingError[2], errorMessage = _parsingError[3];
26
- return "".concat(friendlySyntaxErrorLabel, " ").concat(errorMessage, " (").concat(errorLine, ":").concat(errorColumn, ")");
27
- });
28
- message = lines.join("\n");
29
- message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "".concat(friendlySyntaxErrorLabel, " $3 ($1:$2)\n"));
30
- lines = message.split("\n");
31
- if (lines.length > 2 && lines[1].trim() === "") {
32
- lines.splice(1, 1);
33
- }
34
- lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
35
- if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
36
- lines[1] = lines[1].replace("Error: ", "");
37
- }
38
- lines = lines.filter(function(line, index, arr) {
39
- return index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim();
40
- });
41
- message = lines.join("\n");
42
- return message.trim();
43
- }
44
- var noop = function(message) {
45
- return message;
46
- };
47
- var defaultColor = {
48
- gray: noop,
49
- cyan: noop,
50
- green: noop,
51
- yellow: noop,
52
- underline: noop
53
- };
54
- function addErrorTips(errors) {
55
- var color = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultColor;
56
- var errorHelpers = [
57
- {
58
- validator: function validator(message) {
59
- return (message.includes("You may need an appropriate loader") || message.includes("You may need an additional loader")) && message.includes(".ts");
60
- },
61
- formatter: function formatter(message) {
62
- return "".concat(message, "\n\n").concat(color.yellow('If it is a TypeScript file, you can use "source.include" config to compile it. see '.concat(color.underline("https://modernjs.dev/en/configure/app/source/include.html"))), "\n\n").concat(color.green("".concat(color.gray("// config file"), "\nexport default {\n source: {\n include: [\n ").concat(color.gray("// add some include rules"), "\n ]\n }\n}")), "\n ");
63
- }
64
- }
65
- ];
66
- return errors.map(function(error) {
67
- var helper = errorHelpers.find(function(item) {
68
- return item.validator(error);
69
- });
70
- return helper ? helper.formatter(error) : error;
71
- });
72
- }
73
- function formatWebpackMessages(json) {
74
- var color = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultColor;
75
- var _json_errors, _json_warnings, _result_errors;
76
- var formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
77
- var formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
78
- var result = {
79
- errors: formattedErrors || [],
80
- warnings: formattedWarnings || [],
81
- errorTips: []
82
- };
83
- if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.some(isLikelyASyntaxError)) {
84
- result.errors = result.errors.filter(isLikelyASyntaxError);
85
- }
86
- if (result.errors.length > 1) {
87
- result.errors.length = 1;
88
- }
89
- result.errors = addErrorTips(result.errors, color);
90
- return result;
91
- }
92
- export {
93
- addErrorTips,
94
- formatWebpackMessages
95
- };
@@ -1,4 +0,0 @@
1
- import { cutNameByHyphen } from "./path";
2
- export {
3
- cutNameByHyphen
4
- };