@modern-js/app-tools 2.15.0 → 2.17.0

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 (268) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/cjs/analyze/constants.js +37 -61
  3. package/dist/cjs/analyze/generateCode.js +102 -127
  4. package/dist/cjs/analyze/getBundleEntry.js +33 -66
  5. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
  6. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
  7. package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
  8. package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
  9. package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
  10. package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
  11. package/dist/cjs/analyze/getServerRoutes.js +67 -110
  12. package/dist/cjs/analyze/index.js +265 -257
  13. package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
  14. package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
  15. package/dist/cjs/analyze/nestedRoutes.js +99 -104
  16. package/dist/cjs/analyze/templates.js +49 -110
  17. package/dist/cjs/analyze/utils.js +98 -102
  18. package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
  19. package/dist/cjs/builder/builder-rspack/index.js +14 -30
  20. package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
  21. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
  22. package/dist/cjs/builder/builder-webpack/index.js +65 -46
  23. package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
  24. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
  25. package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
  26. package/dist/cjs/builder/generator/index.js +61 -55
  27. package/dist/cjs/builder/index.js +53 -43
  28. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
  29. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
  30. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
  31. package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
  32. package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
  33. package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
  34. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
  35. package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
  36. package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
  37. package/dist/cjs/builder/shared/index.js +20 -19
  38. package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
  39. package/dist/cjs/builder/shared/types.js +4 -15
  40. package/dist/cjs/commands/build.js +23 -40
  41. package/dist/cjs/commands/deploy.js +7 -25
  42. package/dist/cjs/commands/dev.js +38 -57
  43. package/dist/cjs/commands/index.js +20 -19
  44. package/dist/cjs/commands/inspect.js +10 -30
  45. package/dist/cjs/commands/serve.js +28 -66
  46. package/dist/cjs/config/default.js +34 -34
  47. package/dist/cjs/config/index.js +20 -19
  48. package/dist/cjs/config/initialize/index.js +11 -29
  49. package/dist/cjs/config/initialize/inits.js +103 -82
  50. package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
  51. package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
  52. package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
  53. package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
  54. package/dist/cjs/config/legacy/index.js +22 -46
  55. package/dist/cjs/defineConfig.js +16 -31
  56. package/dist/cjs/exports/server.js +7 -25
  57. package/dist/cjs/hooks.js +33 -51
  58. package/dist/cjs/index.js +185 -166
  59. package/dist/cjs/initialize/index.js +84 -100
  60. package/dist/cjs/locale/en.js +13 -27
  61. package/dist/cjs/locale/index.js +18 -28
  62. package/dist/cjs/locale/zh.js +13 -27
  63. package/dist/cjs/schema/Schema.js +27 -31
  64. package/dist/cjs/schema/index.js +141 -71
  65. package/dist/cjs/schema/legacy.js +273 -96
  66. package/dist/cjs/types/config/deploy.js +4 -15
  67. package/dist/cjs/types/config/dev.js +4 -15
  68. package/dist/cjs/types/config/experiments.js +4 -15
  69. package/dist/cjs/types/config/html.js +4 -15
  70. package/dist/cjs/types/config/index.js +18 -17
  71. package/dist/cjs/types/config/output.js +4 -15
  72. package/dist/cjs/types/config/performance.js +4 -15
  73. package/dist/cjs/types/config/security.js +4 -15
  74. package/dist/cjs/types/config/source.js +4 -15
  75. package/dist/cjs/types/config/tools.js +4 -15
  76. package/dist/cjs/types/hooks.js +4 -15
  77. package/dist/cjs/types/index.js +20 -19
  78. package/dist/cjs/types/legacyConfig/deploy.js +4 -15
  79. package/dist/cjs/types/legacyConfig/dev.js +4 -15
  80. package/dist/cjs/types/legacyConfig/index.js +4 -15
  81. package/dist/cjs/types/legacyConfig/output.js +4 -15
  82. package/dist/cjs/types/legacyConfig/source.js +4 -15
  83. package/dist/cjs/types/legacyConfig/tools.js +4 -15
  84. package/dist/cjs/types/utils.js +4 -15
  85. package/dist/cjs/utils/config.js +74 -79
  86. package/dist/cjs/utils/createServer.js +16 -42
  87. package/dist/cjs/utils/env.js +7 -25
  88. package/dist/cjs/utils/generateWatchFiles.js +31 -52
  89. package/dist/cjs/utils/getSelectedEntries.js +13 -35
  90. package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
  91. package/dist/cjs/utils/printInstructions.js +10 -28
  92. package/dist/cjs/utils/restart.js +13 -31
  93. package/dist/cjs/utils/routes.js +18 -39
  94. package/dist/cjs/utils/types.js +4 -15
  95. package/dist/esm/analyze/constants.js +40 -41
  96. package/dist/esm/analyze/generateCode.js +477 -455
  97. package/dist/esm/analyze/getBundleEntry.js +53 -54
  98. package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
  99. package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
  100. package/dist/esm/analyze/getClientRoutes/index.js +2 -3
  101. package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
  102. package/dist/esm/analyze/getFileSystemEntry.js +86 -87
  103. package/dist/esm/analyze/getHtmlTemplate.js +289 -278
  104. package/dist/esm/analyze/getServerRoutes.js +203 -190
  105. package/dist/esm/analyze/index.js +679 -651
  106. package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
  107. package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
  108. package/dist/esm/analyze/nestedRoutes.js +400 -392
  109. package/dist/esm/analyze/templates.js +536 -509
  110. package/dist/esm/analyze/utils.js +357 -336
  111. package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
  112. package/dist/esm/builder/builder-rspack/index.js +8 -9
  113. package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
  114. package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
  115. package/dist/esm/builder/builder-webpack/index.js +266 -249
  116. package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
  117. package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
  118. package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
  119. package/dist/esm/builder/generator/index.js +203 -196
  120. package/dist/esm/builder/index.js +183 -176
  121. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
  122. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
  123. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
  124. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
  125. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
  126. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
  127. package/dist/esm/builder/shared/createCopyInfo.js +9 -10
  128. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
  129. package/dist/esm/builder/shared/types.js +1 -1
  130. package/dist/esm/commands/build.js +279 -272
  131. package/dist/esm/commands/deploy.js +150 -144
  132. package/dist/esm/commands/dev.js +296 -289
  133. package/dist/esm/commands/inspect.js +144 -138
  134. package/dist/esm/commands/serve.js +241 -235
  135. package/dist/esm/config/default.js +202 -203
  136. package/dist/esm/config/initialize/index.js +7 -8
  137. package/dist/esm/config/initialize/inits.js +189 -181
  138. package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
  139. package/dist/esm/config/legacy/createOutputConfig.js +41 -42
  140. package/dist/esm/config/legacy/createSourceConfig.js +38 -39
  141. package/dist/esm/config/legacy/createToolsConfig.js +24 -25
  142. package/dist/esm/config/legacy/index.js +31 -32
  143. package/dist/esm/defineConfig.js +52 -53
  144. package/dist/esm/exports/server.js +1 -2
  145. package/dist/esm/hooks.js +26 -27
  146. package/dist/esm/index.js +685 -671
  147. package/dist/esm/initialize/index.js +276 -269
  148. package/dist/esm/locale/en.js +36 -37
  149. package/dist/esm/locale/index.js +2 -2
  150. package/dist/esm/locale/zh.js +36 -37
  151. package/dist/esm/schema/Schema.js +255 -244
  152. package/dist/esm/schema/index.js +165 -165
  153. package/dist/esm/schema/legacy.js +316 -317
  154. package/dist/esm/types/config/deploy.js +1 -1
  155. package/dist/esm/types/config/dev.js +1 -1
  156. package/dist/esm/types/config/experiments.js +1 -1
  157. package/dist/esm/types/config/html.js +1 -1
  158. package/dist/esm/types/config/output.js +1 -1
  159. package/dist/esm/types/config/performance.js +1 -1
  160. package/dist/esm/types/config/security.js +1 -1
  161. package/dist/esm/types/config/source.js +1 -1
  162. package/dist/esm/types/config/tools.js +1 -1
  163. package/dist/esm/types/hooks.js +1 -1
  164. package/dist/esm/types/legacyConfig/deploy.js +1 -1
  165. package/dist/esm/types/legacyConfig/dev.js +1 -1
  166. package/dist/esm/types/legacyConfig/index.js +1 -1
  167. package/dist/esm/types/legacyConfig/output.js +1 -1
  168. package/dist/esm/types/legacyConfig/source.js +1 -1
  169. package/dist/esm/types/legacyConfig/tools.js +1 -1
  170. package/dist/esm/types/utils.js +1 -1
  171. package/dist/esm/utils/config.js +285 -278
  172. package/dist/esm/utils/createServer.js +242 -234
  173. package/dist/esm/utils/env.js +11 -12
  174. package/dist/esm/utils/generateWatchFiles.js +205 -190
  175. package/dist/esm/utils/getSelectedEntries.js +180 -173
  176. package/dist/esm/utils/getServerInternalPlugins.js +197 -191
  177. package/dist/esm/utils/printInstructions.js +147 -141
  178. package/dist/esm/utils/restart.js +179 -173
  179. package/dist/esm/utils/routes.js +146 -139
  180. package/dist/esm/utils/types.js +1 -1
  181. package/dist/esm-node/analyze/constants.js +31 -46
  182. package/dist/esm-node/analyze/generateCode.js +28 -94
  183. package/dist/esm-node/analyze/getBundleEntry.js +8 -27
  184. package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
  185. package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
  186. package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
  187. package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
  188. package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
  189. package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
  190. package/dist/esm-node/analyze/getServerRoutes.js +43 -75
  191. package/dist/esm-node/analyze/index.js +208 -230
  192. package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
  193. package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
  194. package/dist/esm-node/analyze/nestedRoutes.js +23 -43
  195. package/dist/esm-node/analyze/templates.js +22 -69
  196. package/dist/esm-node/analyze/utils.js +66 -60
  197. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
  198. package/dist/esm-node/builder/builder-rspack/index.js +4 -5
  199. package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
  200. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
  201. package/dist/esm-node/builder/builder-webpack/index.js +13 -11
  202. package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
  203. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
  204. package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
  205. package/dist/esm-node/builder/generator/index.js +7 -16
  206. package/dist/esm-node/builder/index.js +2 -7
  207. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
  208. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
  209. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
  210. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
  211. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
  212. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
  213. package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
  214. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
  215. package/dist/esm-node/builder/shared/types.js +1 -0
  216. package/dist/esm-node/commands/build.js +7 -9
  217. package/dist/esm-node/commands/deploy.js +1 -4
  218. package/dist/esm-node/commands/dev.js +19 -27
  219. package/dist/esm-node/commands/inspect.js +3 -8
  220. package/dist/esm-node/commands/serve.js +7 -25
  221. package/dist/esm-node/config/default.js +20 -11
  222. package/dist/esm-node/config/initialize/index.js +1 -4
  223. package/dist/esm-node/config/initialize/inits.js +48 -54
  224. package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
  225. package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
  226. package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
  227. package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
  228. package/dist/esm-node/config/legacy/index.js +3 -18
  229. package/dist/esm-node/defineConfig.js +7 -13
  230. package/dist/esm-node/exports/server.js +1 -4
  231. package/dist/esm-node/hooks.js +2 -9
  232. package/dist/esm-node/index.js +95 -120
  233. package/dist/esm-node/initialize/index.js +74 -87
  234. package/dist/esm-node/locale/en.js +7 -6
  235. package/dist/esm-node/locale/index.js +5 -5
  236. package/dist/esm-node/locale/zh.js +7 -6
  237. package/dist/esm-node/schema/Schema.js +19 -8
  238. package/dist/esm-node/schema/index.js +121 -36
  239. package/dist/esm-node/schema/legacy.js +262 -72
  240. package/dist/esm-node/types/config/deploy.js +1 -0
  241. package/dist/esm-node/types/config/dev.js +1 -0
  242. package/dist/esm-node/types/config/experiments.js +1 -0
  243. package/dist/esm-node/types/config/html.js +1 -0
  244. package/dist/esm-node/types/config/output.js +1 -0
  245. package/dist/esm-node/types/config/performance.js +1 -0
  246. package/dist/esm-node/types/config/security.js +1 -0
  247. package/dist/esm-node/types/config/source.js +1 -0
  248. package/dist/esm-node/types/config/tools.js +1 -0
  249. package/dist/esm-node/types/hooks.js +1 -0
  250. package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
  251. package/dist/esm-node/types/legacyConfig/dev.js +1 -0
  252. package/dist/esm-node/types/legacyConfig/index.js +1 -0
  253. package/dist/esm-node/types/legacyConfig/output.js +1 -0
  254. package/dist/esm-node/types/legacyConfig/source.js +1 -0
  255. package/dist/esm-node/types/legacyConfig/tools.js +1 -0
  256. package/dist/esm-node/types/utils.js +1 -0
  257. package/dist/esm-node/utils/config.js +16 -47
  258. package/dist/esm-node/utils/createServer.js +5 -12
  259. package/dist/esm-node/utils/env.js +1 -4
  260. package/dist/esm-node/utils/generateWatchFiles.js +13 -20
  261. package/dist/esm-node/utils/getSelectedEntries.js +2 -9
  262. package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
  263. package/dist/esm-node/utils/printInstructions.js +1 -4
  264. package/dist/esm-node/utils/restart.js +2 -11
  265. package/dist/esm-node/utils/routes.js +4 -4
  266. package/dist/esm-node/utils/types.js +1 -0
  267. package/dist/types/index.d.ts +2 -2
  268. package/package.json +29 -25
@@ -1,184 +1,205 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
5
7
  }
6
- function _arrayWithHoles(arr) {
7
- if (Array.isArray(arr)) return arr;
8
+ function _array_with_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return arr;
8
11
  }
9
- function _arrayWithoutHoles(arr) {
10
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
12
+ function _array_without_holes(arr) {
13
+ if (Array.isArray(arr))
14
+ return _array_like_to_array(arr);
11
15
  }
12
16
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
- try {
14
- var info = gen[key](arg);
15
- var value = info.value;
16
- } catch (error) {
17
- reject(error);
18
- return;
19
- }
20
- if (info.done) {
21
- resolve(value);
22
- } else {
23
- Promise.resolve(value).then(_next, _throw);
24
- }
17
+ try {
18
+ var info = gen[key](arg);
19
+ var value = info.value;
20
+ } catch (error) {
21
+ reject(error);
22
+ return;
23
+ }
24
+ if (info.done) {
25
+ resolve(value);
26
+ } else {
27
+ Promise.resolve(value).then(_next, _throw);
28
+ }
25
29
  }
26
- function _asyncToGenerator(fn) {
27
- return function() {
28
- var self = this, args = arguments;
29
- return new Promise(function(resolve, reject) {
30
- var gen = fn.apply(self, args);
31
- function _next(value) {
32
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
- }
34
- function _throw(err) {
35
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
- }
37
- _next(undefined);
38
- });
39
- };
30
+ function _async_to_generator(fn) {
31
+ return function() {
32
+ var self = this, args = arguments;
33
+ return new Promise(function(resolve, reject) {
34
+ var gen = fn.apply(self, args);
35
+ function _next(value) {
36
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
37
+ }
38
+ function _throw(err) {
39
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
40
+ }
41
+ _next(void 0);
42
+ });
43
+ };
40
44
  }
41
- function _iterableToArray(iter) {
42
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
45
+ function _iterable_to_array(iter) {
46
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
47
+ return Array.from(iter);
43
48
  }
44
- function _iterableToArrayLimit(arr, i) {
45
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
46
- if (_i == null) return;
47
- var _arr = [];
48
- var _n = true;
49
- var _d = false;
50
- var _s, _e;
49
+ function _iterable_to_array_limit(arr, i) {
50
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
51
+ if (_i == null)
52
+ return;
53
+ var _arr = [];
54
+ var _n = true;
55
+ var _d = false;
56
+ var _s, _e;
57
+ try {
58
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
59
+ _arr.push(_s.value);
60
+ if (i && _arr.length === i)
61
+ break;
62
+ }
63
+ } catch (err) {
64
+ _d = true;
65
+ _e = err;
66
+ } finally {
51
67
  try {
52
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
53
- _arr.push(_s.value);
54
- if (i && _arr.length === i) break;
55
- }
56
- } catch (err) {
57
- _d = true;
58
- _e = err;
59
- } finally{
60
- try {
61
- if (!_n && _i["return"] != null) _i["return"]();
62
- } finally{
63
- if (_d) throw _e;
64
- }
68
+ if (!_n && _i["return"] != null)
69
+ _i["return"]();
70
+ } finally {
71
+ if (_d)
72
+ throw _e;
65
73
  }
66
- return _arr;
74
+ }
75
+ return _arr;
67
76
  }
68
- function _nonIterableRest() {
69
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
+ function _non_iterable_rest() {
78
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
70
79
  }
71
- function _nonIterableSpread() {
72
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
80
+ function _non_iterable_spread() {
81
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
82
  }
74
- function _slicedToArray(arr, i) {
75
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
83
+ function _sliced_to_array(arr, i) {
84
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
76
85
  }
77
- function _toConsumableArray(arr) {
78
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
86
+ function _to_consumable_array(arr) {
87
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
79
88
  }
80
- function _unsupportedIterableToArray(o, minLen) {
81
- if (!o) return;
82
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
83
- var n = Object.prototype.toString.call(o).slice(8, -1);
84
- if (n === "Object" && o.constructor) n = o.constructor.name;
85
- if (n === "Map" || n === "Set") return Array.from(n);
86
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
89
+ function _unsupported_iterable_to_array(o, minLen) {
90
+ if (!o)
91
+ return;
92
+ if (typeof o === "string")
93
+ return _array_like_to_array(o, minLen);
94
+ var n = Object.prototype.toString.call(o).slice(8, -1);
95
+ if (n === "Object" && o.constructor)
96
+ n = o.constructor.name;
97
+ if (n === "Map" || n === "Set")
98
+ return Array.from(n);
99
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
100
+ return _array_like_to_array(o, minLen);
87
101
  }
88
- var __generator = this && this.__generator || function(thisArg, body) {
89
- var f, y, t, g, _ = {
90
- label: 0,
91
- sent: function() {
92
- if (t[0] & 1) throw t[1];
93
- return t[1];
94
- },
95
- trys: [],
96
- ops: []
102
+ var __generator = function(thisArg, body) {
103
+ var f, y, t, g, _ = {
104
+ label: 0,
105
+ sent: function() {
106
+ if (t[0] & 1)
107
+ throw t[1];
108
+ return t[1];
109
+ },
110
+ trys: [],
111
+ ops: []
112
+ };
113
+ return g = {
114
+ next: verb(0),
115
+ "throw": verb(1),
116
+ "return": verb(2)
117
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
118
+ return this;
119
+ }), g;
120
+ function verb(n) {
121
+ return function(v) {
122
+ return step([
123
+ n,
124
+ v
125
+ ]);
97
126
  };
98
- return(g = {
99
- next: verb(0),
100
- "throw": verb(1),
101
- "return": verb(2)
102
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
103
- return this;
104
- }), g);
105
- function verb(n) {
106
- return function(v) {
107
- return step([
108
- n,
109
- v
110
- ]);
111
- };
112
- }
113
- function step(op) {
114
- if (f) throw new TypeError("Generator is already executing.");
115
- while(_)try {
116
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
117
- if (y = 0, t) op = [
118
- op[0] & 2,
119
- t.value
120
- ];
121
- switch(op[0]){
122
- case 0:
123
- case 1:
124
- t = op;
125
- break;
126
- case 4:
127
- _.label++;
128
- return {
129
- value: op[1],
130
- done: false
131
- };
132
- case 5:
133
- _.label++;
134
- y = op[1];
135
- op = [
136
- 0
137
- ];
138
- continue;
139
- case 7:
140
- op = _.ops.pop();
141
- _.trys.pop();
142
- continue;
143
- default:
144
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
145
- _ = 0;
146
- continue;
147
- }
148
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
149
- _.label = op[1];
150
- break;
151
- }
152
- if (op[0] === 6 && _.label < t[1]) {
153
- _.label = t[1];
154
- t = op;
155
- break;
156
- }
157
- if (t && _.label < t[2]) {
158
- _.label = t[2];
159
- _.ops.push(op);
160
- break;
161
- }
162
- if (t[2]) _.ops.pop();
163
- _.trys.pop();
164
- continue;
165
- }
166
- op = body.call(thisArg, _);
167
- } catch (e) {
127
+ }
128
+ function step(op) {
129
+ if (f)
130
+ throw new TypeError("Generator is already executing.");
131
+ while (_)
132
+ try {
133
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
134
+ return t;
135
+ if (y = 0, t)
136
+ op = [
137
+ op[0] & 2,
138
+ t.value
139
+ ];
140
+ switch (op[0]) {
141
+ case 0:
142
+ case 1:
143
+ t = op;
144
+ break;
145
+ case 4:
146
+ _.label++;
147
+ return {
148
+ value: op[1],
149
+ done: false
150
+ };
151
+ case 5:
152
+ _.label++;
153
+ y = op[1];
168
154
  op = [
169
- 6,
170
- e
155
+ 0
171
156
  ];
172
- y = 0;
173
- } finally{
174
- f = t = 0;
157
+ continue;
158
+ case 7:
159
+ op = _.ops.pop();
160
+ _.trys.pop();
161
+ continue;
162
+ default:
163
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
164
+ _ = 0;
165
+ continue;
166
+ }
167
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
168
+ _.label = op[1];
169
+ break;
170
+ }
171
+ if (op[0] === 6 && _.label < t[1]) {
172
+ _.label = t[1];
173
+ t = op;
174
+ break;
175
+ }
176
+ if (t && _.label < t[2]) {
177
+ _.label = t[2];
178
+ _.ops.push(op);
179
+ break;
180
+ }
181
+ if (t[2])
182
+ _.ops.pop();
183
+ _.trys.pop();
184
+ continue;
175
185
  }
176
- if (op[0] & 5) throw op[1];
177
- return {
178
- value: op[0] ? op[1] : void 0,
179
- done: true
180
- };
181
- }
186
+ op = body.call(thisArg, _);
187
+ } catch (e) {
188
+ op = [
189
+ 6,
190
+ e
191
+ ];
192
+ y = 0;
193
+ } finally {
194
+ f = t = 0;
195
+ }
196
+ if (op[0] & 5)
197
+ throw op[1];
198
+ return {
199
+ value: op[0] ? op[1] : void 0,
200
+ done: true
201
+ };
202
+ }
182
203
  };
183
204
  import fs from "fs";
184
205
  import path from "path";
@@ -186,196 +207,196 @@ import { isReact18, normalizeToPosixPath, fs as fse } from "@modern-js/utils";
186
207
  import { transform } from "esbuild";
187
208
  import { parse } from "es-module-lexer";
188
209
  import { FILE_SYSTEM_ROUTES_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME } from "./constants";
189
- var walkDirectory = function(dir) {
190
- return fs.readdirSync(dir).reduce(function(previous, filename) {
191
- var filePath = path.join(dir, filename);
192
- if (fs.statSync(filePath).isDirectory()) {
193
- return _toConsumableArray(previous).concat(_toConsumableArray(walkDirectory(filePath)));
194
- } else {
195
- return _toConsumableArray(previous).concat([
196
- filePath
197
- ]);
198
- }
199
- }, []);
210
+ export var walkDirectory = function(dir) {
211
+ return fs.readdirSync(dir).reduce(function(previous, filename) {
212
+ var filePath = path.join(dir, filename);
213
+ if (fs.statSync(filePath).isDirectory()) {
214
+ return _to_consumable_array(previous).concat(_to_consumable_array(walkDirectory(filePath)));
215
+ } else {
216
+ return _to_consumable_array(previous).concat([
217
+ filePath
218
+ ]);
219
+ }
220
+ }, []);
200
221
  };
201
- var getDefaultImports = function(param) {
202
- var entrypoint = param.entrypoint, srcDirectory = param.srcDirectory, internalSrcAlias = param.internalSrcAlias, internalDirAlias = param.internalDirAlias, internalDirectory = param.internalDirectory;
203
- var entryName = entrypoint.entryName, fileSystemRoutes = entrypoint.fileSystemRoutes, customBootstrap = entrypoint.customBootstrap, entry = entrypoint.entry;
204
- var imports = [
222
+ export var getDefaultImports = function(param) {
223
+ var entrypoint = param.entrypoint, srcDirectory = param.srcDirectory, internalSrcAlias = param.internalSrcAlias, internalDirAlias = param.internalDirAlias, internalDirectory = param.internalDirectory;
224
+ var entryName = entrypoint.entryName, fileSystemRoutes = entrypoint.fileSystemRoutes, customBootstrap = entrypoint.customBootstrap, entry = entrypoint.entry;
225
+ var imports = [
226
+ {
227
+ specifiers: [
205
228
  {
206
- specifiers: [
207
- {
208
- local: "React"
209
- }
210
- ],
211
- value: "react"
212
- },
229
+ local: "React"
230
+ }
231
+ ],
232
+ value: "react"
233
+ },
234
+ {
235
+ specifiers: [
213
236
  {
214
- specifiers: [
215
- {
216
- local: "ReactDOM"
217
- }
218
- ],
219
- value: isReact18(path.join(internalDirectory, "../../")) ? "react-dom/client" : "react-dom"
220
- },
237
+ local: "ReactDOM"
238
+ }
239
+ ],
240
+ value: isReact18(path.join(internalDirectory, "../../")) ? "react-dom/client" : "react-dom"
241
+ },
242
+ {
243
+ specifiers: [
221
244
  {
222
- specifiers: [
223
- {
224
- imported: "createApp"
225
- },
226
- {
227
- imported: "bootstrap"
228
- }
229
- ],
230
- value: "@modern-js/runtime"
245
+ imported: "createApp"
231
246
  },
232
- customBootstrap && {
233
- specifiers: [
234
- {
235
- local: "customBootstrap"
236
- }
237
- ],
238
- value: normalizeToPosixPath(customBootstrap.replace(srcDirectory, internalSrcAlias))
247
+ {
248
+ imported: "bootstrap"
239
249
  }
240
- ].filter(Boolean);
241
- if (fileSystemRoutes) {
242
- var route = {
243
- specifiers: [
244
- {
245
- imported: "routes"
246
- }
247
- ],
248
- value: normalizeToPosixPath("".concat(internalDirAlias, "/").concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME.replace(".js", "")))
249
- };
250
- if (fileSystemRoutes.globalApp) {
251
- imports.push({
252
- specifiers: [
253
- {
254
- local: "App"
255
- }
256
- ],
257
- value: normalizeToPosixPath(fileSystemRoutes.globalApp.replace(srcDirectory, internalSrcAlias))
258
- });
259
- } else {
260
- route.initialize = "const App = false;";
250
+ ],
251
+ value: "@modern-js/runtime"
252
+ },
253
+ customBootstrap && {
254
+ specifiers: [
255
+ {
256
+ local: "customBootstrap"
257
+ }
258
+ ],
259
+ value: normalizeToPosixPath(customBootstrap.replace(srcDirectory, internalSrcAlias))
260
+ }
261
+ ].filter(Boolean);
262
+ if (fileSystemRoutes) {
263
+ var route = {
264
+ specifiers: [
265
+ {
266
+ imported: "routes"
261
267
  }
262
- imports.push(route);
268
+ ],
269
+ value: normalizeToPosixPath("".concat(internalDirAlias, "/").concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME.replace(".js", "")))
270
+ };
271
+ if (fileSystemRoutes.globalApp) {
272
+ imports.push({
273
+ specifiers: [
274
+ {
275
+ local: "App"
276
+ }
277
+ ],
278
+ value: normalizeToPosixPath(fileSystemRoutes.globalApp.replace(srcDirectory, internalSrcAlias))
279
+ });
263
280
  } else {
264
- imports.push({
265
- specifiers: [
266
- {
267
- local: "App"
268
- }
269
- ],
270
- value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
271
- });
281
+ route.initialize = "const App = false;";
272
282
  }
273
- return imports;
283
+ imports.push(route);
284
+ } else {
285
+ imports.push({
286
+ specifiers: [
287
+ {
288
+ local: "App"
289
+ }
290
+ ],
291
+ value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
292
+ });
293
+ }
294
+ return imports;
274
295
  };
275
- var isPageComponentFile = function(filePath) {
276
- if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
277
- return false;
278
- }
279
- if ([
280
- ".js",
281
- ".jsx",
282
- ".ts",
283
- ".tsx"
284
- ].includes(path.extname(filePath))) {
285
- return true;
286
- }
296
+ export var isPageComponentFile = function(filePath) {
297
+ if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
287
298
  return false;
299
+ }
300
+ if ([
301
+ ".js",
302
+ ".jsx",
303
+ ".ts",
304
+ ".tsx"
305
+ ].includes(path.extname(filePath))) {
306
+ return true;
307
+ }
308
+ return false;
288
309
  };
289
- var replaceWithAlias = function(base, filePath, alias) {
290
- if (filePath.includes(base)) {
291
- return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
292
- } else {
293
- return filePath;
294
- }
310
+ export var replaceWithAlias = function(base, filePath, alias) {
311
+ if (filePath.includes(base)) {
312
+ return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
313
+ } else {
314
+ return filePath;
315
+ }
295
316
  };
296
- var parseModule = function() {
297
- var _ref = _asyncToGenerator(function(param) {
298
- var source, filename, content, result;
299
- return __generator(this, function(_state) {
300
- switch(_state.label){
301
- case 0:
302
- source = param.source, filename = param.filename;
303
- content = source;
304
- if (!JS_EXTENSIONS.some(function(ext) {
305
- return filename.endsWith(ext);
306
- })) return [
307
- 3,
308
- 2
309
- ];
310
- return [
311
- 4,
312
- transform(content, {
313
- loader: path.extname(filename).slice(1),
314
- format: "esm"
315
- })
316
- ];
317
- case 1:
318
- result = _state.sent();
319
- content = result.code;
320
- _state.label = 2;
321
- case 2:
322
- return [
323
- 4,
324
- parse(content)
325
- ];
326
- case 3:
327
- return [
328
- 2,
329
- _state.sent()
330
- ];
331
- }
332
- });
317
+ export var parseModule = function() {
318
+ var _ref = _async_to_generator(function(param) {
319
+ var source, filename, content, result;
320
+ return __generator(this, function(_state) {
321
+ switch (_state.label) {
322
+ case 0:
323
+ source = param.source, filename = param.filename;
324
+ content = source;
325
+ if (!JS_EXTENSIONS.some(function(ext) {
326
+ return filename.endsWith(ext);
327
+ }))
328
+ return [
329
+ 3,
330
+ 2
331
+ ];
332
+ return [
333
+ 4,
334
+ transform(content, {
335
+ loader: path.extname(filename).slice(1),
336
+ format: "esm"
337
+ })
338
+ ];
339
+ case 1:
340
+ result = _state.sent();
341
+ content = result.code;
342
+ _state.label = 2;
343
+ case 2:
344
+ return [
345
+ 4,
346
+ parse(content)
347
+ ];
348
+ case 3:
349
+ return [
350
+ 2,
351
+ _state.sent()
352
+ ];
353
+ }
333
354
  });
334
- return function parseModule(_) {
335
- return _ref.apply(this, arguments);
336
- };
355
+ });
356
+ return function parseModule2(_) {
357
+ return _ref.apply(this, arguments);
358
+ };
337
359
  }();
338
- var hasLoader = function() {
339
- var _ref = _asyncToGenerator(function(filename) {
340
- var source, _ref, moduleExports;
341
- return __generator(this, function(_state) {
342
- switch(_state.label){
343
- case 0:
344
- return [
345
- 4,
346
- fse.readFile(filename)
347
- ];
348
- case 1:
349
- source = _state.sent();
350
- return [
351
- 4,
352
- parseModule({
353
- source: source.toString(),
354
- filename: filename
355
- })
356
- ];
357
- case 2:
358
- _ref = _slicedToArray.apply(void 0, [
359
- _state.sent(),
360
- 2
361
- ]), moduleExports = _ref[1];
362
- return [
363
- 2,
364
- moduleExports.some(function(e) {
365
- return e.n === LOADER_EXPORT_NAME;
366
- })
367
- ];
368
- }
369
- });
360
+ export var hasLoader = function() {
361
+ var _ref = _async_to_generator(function(filename) {
362
+ var source, _ref2, moduleExports;
363
+ return __generator(this, function(_state) {
364
+ switch (_state.label) {
365
+ case 0:
366
+ return [
367
+ 4,
368
+ fse.readFile(filename)
369
+ ];
370
+ case 1:
371
+ source = _state.sent();
372
+ return [
373
+ 4,
374
+ parseModule({
375
+ source: source.toString(),
376
+ filename
377
+ })
378
+ ];
379
+ case 2:
380
+ _ref2 = _sliced_to_array.apply(void 0, [
381
+ _state.sent(),
382
+ 2
383
+ ]), moduleExports = _ref2[1];
384
+ return [
385
+ 2,
386
+ moduleExports.some(function(e) {
387
+ return e.n === LOADER_EXPORT_NAME;
388
+ })
389
+ ];
390
+ }
370
391
  });
371
- return function hasLoader(filename) {
372
- return _ref.apply(this, arguments);
373
- };
392
+ });
393
+ return function hasLoader2(filename) {
394
+ return _ref.apply(this, arguments);
395
+ };
374
396
  }();
375
- var getServerLoadersFile = function(internalDirectory, entryName) {
376
- return path.join(internalDirectory, entryName, "route-server-loaders.js");
397
+ export var getServerLoadersFile = function(internalDirectory, entryName) {
398
+ return path.join(internalDirectory, entryName, "route-server-loaders.js");
377
399
  };
378
- var getServerCombinedModueFile = function(internalDirectory, entryName) {
379
- return path.join(internalDirectory, entryName, "server-loader-combined.js");
400
+ export var getServerCombinedModueFile = function(internalDirectory, entryName) {
401
+ return path.join(internalDirectory, entryName, "server-loader-combined.js");
380
402
  };
381
- export { getDefaultImports, getServerCombinedModueFile, getServerLoadersFile, hasLoader, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };