@modern-js/app-tools 1.22.2 → 2.0.0-alpha.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 (325) hide show
  1. package/CHANGELOG.md +1383 -104
  2. package/bin/modern.js +13 -1
  3. package/dist/js/modern/analyze/Builder.js +39 -0
  4. package/dist/js/modern/analyze/constants.js +48 -15
  5. package/dist/js/modern/analyze/generateCode.js +286 -133
  6. package/dist/js/modern/analyze/getBundleEntry.js +39 -41
  7. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
  8. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
  9. package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
  10. package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
  11. package/dist/js/modern/analyze/getFileSystemEntry.js +74 -39
  12. package/dist/js/modern/analyze/getHtmlTemplate.js +90 -57
  13. package/dist/js/modern/analyze/getServerRoutes.js +123 -140
  14. package/dist/js/modern/analyze/index.js +220 -133
  15. package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -20
  16. package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -13
  17. package/dist/js/modern/analyze/nestedRoutes.js +166 -0
  18. package/dist/js/modern/analyze/templates.js +289 -29
  19. package/dist/js/modern/analyze/utils.js +128 -58
  20. package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
  21. package/dist/js/modern/builder/index.js +154 -0
  22. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  23. package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
  24. package/dist/js/modern/builder/share.js +46 -0
  25. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
  26. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
  27. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
  28. package/dist/js/modern/commands/build.js +75 -138
  29. package/dist/js/modern/commands/deploy.js +27 -4
  30. package/dist/js/modern/commands/dev.js +102 -66
  31. package/dist/js/modern/commands/index.js +1 -1
  32. package/dist/js/modern/commands/inspect.js +33 -64
  33. package/dist/js/modern/commands/serve.js +54 -0
  34. package/dist/js/modern/config/default.js +173 -0
  35. package/dist/js/modern/config/index.js +8 -0
  36. package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
  37. package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
  38. package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
  39. package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
  40. package/dist/js/modern/config/initial/index.js +16 -0
  41. package/dist/js/modern/config/initial/inits.js +153 -0
  42. package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
  43. package/dist/js/modern/defineConfig.js +27 -0
  44. package/dist/js/modern/exports/server.js +4 -1
  45. package/dist/js/modern/hooks.js +37 -21
  46. package/dist/js/modern/index.js +185 -94
  47. package/dist/js/modern/initialize/index.js +120 -0
  48. package/dist/js/modern/locale/en.js +20 -22
  49. package/dist/js/modern/locale/index.js +6 -6
  50. package/dist/js/modern/locale/zh.js +21 -23
  51. package/dist/js/modern/schema/Schema.js +40 -0
  52. package/dist/js/modern/schema/index.js +88 -0
  53. package/dist/js/modern/schema/legacy.js +148 -0
  54. package/dist/js/modern/types/config/deploy.js +0 -0
  55. package/dist/js/modern/types/config/dev.js +0 -0
  56. package/dist/js/modern/types/config/experiments.js +0 -0
  57. package/dist/js/modern/types/config/html.js +0 -0
  58. package/dist/js/modern/types/config/index.js +1 -0
  59. package/dist/js/modern/types/config/output.js +0 -0
  60. package/dist/js/modern/types/config/performance.js +0 -0
  61. package/dist/js/modern/types/config/security.js +0 -0
  62. package/dist/js/modern/types/config/source.js +0 -0
  63. package/dist/js/modern/types/config/tools.js +0 -0
  64. package/dist/js/modern/types/hooks.js +0 -0
  65. package/dist/js/modern/types/index.js +3 -0
  66. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  67. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  68. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  69. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  70. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  71. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  72. package/dist/js/modern/utils/commands.js +13 -0
  73. package/dist/js/modern/utils/config.js +102 -52
  74. package/dist/js/modern/utils/createFileWatcher.js +115 -0
  75. package/dist/js/modern/utils/createServer.js +67 -10
  76. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  77. package/dist/js/modern/utils/getSpecifiedEntries.js +46 -25
  78. package/dist/js/modern/utils/language.js +6 -3
  79. package/dist/js/modern/utils/printInstructions.js +29 -9
  80. package/dist/js/modern/utils/restart.js +44 -0
  81. package/dist/js/modern/utils/routes.js +29 -14
  82. package/dist/js/node/analyze/Builder.js +64 -0
  83. package/dist/js/node/analyze/constants.js +86 -33
  84. package/dist/js/node/analyze/generateCode.js +305 -163
  85. package/dist/js/node/analyze/getBundleEntry.js +66 -58
  86. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
  87. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
  88. package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
  89. package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
  90. package/dist/js/node/analyze/getFileSystemEntry.js +99 -58
  91. package/dist/js/node/analyze/getHtmlTemplate.js +121 -83
  92. package/dist/js/node/analyze/getServerRoutes.js +146 -160
  93. package/dist/js/node/analyze/index.js +243 -161
  94. package/dist/js/node/analyze/isDefaultExportFunction.js +59 -38
  95. package/dist/js/node/analyze/makeLegalIdentifier.js +31 -19
  96. package/dist/js/node/analyze/nestedRoutes.js +193 -0
  97. package/dist/js/node/analyze/templates.js +316 -43
  98. package/dist/js/node/analyze/utils.js +158 -78
  99. package/dist/js/node/builder/builderPlugins/compatModern.js +258 -0
  100. package/dist/js/node/builder/index.js +177 -0
  101. package/dist/js/node/builder/loaders/routerLoader.js +38 -0
  102. package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
  103. package/dist/js/node/builder/share.js +75 -0
  104. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
  105. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
  106. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
  107. package/dist/js/node/commands/build.js +97 -159
  108. package/dist/js/node/commands/deploy.js +49 -12
  109. package/dist/js/node/commands/dev.js +121 -93
  110. package/dist/js/node/commands/index.js +19 -44
  111. package/dist/js/node/commands/inspect.js +56 -93
  112. package/dist/js/node/commands/serve.js +83 -0
  113. package/dist/js/node/config/default.js +195 -0
  114. package/dist/js/node/config/index.js +34 -0
  115. package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
  116. package/dist/js/node/config/initial/createOutputConfig.js +91 -0
  117. package/dist/js/node/config/initial/createSourceConfig.js +62 -0
  118. package/dist/js/node/config/initial/createToolsConfig.js +65 -0
  119. package/dist/js/node/config/initial/index.js +41 -0
  120. package/dist/js/node/config/initial/inits.js +176 -0
  121. package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
  122. package/dist/js/node/defineConfig.js +49 -0
  123. package/dist/js/node/exports/server.js +25 -11
  124. package/dist/js/node/hooks.js +53 -36
  125. package/dist/js/node/index.js +216 -128
  126. package/dist/js/node/initialize/index.js +135 -0
  127. package/dist/js/node/locale/en.js +40 -26
  128. package/dist/js/node/locale/index.js +31 -18
  129. package/dist/js/node/locale/zh.js +41 -27
  130. package/dist/js/node/schema/Schema.js +63 -0
  131. package/dist/js/node/schema/index.js +118 -0
  132. package/dist/js/node/schema/legacy.js +169 -0
  133. package/dist/js/node/types/config/deploy.js +15 -0
  134. package/dist/js/node/types/config/dev.js +15 -0
  135. package/dist/js/node/types/config/experiments.js +15 -0
  136. package/dist/js/node/types/config/html.js +15 -0
  137. package/dist/js/node/types/config/index.js +17 -0
  138. package/dist/js/node/types/config/output.js +15 -0
  139. package/dist/js/node/types/config/performance.js +15 -0
  140. package/dist/js/node/types/config/security.js +15 -0
  141. package/dist/js/node/types/config/source.js +15 -0
  142. package/dist/js/node/types/config/tools.js +15 -0
  143. package/dist/js/node/types/hooks.js +15 -0
  144. package/dist/js/node/types/index.js +19 -0
  145. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  146. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  147. package/dist/js/node/types/legacyConfig/index.js +15 -0
  148. package/dist/js/node/types/legacyConfig/output.js +15 -0
  149. package/dist/js/node/types/legacyConfig/source.js +15 -0
  150. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  151. package/dist/js/node/utils/commands.js +37 -0
  152. package/dist/js/node/utils/config.js +125 -75
  153. package/dist/js/node/utils/createFileWatcher.js +139 -0
  154. package/dist/js/node/utils/createServer.js +96 -25
  155. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  156. package/dist/js/node/utils/getSpecifiedEntries.js +68 -34
  157. package/dist/js/node/utils/language.js +28 -10
  158. package/dist/js/node/utils/printInstructions.js +51 -19
  159. package/dist/js/node/utils/restart.js +67 -0
  160. package/dist/js/node/utils/routes.js +58 -24
  161. package/dist/js/node/utils/types.js +15 -0
  162. package/dist/js/treeshaking/analyze/Builder.js +199 -0
  163. package/dist/js/treeshaking/analyze/constants.js +37 -0
  164. package/dist/js/treeshaking/analyze/generateCode.js +615 -0
  165. package/dist/js/treeshaking/analyze/getBundleEntry.js +64 -0
  166. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
  167. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
  168. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
  169. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
  170. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
  171. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
  172. package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
  173. package/dist/js/treeshaking/analyze/index.js +589 -0
  174. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
  175. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
  176. package/dist/js/treeshaking/analyze/nestedRoutes.js +426 -0
  177. package/dist/js/treeshaking/analyze/templates.js +446 -0
  178. package/dist/js/treeshaking/analyze/utils.js +390 -0
  179. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +304 -0
  180. package/dist/js/treeshaking/builder/index.js +374 -0
  181. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  182. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
  183. package/dist/js/treeshaking/builder/share.js +40 -0
  184. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
  185. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
  186. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +343 -0
  187. package/dist/js/treeshaking/commands/build.js +291 -0
  188. package/dist/js/treeshaking/commands/deploy.js +154 -0
  189. package/dist/js/treeshaking/commands/dev.js +319 -0
  190. package/dist/js/treeshaking/commands/index.js +3 -0
  191. package/dist/js/treeshaking/commands/inspect.js +149 -0
  192. package/dist/js/treeshaking/commands/serve.js +199 -0
  193. package/dist/js/treeshaking/config/default.js +208 -0
  194. package/dist/js/treeshaking/config/index.js +3 -0
  195. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
  196. package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
  197. package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
  198. package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
  199. package/dist/js/treeshaking/config/initial/index.js +12 -0
  200. package/dist/js/treeshaking/config/initial/inits.js +213 -0
  201. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
  202. package/dist/js/treeshaking/defineConfig.js +61 -0
  203. package/dist/js/treeshaking/exports/server.js +2 -0
  204. package/dist/js/treeshaking/hooks.js +31 -0
  205. package/dist/js/treeshaking/index.js +694 -0
  206. package/dist/js/treeshaking/initialize/index.js +300 -0
  207. package/dist/js/treeshaking/locale/en.js +35 -0
  208. package/dist/js/treeshaking/locale/index.js +9 -0
  209. package/dist/js/treeshaking/locale/zh.js +35 -0
  210. package/dist/js/treeshaking/schema/Schema.js +273 -0
  211. package/dist/js/treeshaking/schema/index.js +181 -0
  212. package/dist/js/treeshaking/schema/legacy.js +337 -0
  213. package/dist/js/treeshaking/types/config/deploy.js +1 -0
  214. package/dist/js/treeshaking/types/config/dev.js +1 -0
  215. package/dist/js/treeshaking/types/config/experiments.js +1 -0
  216. package/dist/js/treeshaking/types/config/html.js +1 -0
  217. package/dist/js/treeshaking/types/config/index.js +1 -0
  218. package/dist/js/treeshaking/types/config/output.js +1 -0
  219. package/dist/js/treeshaking/types/config/performance.js +1 -0
  220. package/dist/js/treeshaking/types/config/security.js +1 -0
  221. package/dist/js/treeshaking/types/config/source.js +1 -0
  222. package/dist/js/treeshaking/types/config/tools.js +1 -0
  223. package/dist/js/treeshaking/types/hooks.js +1 -0
  224. package/dist/js/treeshaking/types/index.js +3 -0
  225. package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
  226. package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
  227. package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
  228. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  229. package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
  230. package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
  231. package/dist/js/treeshaking/utils/commands.js +10 -0
  232. package/dist/js/treeshaking/utils/config.js +302 -0
  233. package/dist/js/treeshaking/utils/createFileWatcher.js +283 -0
  234. package/dist/js/treeshaking/utils/createServer.js +258 -0
  235. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  236. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +185 -0
  237. package/dist/js/treeshaking/utils/language.js +6 -0
  238. package/dist/js/treeshaking/utils/printInstructions.js +152 -0
  239. package/dist/js/treeshaking/utils/restart.js +187 -0
  240. package/dist/js/treeshaking/utils/routes.js +153 -0
  241. package/dist/js/treeshaking/utils/types.js +1 -0
  242. package/dist/types/analyze/Builder.d.ts +8 -0
  243. package/dist/types/analyze/constants.d.ts +13 -1
  244. package/dist/types/analyze/generateCode.d.ts +3 -2
  245. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  246. package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
  247. package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
  248. package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
  249. package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
  250. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  251. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  252. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  253. package/dist/types/analyze/index.d.ts +3 -40
  254. package/dist/types/analyze/nestedRoutes.d.ts +5 -0
  255. package/dist/types/analyze/templates.d.ts +24 -5
  256. package/dist/types/analyze/utils.d.ts +12 -2
  257. package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
  258. package/dist/types/builder/index.d.ts +18 -0
  259. package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
  260. package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
  261. package/dist/types/builder/share.d.ts +26 -0
  262. package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
  263. package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
  264. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +4 -0
  265. package/dist/types/commands/build.d.ts +2 -1
  266. package/dist/types/commands/deploy.d.ts +2 -1
  267. package/dist/types/commands/dev.d.ts +2 -1
  268. package/dist/types/commands/index.d.ts +1 -1
  269. package/dist/types/commands/inspect.d.ts +10 -6
  270. package/dist/types/commands/serve.d.ts +3 -0
  271. package/dist/types/config/default.d.ts +3 -0
  272. package/dist/types/config/index.d.ts +2 -0
  273. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  274. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  275. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  276. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  277. package/dist/types/config/initial/index.d.ts +4 -0
  278. package/dist/types/config/initial/inits.d.ts +4 -0
  279. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  280. package/dist/types/defineConfig.d.ts +8 -0
  281. package/dist/types/hooks.d.ts +2 -37
  282. package/dist/types/index.d.ts +9 -3
  283. package/dist/types/initialize/index.d.ts +5 -0
  284. package/dist/types/locale/en.d.ts +1 -2
  285. package/dist/types/locale/index.d.ts +2 -4
  286. package/dist/types/locale/zh.d.ts +1 -2
  287. package/dist/types/schema/Schema.d.ts +14 -0
  288. package/dist/types/schema/index.d.ts +4 -0
  289. package/dist/types/schema/legacy.d.ts +3 -0
  290. package/dist/types/types/config/deploy.d.ts +9 -0
  291. package/dist/types/types/config/dev.d.ts +13 -0
  292. package/dist/types/types/config/experiments.d.ts +4 -0
  293. package/dist/types/types/config/html.d.ts +4 -0
  294. package/dist/types/types/config/index.d.ts +66 -0
  295. package/dist/types/types/config/output.d.ts +22 -0
  296. package/dist/types/types/config/performance.d.ts +4 -0
  297. package/dist/types/types/config/security.d.ts +4 -0
  298. package/dist/types/types/config/source.d.ts +24 -0
  299. package/dist/types/types/config/tools.d.ts +24 -0
  300. package/dist/types/types/hooks.d.ts +89 -0
  301. package/dist/types/types/index.d.ts +23 -0
  302. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  303. package/dist/types/types/legacyConfig/dev.d.ts +13 -0
  304. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  305. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  306. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  307. package/dist/types/types/legacyConfig/tools.d.ts +17 -0
  308. package/dist/types/utils/commands.d.ts +2 -0
  309. package/dist/types/utils/config.d.ts +2 -2
  310. package/dist/types/utils/createFileWatcher.d.ts +4 -0
  311. package/dist/types/utils/createServer.d.ts +9 -1
  312. package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
  313. package/dist/types/utils/printInstructions.d.ts +3 -2
  314. package/dist/types/utils/restart.d.ts +3 -0
  315. package/dist/types/utils/types.d.ts +2 -3
  316. package/lib/types.d.ts +1 -1
  317. package/package.json +37 -46
  318. package/dist/js/modern/analyze/getClientRoutes.js +0 -219
  319. package/dist/js/modern/commands/start.js +0 -31
  320. package/dist/js/modern/utils/createCompiler.js +0 -61
  321. package/dist/js/node/analyze/getClientRoutes.js +0 -241
  322. package/dist/js/node/commands/start.js +0 -47
  323. package/dist/js/node/utils/createCompiler.js +0 -81
  324. package/dist/types/commands/start.d.ts +0 -2
  325. package/dist/types/utils/createCompiler.d.ts +0 -13
@@ -1,148 +1,235 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- import * as path from 'path';
8
- import { createAsyncWaterfall } from '@modern-js/plugin';
9
- import { createDebugger, fs, isApiOnly } from '@modern-js/utils';
10
- import { cloneDeep } from '@modern-js/utils/lodash';
11
- import { isRouteComponentFile } from "./utils";
12
- const debug = createDebugger('plugin-analyze');
13
- export const modifyEntryImports = createAsyncWaterfall();
14
- export const modifyEntryExport = createAsyncWaterfall();
15
- export const addRuntimeExports = createAsyncWaterfall();
16
- export const modifyEntryRuntimePlugins = createAsyncWaterfall();
17
- export const modifyEntryRenderFunction = createAsyncWaterfall();
18
- export const modifyAsyncEntry = createAsyncWaterfall();
19
- export const modifyFileSystemRoutes = createAsyncWaterfall();
20
- export const modifyServerRoutes = createAsyncWaterfall();
21
- export const htmlPartials = createAsyncWaterfall();
22
- export const beforeGenerateRoutes = createAsyncWaterfall();
23
- export const addDefineTypes = createAsyncWaterfall();
24
- export default (() => ({
25
- name: '@modern-js/plugin-analyze',
26
- registerHook: {
27
- modifyAsyncEntry,
28
- modifyEntryImports,
29
- modifyEntryExport,
30
- modifyEntryRuntimePlugins,
31
- modifyEntryRenderFunction,
32
- modifyFileSystemRoutes,
33
- modifyServerRoutes,
34
- htmlPartials,
35
- addRuntimeExports,
36
- beforeGenerateRoutes,
37
- addDefineTypes
38
- },
39
- setup: api => {
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import * as path from "path";
41
+ import { createDebugger, fs, isApiOnly } from "@modern-js/utils";
42
+ import { cloneDeep } from "@modern-js/utils/lodash";
43
+ import { createBuilderForModern } from "../builder";
44
+ import { printInstructions } from "../utils/printInstructions";
45
+ import { generateRoutes } from "../utils/routes";
46
+ import { emitResolvedConfig } from "../utils/config";
47
+ import { getCommand } from "../utils/commands";
48
+ import { initialNormalizedConfig } from "../config";
49
+ import { isNestedRouteComponent, isPageComponentFile } from "./utils";
50
+ import { loaderBuilder, serverLoaderBuilder } from "./Builder";
51
+ const debug = createDebugger("plugin-analyze");
52
+ var analyze_default = () => ({
53
+ name: "@modern-js/plugin-analyze",
54
+ setup: (api) => {
40
55
  let pagesDir = [];
56
+ let nestedRouteEntries = [];
41
57
  let originEntrypoints = [];
42
58
  return {
43
- async prepare() {
44
- var _resolvedConfig$sourc;
45
-
46
- const appContext = api.useAppContext();
47
- const resolvedConfig = api.useResolvedConfigContext();
48
- const hookRunners = api.useHookRunners();
49
-
50
- try {
51
- fs.emptydirSync(appContext.internalDirectory);
52
- } catch (_unused) {// FIXME:
53
- }
54
-
55
- const apiOnly = await isApiOnly(appContext.appDirectory, resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig$sourc = resolvedConfig.source) === null || _resolvedConfig$sourc === void 0 ? void 0 : _resolvedConfig$sourc.entriesDir);
56
- await hookRunners.addRuntimeExports();
57
-
58
- if (apiOnly) {
59
- const {
60
- routes
61
- } = await hookRunners.modifyServerRoutes({
62
- routes: []
59
+ prepare() {
60
+ return __async(this, null, function* () {
61
+ var _a2;
62
+ let appContext = api.useAppContext();
63
+ const resolvedConfig = api.useResolvedConfigContext();
64
+ const hookRunners = api.useHookRunners();
65
+ try {
66
+ fs.emptydirSync(appContext.internalDirectory);
67
+ } catch (e) {
68
+ }
69
+ const apiOnly = yield isApiOnly(
70
+ appContext.appDirectory,
71
+ (_a2 = resolvedConfig.source) == null ? void 0 : _a2.entriesDir
72
+ );
73
+ yield hookRunners.addRuntimeExports();
74
+ if (apiOnly) {
75
+ const { routes: routes2 } = yield hookRunners.modifyServerRoutes({
76
+ routes: []
77
+ });
78
+ debug(`server routes: %o`, routes2);
79
+ appContext = __spreadProps(__spreadValues({}, appContext), {
80
+ apiOnly,
81
+ serverRoutes: routes2
82
+ });
83
+ api.setAppContext(appContext);
84
+ return;
85
+ }
86
+ const [
87
+ { getBundleEntry },
88
+ { getServerRoutes },
89
+ { generateCode },
90
+ { getHtmlTemplate }
91
+ ] = yield Promise.all([
92
+ import("./getBundleEntry"),
93
+ import("./getServerRoutes"),
94
+ import("./generateCode"),
95
+ import("./getHtmlTemplate")
96
+ ]);
97
+ const entrypoints = getBundleEntry(appContext, resolvedConfig);
98
+ console.log("final entries", entrypoints);
99
+ const defaultChecked = entrypoints.map((point) => point.entryName);
100
+ debug(`entrypoints: %o`, entrypoints);
101
+ const initialRoutes = getServerRoutes(entrypoints, {
102
+ appContext,
103
+ config: resolvedConfig
104
+ });
105
+ const { routes } = yield hookRunners.modifyServerRoutes({
106
+ routes: initialRoutes
63
107
  });
64
108
  debug(`server routes: %o`, routes);
65
- api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
66
- apiOnly,
109
+ appContext = __spreadProps(__spreadValues({}, appContext), {
110
+ entrypoints,
67
111
  serverRoutes: routes
68
- }));
69
- return;
70
- }
71
-
72
- const [{
73
- getBundleEntry
74
- }, {
75
- getServerRoutes
76
- }, {
77
- generateCode
78
- }, {
79
- getHtmlTemplate
80
- }] = await Promise.all([import("./getBundleEntry"), import("./getServerRoutes"), import("./generateCode"), import("./getHtmlTemplate")]);
81
- const entrypoints = getBundleEntry(appContext, resolvedConfig);
82
- const defaultChecked = entrypoints.map(point => point.entryName);
83
- debug(`entrypoints: %o`, entrypoints);
84
- const initialRoutes = getServerRoutes(entrypoints, {
85
- appContext,
86
- config: resolvedConfig
87
- });
88
- const {
89
- routes
90
- } = await hookRunners.modifyServerRoutes({
91
- routes: initialRoutes
92
- });
93
- debug(`server routes: %o`, routes);
94
- api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
95
- entrypoints,
96
- serverRoutes: routes
97
- }));
98
- pagesDir = entrypoints.map(point => point.entry);
99
- originEntrypoints = cloneDeep(entrypoints);
100
- await generateCode(appContext, resolvedConfig, entrypoints, api);
101
- const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
102
- appContext,
103
- config: resolvedConfig
112
+ });
113
+ api.setAppContext(appContext);
114
+ nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
115
+ pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
116
+ originEntrypoints = cloneDeep(entrypoints);
117
+ yield generateCode(appContext, resolvedConfig, entrypoints, api);
118
+ const htmlTemplates = yield getHtmlTemplate(entrypoints, api, {
119
+ appContext,
120
+ config: resolvedConfig
121
+ });
122
+ debug(`html templates: %o`, htmlTemplates);
123
+ yield hookRunners.addDefineTypes();
124
+ debug(`add Define Types`);
125
+ appContext = __spreadProps(__spreadValues({}, appContext), {
126
+ entrypoints,
127
+ checkedEntries: defaultChecked,
128
+ apiOnly,
129
+ serverRoutes: routes,
130
+ htmlTemplates
131
+ });
132
+ api.setAppContext(appContext);
133
+ const command = getCommand();
134
+ const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
135
+ if (buildCommands.includes(command)) {
136
+ let _b;
137
+ const normalizedConfig = api.useResolvedConfigContext();
138
+ const builder = yield createBuilderForModern({
139
+ normalizedConfig,
140
+ appContext,
141
+ compatPluginConfig: {
142
+ onBeforeBuild(_0) {
143
+ return __async(this, arguments, function* ({ bundlerConfigs }) {
144
+ const hookRunners2 = api.useHookRunners();
145
+ yield generateRoutes(appContext);
146
+ yield hookRunners2.beforeBuild({ bundlerConfigs });
147
+ });
148
+ },
149
+ onAfterBuild(_0) {
150
+ return __async(this, arguments, function* ({ stats }) {
151
+ const hookRunners2 = api.useHookRunners();
152
+ yield hookRunners2.afterBuild({ stats });
153
+ yield emitResolvedConfig(
154
+ appContext.appDirectory,
155
+ normalizedConfig
156
+ );
157
+ });
158
+ },
159
+ onDevCompileDone(_0) {
160
+ return __async(this, arguments, function* ({ isFirstCompile }) {
161
+ const hookRunners2 = api.useHookRunners();
162
+ if (process.stdout.isTTY || isFirstCompile) {
163
+ hookRunners2.afterDev();
164
+ if (isFirstCompile) {
165
+ printInstructions(
166
+ hookRunners2,
167
+ appContext,
168
+ normalizedConfig
169
+ );
170
+ }
171
+ }
172
+ });
173
+ },
174
+ onBeforeCreateCompiler(_0) {
175
+ return __async(this, arguments, function* ({ bundlerConfigs }) {
176
+ const hookRunners2 = api.useHookRunners();
177
+ yield hookRunners2.beforeCreateCompiler({
178
+ bundlerConfigs
179
+ });
180
+ });
181
+ },
182
+ onAfterCreateCompiler(_0) {
183
+ return __async(this, arguments, function* ({ compiler }) {
184
+ const hookRunners2 = api.useHookRunners();
185
+ yield hookRunners2.afterCreateCompiler({ compiler });
186
+ });
187
+ }
188
+ }
189
+ });
190
+ builder.addPlugins(resolvedConfig.builderPlugins);
191
+ appContext = __spreadProps(__spreadValues({}, appContext), {
192
+ builder
193
+ });
194
+ api.setAppContext(appContext);
195
+ }
104
196
  });
105
- debug(`html templates: %o`, htmlTemplates);
106
- await hookRunners.addDefineTypes();
107
- debug(`add Define Types`);
108
- api.setAppContext(_objectSpread(_objectSpread({}, appContext), {}, {
109
- entrypoints,
110
- checkedEntries: defaultChecked,
111
- apiOnly,
112
- serverRoutes: routes,
113
- htmlTemplates
114
- }));
115
197
  },
116
-
117
198
  watchFiles() {
118
199
  return pagesDir;
119
200
  },
120
-
121
- async fileChange(e) {
201
+ resolvedConfig({ resolved }) {
122
202
  const appContext = api.useAppContext();
123
- const {
124
- appDirectory
125
- } = appContext;
126
- const {
127
- filename,
128
- eventType
129
- } = e;
130
-
131
- const isPageFile = name => pagesDir.some(pageDir => name.includes(pageDir));
132
-
133
- const absoluteFilePath = path.resolve(appDirectory, filename);
134
- const isRouteComponent = isPageFile(absoluteFilePath) && isRouteComponentFile(absoluteFilePath);
135
-
136
- if (isRouteComponent && (eventType === 'add' || eventType === 'unlink')) {
137
- const resolvedConfig = api.useResolvedConfigContext();
138
- const {
139
- generateCode
140
- } = await import("./generateCode");
141
- const entrypoints = cloneDeep(originEntrypoints);
142
- generateCode(appContext, resolvedConfig, entrypoints, api);
143
- }
203
+ const config = initialNormalizedConfig(resolved, appContext);
204
+ return {
205
+ resolved: config
206
+ };
207
+ },
208
+ beforeRestart() {
209
+ return __async(this, null, function* () {
210
+ serverLoaderBuilder.stop();
211
+ loaderBuilder.stop();
212
+ });
213
+ },
214
+ fileChange(e) {
215
+ return __async(this, null, function* () {
216
+ const appContext = api.useAppContext();
217
+ const { appDirectory } = appContext;
218
+ const { filename, eventType } = e;
219
+ const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
220
+ const absoluteFilePath = path.resolve(appDirectory, filename);
221
+ const isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
222
+ if (isRouteComponent && (eventType === "add" || eventType === "unlink") || isNestedRouteComponent(nestedRouteEntries, absoluteFilePath) && eventType === "change") {
223
+ const resolvedConfig = api.useResolvedConfigContext();
224
+ const { generateCode } = yield import("./generateCode");
225
+ const entrypoints = cloneDeep(originEntrypoints);
226
+ generateCode(appContext, resolvedConfig, entrypoints, api);
227
+ }
228
+ });
144
229
  }
145
-
146
230
  };
147
231
  }
148
- }));
232
+ });
233
+ export {
234
+ analyze_default as default
235
+ };
@@ -1,32 +1,42 @@
1
- import fs from 'fs';
2
- import { parse } from '@babel/parser';
3
- import traverse from '@babel/traverse';
4
- import * as t from '@babel/types';
5
-
6
- const isFunction = node => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
7
-
8
- export const isDefaultExportFunction = file => {
1
+ import fs from "fs";
2
+ import { parse } from "@babel/parser";
3
+ import traverse from "@babel/traverse";
4
+ import * as t from "@babel/types";
5
+ const isFunction = (node) => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
6
+ const isDefaultExportFunction = (file) => {
9
7
  if (!file || !fs.existsSync(file)) {
10
8
  return false;
11
9
  }
12
-
13
- const ast = parse(fs.readFileSync(file, 'utf8'), {
14
- sourceType: 'unambiguous',
15
- plugins: ['jsx', 'typescript', 'classProperties', 'dynamicImport', 'exportDefaultFrom', 'exportNamespaceFrom', 'decorators-legacy', 'functionBind', 'classPrivateMethods', ['pipelineOperator', {
16
- proposal: 'minimal'
17
- }], 'optionalChaining', 'optionalCatchBinding', 'objectRestSpread', 'numericSeparator']
10
+ const ast = parse(fs.readFileSync(file, "utf8"), {
11
+ sourceType: "unambiguous",
12
+ plugins: [
13
+ "jsx",
14
+ "typescript",
15
+ "classProperties",
16
+ "dynamicImport",
17
+ "exportDefaultFrom",
18
+ "exportNamespaceFrom",
19
+ "decorators-legacy",
20
+ "functionBind",
21
+ "classPrivateMethods",
22
+ ["pipelineOperator", { proposal: "minimal" }],
23
+ "optionalChaining",
24
+ "optionalCatchBinding",
25
+ "objectRestSpread",
26
+ "numericSeparator"
27
+ ]
18
28
  });
19
29
  let isExportFunction = false;
20
30
  traverse(ast, {
21
- ExportDefaultDeclaration: path => {
22
- const {
23
- declaration
24
- } = path.node;
25
-
31
+ ExportDefaultDeclaration: (path) => {
32
+ const { declaration } = path.node;
26
33
  if (isFunction(declaration)) {
27
34
  isExportFunction = true;
28
35
  }
29
36
  }
30
37
  });
31
38
  return isExportFunction;
32
- };
39
+ };
40
+ export {
41
+ isDefaultExportFunction
42
+ };
@@ -1,16 +1,13 @@
1
- /**
2
- * modified from https://github.com/rollup/plugins/blob/master/packages/pluginutils
3
- * license at https://github.com/rollup/plugins/blob/master/LICENSE
4
- */
5
- const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
6
- const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
7
- const forbidList = new Set(`${reservedWords} ${builtins}`.split(' '));
8
- export function makeLegalIdentifier(str) {
9
- const identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, '_');
10
-
1
+ const reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
2
+ const builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
3
+ const forbidList = new Set(`${reservedWords} ${builtins}`.split(" "));
4
+ function makeLegalIdentifier(str) {
5
+ const identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
11
6
  if (/\d/.test(identifier[0]) || forbidList.has(identifier)) {
12
7
  return `_${identifier}`;
13
8
  }
14
-
15
- return identifier || '_';
16
- }
9
+ return identifier || "_";
10
+ }
11
+ export {
12
+ makeLegalIdentifier
13
+ };
@@ -0,0 +1,166 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import * as path from "path";
41
+ import { fs, getRouteId } from "@modern-js/utils";
42
+ import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
43
+ import { hasLoader, replaceWithAlias } from "./utils";
44
+ const conventionNames = Object.values(NESTED_ROUTE);
45
+ const getLoaderPath = (filename) => __async(void 0, null, function* () {
46
+ if (yield hasLoader(filename)) {
47
+ return filename;
48
+ }
49
+ return void 0;
50
+ });
51
+ const replaceDynamicPath = (routePath) => {
52
+ return routePath.replace(/\[(.*?)\]/g, ":$1");
53
+ };
54
+ const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
55
+ return createRoute(
56
+ __spreadProps(__spreadValues({}, routeInfo), {
57
+ index: true,
58
+ children: void 0
59
+ }),
60
+ rootDir,
61
+ filename,
62
+ entryName
63
+ );
64
+ };
65
+ const createRoute = (routeInfo, rootDir, filename, entryName) => {
66
+ const id = getRouteId(filename, rootDir, entryName);
67
+ return __spreadProps(__spreadValues({}, routeInfo), {
68
+ id,
69
+ type: "nested"
70
+ });
71
+ };
72
+ const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, function* () {
73
+ var _a, _b;
74
+ if (!(yield fs.pathExists(dirname))) {
75
+ return null;
76
+ }
77
+ const isDirectory = (yield fs.stat(dirname)).isDirectory();
78
+ if (!isDirectory) {
79
+ return null;
80
+ }
81
+ const relativeDir = path.relative(rootDir, dirname);
82
+ const pathSegments = relativeDir.split(path.sep);
83
+ const lastSegment = pathSegments[pathSegments.length - 1];
84
+ const isRoot = lastSegment === "";
85
+ const isPathlessLayout = lastSegment.startsWith("__");
86
+ const isWithoutLayoutPath = lastSegment.includes(".");
87
+ let routePath = isRoot || isPathlessLayout ? "/" : `${lastSegment}`;
88
+ if (isWithoutLayoutPath) {
89
+ routePath = lastSegment.split(".").join("/");
90
+ }
91
+ routePath = replaceDynamicPath(routePath);
92
+ const route = {
93
+ path: routePath,
94
+ children: [],
95
+ isRoot
96
+ };
97
+ let pageLoaderFile = "";
98
+ let pageRoute = null;
99
+ const items = yield fs.readdir(dirname);
100
+ for (const item of items) {
101
+ const itemPath = path.join(dirname, item);
102
+ const extname = path.extname(item);
103
+ const itemWithoutExt = item.slice(0, -extname.length);
104
+ const isDirectory2 = (yield fs.stat(itemPath)).isDirectory();
105
+ if (isDirectory2) {
106
+ const childRoute = yield walk(itemPath, rootDir, alias, entryName);
107
+ if (childRoute) {
108
+ (_a = route.children) == null ? void 0 : _a.push(childRoute);
109
+ }
110
+ }
111
+ if (extname && (!JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt))) {
112
+ continue;
113
+ }
114
+ if (itemWithoutExt === NESTED_ROUTE.LAYOUT_LOADER_FILE) {
115
+ if (!route.loader) {
116
+ route.loader = itemPath;
117
+ }
118
+ }
119
+ if (itemWithoutExt === NESTED_ROUTE.LAYOUT_FILE) {
120
+ route._component = replaceWithAlias(alias.basename, itemPath, alias.name);
121
+ const loaderPath = yield getLoaderPath(itemPath);
122
+ if (loaderPath) {
123
+ route.loader = loaderPath;
124
+ }
125
+ }
126
+ if (itemWithoutExt === NESTED_ROUTE.PAGE_LOADER_FILE) {
127
+ pageLoaderFile = itemPath;
128
+ }
129
+ if (itemWithoutExt === NESTED_ROUTE.PAGE_FILE) {
130
+ pageRoute = createIndexRoute(
131
+ {
132
+ _component: replaceWithAlias(alias.basename, itemPath, alias.name)
133
+ },
134
+ rootDir,
135
+ itemPath,
136
+ entryName
137
+ );
138
+ const loaderPath = yield getLoaderPath(itemPath);
139
+ if (loaderPath) {
140
+ pageRoute.loader = loaderPath;
141
+ } else if (pageLoaderFile) {
142
+ pageRoute.loader = pageLoaderFile;
143
+ }
144
+ (_b = route.children) == null ? void 0 : _b.push(pageRoute);
145
+ }
146
+ if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
147
+ route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
148
+ }
149
+ if (itemWithoutExt === NESTED_ROUTE.ERROR_FILE) {
150
+ route.error = replaceWithAlias(alias.basename, itemPath, alias.name);
151
+ }
152
+ }
153
+ const finalRoute = createRoute(
154
+ route,
155
+ rootDir,
156
+ path.join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`),
157
+ entryName
158
+ );
159
+ if (isPathlessLayout) {
160
+ delete finalRoute.path;
161
+ }
162
+ return finalRoute;
163
+ });
164
+ export {
165
+ walk
166
+ };