@modern-js/app-tools 1.22.1 → 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 -87
  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
@@ -0,0 +1,89 @@
1
+ import type { webpack } from '@modern-js/builder-webpack-provider';
2
+ import type { AsyncWaterfall, AsyncWorkflow, ParallelWorkflow } from '@modern-js/plugin';
3
+ import type { Entrypoint, HtmlPartials, NestedRoute, PageRoute, RouteLegacy, ServerRoute } from '@modern-js/types';
4
+ import type { RegisterBuildPlatformResult, DevToolData } from '@modern-js/core';
5
+ import type { Stats, MultiStats } from '@modern-js/builder-shared';
6
+ export interface ImportSpecifier {
7
+ local?: string;
8
+ imported?: string;
9
+ }
10
+ export interface ImportStatement {
11
+ specifiers: ImportSpecifier[];
12
+ value: string;
13
+ initialize?: string;
14
+ }
15
+ export interface RuntimePlugin {
16
+ name: string;
17
+ options: string;
18
+ args?: string;
19
+ }
20
+ export declare type AppToolsHooks = {
21
+ modifyEntryExport: AsyncWaterfall<{
22
+ entrypoint: Entrypoint;
23
+ exportStatement: string;
24
+ }>;
25
+ modifyEntryImports: AsyncWaterfall<{
26
+ imports: ImportStatement[];
27
+ entrypoint: Entrypoint;
28
+ }>;
29
+ modifyEntryRuntimePlugins: AsyncWaterfall<{
30
+ entrypoint: Entrypoint;
31
+ plugins: RuntimePlugin[];
32
+ }>;
33
+ modifyEntryRenderFunction: AsyncWaterfall<{
34
+ entrypoint: Entrypoint;
35
+ code: string;
36
+ }>;
37
+ modifyAsyncEntry: AsyncWaterfall<{
38
+ entrypoint: Entrypoint;
39
+ code: string;
40
+ }>;
41
+ modifyFileSystemRoutes: AsyncWaterfall<{
42
+ entrypoint: Entrypoint;
43
+ routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
44
+ }>;
45
+ modifyServerRoutes: AsyncWaterfall<{
46
+ routes: ServerRoute[];
47
+ }>;
48
+ htmlPartials: AsyncWaterfall<{
49
+ entrypoint: Entrypoint;
50
+ partials: HtmlPartials;
51
+ }>;
52
+ beforeGenerateRoutes: AsyncWaterfall<{
53
+ entrypoint: Entrypoint;
54
+ code: string;
55
+ }>;
56
+ addDefineTypes: AsyncWaterfall<void>;
57
+ collectServerPlugins: AsyncWaterfall<{
58
+ plugins: Array<Record<string, string>>;
59
+ }>;
60
+ beforeDev: AsyncWorkflow<void, unknown>;
61
+ afterDev: AsyncWorkflow<void, unknown>;
62
+ beforeCreateCompiler: AsyncWorkflow<{
63
+ bundlerConfigs: webpack.Configuration[];
64
+ }, unknown>;
65
+ afterCreateCompiler: AsyncWorkflow<{
66
+ compiler?: webpack.Compiler | webpack.MultiCompiler;
67
+ }, unknown>;
68
+ beforePrintInstructions: AsyncWaterfall<{
69
+ instructions: string;
70
+ }>;
71
+ beforeBuild: AsyncWorkflow<{
72
+ bundlerConfigs?: webpack.Configuration[];
73
+ }, unknown>;
74
+ afterBuild: AsyncWorkflow<{
75
+ stats?: Stats | MultiStats;
76
+ }, unknown>;
77
+ beforeDeploy: AsyncWorkflow<Record<string, any>, unknown>;
78
+ afterDeploy: AsyncWorkflow<Record<string, any>, unknown>;
79
+ watchFiles: ParallelWorkflow<void>;
80
+ fileChange: AsyncWorkflow<{
81
+ filename: string;
82
+ eventType: 'add' | 'change' | 'unlink';
83
+ }, void>;
84
+ beforeRestart: AsyncWorkflow<void, void>;
85
+ registerDev: ParallelWorkflow<void, DevToolData>;
86
+ beforeDevTask: ParallelWorkflow<DevToolData, void>;
87
+ registerBuildPlatform: ParallelWorkflow<void, RegisterBuildPlatformResult>;
88
+ beforeBuildPlatform: ParallelWorkflow<RegisterBuildPlatformResult[], void>;
89
+ };
@@ -0,0 +1,23 @@
1
+ import type { NormalizedConfig, UserConfig } from '@modern-js/core';
2
+ import type { AppToolsUserConfig, AppToolsNormalizedConfig } from './config';
3
+ import type { AppToolsHooks } from './hooks';
4
+ import type { AppToolsLegacyUserConfig, AppToolsLegacyNormalizedConfig } from './legacyConfig';
5
+ export * from './hooks';
6
+ export * from './config';
7
+ export * from './legacyConfig';
8
+ export type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig, SSR, SSRByEntries } from '@modern-js/server-core';
9
+ export type { IAppContext, PluginAPI, CliPlugin, NormalizedConfig, UserConfig } from '@modern-js/core';
10
+ export declare type AppTools = {
11
+ hooks: AppToolsHooks;
12
+ userConfig: AppToolsUserConfig;
13
+ normalizedConfig: AppToolsNormalizedConfig;
14
+ };
15
+ export declare type LegacyAppTools = {
16
+ hooks: AppToolsHooks;
17
+ userConfig: AppToolsLegacyUserConfig;
18
+ normalizedConfig: AppToolsLegacyNormalizedConfig;
19
+ };
20
+ export declare type AppNormalizedConfig = NormalizedConfig<AppTools>;
21
+ export declare type AppLegacyNormalizedConfig = NormalizedConfig<LegacyAppTools>;
22
+ export declare type AppUserConfig = UserConfig<AppTools>;
23
+ export declare type AppLegacyUserConfig = UserConfig<LegacyAppTools>;
@@ -0,0 +1,8 @@
1
+ export interface MicroFrontend {
2
+ enableHtmlEntry?: boolean;
3
+ externalBasicLibrary?: boolean;
4
+ moduleApp?: string;
5
+ }
6
+ export declare type DeployLegacyUserConfig = {
7
+ microFrontend?: boolean | MicroFrontend;
8
+ };
@@ -0,0 +1,13 @@
1
+ import type { DevServerHttpsOptions } from '@modern-js/types';
2
+ export declare type DevProxyOptions = string | Record<string, string>;
3
+ export declare type DevUserLegacyConfig = {
4
+ assetPrefix?: string | boolean;
5
+ https?: DevServerHttpsOptions;
6
+ /**
7
+ * The configuration of `dev.proxy` is provided by `proxy` plugin.
8
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
9
+ * @requires `proxy` plugin
10
+ */
11
+
12
+ proxy?: DevProxyOptions;
13
+ };
@@ -0,0 +1,33 @@
1
+ import type { ServerUserConfig as LegacyServerUserConfig, BffUserConfig as LegacyBffUserConfig } from '@modern-js/server-core';
2
+ import type { DevUserLegacyConfig } from './dev';
3
+ import type { OutputLegacyUserConfig } from './output';
4
+ import type { SourceLegacyUserConfig } from './source';
5
+ import type { DeployLegacyUserConfig } from './deploy';
6
+ import type { ToolsLegacyUserConfig } from './tools';
7
+ export type { DevUserLegacyConfig } from './dev';
8
+ export type { OutputLegacyUserConfig } from './output';
9
+ export type { DeployLegacyUserConfig } from './deploy';
10
+ export type { SourceLegacyUserConfig } from './source';
11
+ export type { ToolsLegacyUserConfig } from './tools';
12
+ export interface RuntimeLegacyConfig {
13
+ [name: string]: any;
14
+ }
15
+ export interface RuntimeByEntriesLegacyConfig {
16
+ [name: string]: RuntimeLegacyConfig;
17
+ }
18
+ export declare type AppToolsLegacyUserConfig = {
19
+ source?: SourceLegacyUserConfig;
20
+ output?: OutputLegacyUserConfig;
21
+ server?: LegacyServerUserConfig;
22
+ dev?: DevUserLegacyConfig;
23
+ deploy?: DeployLegacyUserConfig;
24
+ tools?: ToolsLegacyUserConfig;
25
+ runtime?: RuntimeLegacyConfig;
26
+ runtimeByEntries?: RuntimeByEntriesLegacyConfig;
27
+ bff?: LegacyBffUserConfig;
28
+ legacy?: boolean;
29
+ };
30
+ export interface AppToolsLegacyNormalizedConfig extends Required<AppToolsLegacyUserConfig> {
31
+ cliOptions?: Record<string, any>;
32
+ _raw: AppToolsLegacyUserConfig;
33
+ }
@@ -0,0 +1,51 @@
1
+ import { MetaOptions } from '@modern-js/utils';
2
+ import { SSGConfig } from '../config';
3
+ declare type CrossOrigin = 'anonymous' | 'use-credentials';
4
+ export declare type OutputLegacyUserConfig = {
5
+ assetPrefix?: string;
6
+ htmlPath?: string;
7
+ jsPath?: string;
8
+ cssPath?: string;
9
+ mediaPath?: string;
10
+ path?: string;
11
+ title?: string;
12
+ titleByEntries?: Record<string, string>;
13
+ meta?: MetaOptions;
14
+ metaByEntries?: Record<string, MetaOptions>;
15
+ inject?: 'body' | 'head' | boolean;
16
+ injectByEntries?: Record<string, 'body' | 'head' | boolean>;
17
+ mountId?: string;
18
+ favicon?: string;
19
+ faviconByEntries?: Record<string, string | undefined>;
20
+ copy?: Array<Record<string, unknown> & {
21
+ from: string;
22
+ }>;
23
+ disableTsChecker?: boolean;
24
+ disableHtmlFolder?: boolean;
25
+ disableCssModuleExtension?: boolean;
26
+ disableCssExtract?: boolean;
27
+ enableCssModuleTSDeclaration?: boolean;
28
+ disableMinimize?: boolean;
29
+ enableInlineStyles?: boolean;
30
+ enableInlineScripts?: boolean;
31
+ disableSourceMap?: boolean;
32
+ disableInlineRuntimeChunk?: boolean;
33
+ disableAssetsCache?: boolean;
34
+ enableLatestDecorators?: boolean;
35
+ polyfill?: 'off' | 'usage' | 'entry' | 'ua';
36
+ dataUriLimit?: number;
37
+ templateParameters?: Record<string, unknown>;
38
+ templateParametersByEntries?: Record<string, Record<string, unknown>>;
39
+ crossorigin?: boolean | CrossOrigin;
40
+ cssModuleLocalIdentName?: string;
41
+ disableNodePolyfill?: boolean;
42
+ enableTsLoader?: boolean;
43
+ /**
44
+ * The configuration of `output.ssg` is provided by `ssg` plugin.
45
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
46
+ * @requires `ssg` plugin
47
+ */
48
+
49
+ ssg?: SSGConfig;
50
+ };
51
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { AliasOption } from '@modern-js/utils';
2
+ export declare type SourceLegacyUserConfig = {
3
+ alias?: AliasOption;
4
+ entries?: Record<string, string | {
5
+ entry: string;
6
+ disableMount?: boolean;
7
+ }>;
8
+ preEntry?: string | string[];
9
+ enableAsyncEntry?: boolean;
10
+ disableDefaultEntries?: boolean;
11
+ entriesDir?: string;
12
+ configDir?: string;
13
+ apiDir?: string;
14
+ envVars?: Array<string>;
15
+ globalVars?: Record<string, string>;
16
+ moduleScopes?: Array<string | RegExp> | (((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>))[] | ((scopes: Array<string | RegExp>) => Array<string | RegExp>) | ((scopes: Array<string | RegExp>) => void);
17
+ include?: Array<string | RegExp>;
18
+ /**
19
+ * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
20
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
21
+ * @requires `tailwindcss` plugin
22
+ */
23
+
24
+ designSystem?: Record<string, any>;
25
+ };
@@ -0,0 +1,17 @@
1
+ import type { DevServerOptions } from '@modern-js/types';
2
+ import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
3
+ import type { JestConfig } from '@modern-js/core';
4
+ declare type BuilderToolsConfig = Required<BuilderConfig>['tools'];
5
+ export declare type ToolsLegacyUserConfig = BuilderToolsConfig & {
6
+ esbuild?: Record<string, unknown>;
7
+ devServer?: DevServerOptions;
8
+ /**
9
+ * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
10
+ * Please use `yarn new` or `pnpm new` to enable the corresponding capability.
11
+ * @requires `tailwindcss` plugin
12
+ */
13
+
14
+ tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
15
+ jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
16
+ };
17
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const getCommand: () => string;
2
+ export declare const isDevCommand: () => boolean;
@@ -1,6 +1,6 @@
1
1
  import { bundle } from '@modern-js/node-bundle-require';
2
- import type { NormalizedConfig } from '@modern-js/core';
3
2
  import type { ServerConfig } from '@modern-js/server-core';
3
+ import type { AppNormalizedConfig } from '../types';
4
4
  export declare const defineServerConfig: (config: ServerConfig) => ServerConfig;
5
5
  export declare const buildServerConfig: ({
6
6
  appDirectory,
@@ -19,4 +19,4 @@ export declare const buildServerConfig: ({
19
19
  */
20
20
 
21
21
  export declare const safeReplacer: () => (key: string, value: unknown) => unknown;
22
- export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: NormalizedConfig) => Promise<void>;
22
+ export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: AppNormalizedConfig) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { IAppContext, ToRunners } from '@modern-js/core';
2
+ import { AppToolsHooks } from '../types/hooks';
3
+ export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
4
+ export declare const createFileWatcher: (appContext: IAppContext, configDir: string | undefined, hooksRunner: ToRunners<AppToolsHooks>) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
@@ -1,4 +1,12 @@
1
1
  import { Server, ModernDevServerOptions } from '@modern-js/server';
2
+ import type { InternalPlugins } from '@modern-js/types';
2
3
  export declare const getServer: () => Server | null;
4
+ export declare const setServer: (newServer: Server) => void;
3
5
  export declare const closeServer: () => Promise<void>;
4
- export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
6
+ export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
7
+ export declare const injectDataLoaderPlugin: (internalPlugins: InternalPlugins) => {
8
+ '@modern-js/plugin-data-loader': {
9
+ path: string;
10
+ forced: boolean;
11
+ };
12
+ };
@@ -0,0 +1,2 @@
1
+ import { AppTools, PluginAPI } from '../types';
2
+ export declare function getServerInternalPlugins(api: PluginAPI<AppTools>): Promise<Record<string, string>>;
@@ -1,2 +1,3 @@
1
- import type { IAppContext, NormalizedConfig, ToRunners, CliHooks } from '@modern-js/core';
2
- export declare const printInstructions: (hookRunners: ToRunners<CliHooks>, appContext: IAppContext, config: NormalizedConfig) => Promise<void>;
1
+ import type { IAppContext, CliHooksRunner } from '@modern-js/core';
2
+ import type { AppNormalizedConfig, AppTools } from '../types';
3
+ export declare const printInstructions: (hookRunners: CliHooksRunner<AppTools>, appContext: IAppContext, config: AppNormalizedConfig) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { ToRunners } from '@modern-js/core';
2
+ import { AppToolsHooks } from '../types/hooks';
3
+ export declare function restart(hooksRunner: ToRunners<AppToolsHooks>, filename: string): Promise<void>;
@@ -15,8 +15,7 @@ export declare type StartOptions = {
15
15
  apiOnly?: boolean;
16
16
  };
17
17
  export declare type InspectOptions = {
18
- env?: string;
19
- output?: string;
20
- console?: boolean;
18
+ env: string;
19
+ output: string;
21
20
  verbose?: boolean;
22
21
  };
package/lib/types.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  declare namespace NodeJS {
7
7
  interface ProcessEnv {
8
- readonly NODE_ENV: 'development' | 'production' | 'test';
8
+ NODE_ENV: 'development' | 'production' | 'test';
9
9
  readonly PUBLIC_URL: string;
10
10
  }
11
11
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.22.1",
14
+ "version": "2.0.0-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -38,6 +38,9 @@
38
38
  "default": "./dist/js/node/exports/server.js"
39
39
  }
40
40
  },
41
+ "engines": {
42
+ "node": ">=14.17.6"
43
+ },
41
44
  "typesVersions": {
42
45
  "*": {
43
46
  ".": [
@@ -52,68 +55,56 @@
52
55
  }
53
56
  },
54
57
  "bin": {
55
- "modern": "./bin/modern.js"
58
+ "modern": "./bin/modern.js",
59
+ "modern-app": "./bin/modern.js"
56
60
  },
57
61
  "dependencies": {
58
- "@babel/runtime": "^7.18.0",
59
62
  "@babel/parser": "^7.18.0",
63
+ "@babel/runtime": "^7.18.0",
60
64
  "@babel/traverse": "^7.18.0",
61
65
  "@babel/types": "^7.18.0",
62
- "@modern-js/core": "1.22.1",
63
- "@modern-js/new-action": "1.22.1",
64
- "@modern-js/upgrade": "1.22.1",
65
- "@modern-js/node-bundle-require": "1.22.1",
66
- "@modern-js/plugin": "1.22.1",
67
- "@modern-js/plugin-i18n": "1.22.1",
68
- "@modern-js/plugin-jarvis": "1.22.1",
69
- "@modern-js/prod-server": "1.22.1",
70
- "@modern-js/server": "1.22.1",
71
- "@modern-js/types": "1.22.1",
72
- "@modern-js/utils": "1.22.1",
73
- "@modern-js/webpack": "1.22.1"
66
+ "@modern-js/builder": "2.0.0-beta.6",
67
+ "@modern-js/builder-plugin-esbuild": "2.0.0-beta.6",
68
+ "@modern-js/builder-plugin-node-polyfill": "2.0.0-beta.6",
69
+ "@modern-js/builder-shared": "2.0.0-beta.6",
70
+ "@modern-js/builder-webpack-provider": "2.0.0-beta.6",
71
+ "@modern-js/core": "2.0.0-beta.6",
72
+ "@modern-js/new-action": "2.0.0-beta.6",
73
+ "@modern-js/node-bundle-require": "2.0.0-beta.6",
74
+ "@modern-js/plugin": "2.0.0-beta.6",
75
+ "@modern-js/plugin-data-loader": "2.0.0-beta.6",
76
+ "@modern-js/plugin-i18n": "2.0.0-beta.6",
77
+ "@modern-js/plugin-lint": "2.0.0-beta.6",
78
+ "@modern-js/prod-server": "2.0.0-beta.6",
79
+ "@modern-js/server": "2.0.0-beta.6",
80
+ "@modern-js/types": "2.0.0-beta.6",
81
+ "@modern-js/upgrade": "2.0.0-beta.6",
82
+ "@modern-js/utils": "2.0.0-beta.6",
83
+ "es-module-lexer": "^1.1.0",
84
+ "esbuild": "0.15.7"
74
85
  },
75
86
  "devDependencies": {
87
+ "@modern-js/builder-plugin-swc": "2.0.0-beta.6",
88
+ "@modern-js/server-core": "2.0.0-beta.6",
89
+ "@scripts/build": "2.0.0-beta.6",
90
+ "@scripts/jest-config": "2.0.0-beta.6",
76
91
  "@types/babel__traverse": "^7.14.2",
77
92
  "@types/jest": "^27",
78
93
  "@types/node": "^14",
79
94
  "jest": "^27",
80
95
  "typescript": "^4",
81
- "@modern-js/server-core": "1.22.1",
82
- "@scripts/build": "1.22.1",
83
- "@scripts/jest-config": "1.22.1"
96
+ "webpack": "^5.75.0"
84
97
  },
85
98
  "sideEffects": false,
86
99
  "publishConfig": {
87
100
  "registry": "https://registry.npmjs.org/",
88
101
  "access": "public"
89
102
  },
90
- "wireit": {
91
- "build": {
92
- "command": "modern build",
93
- "files": [
94
- "src/**/*",
95
- "tsconfig.json",
96
- "package.json"
97
- ],
98
- "output": [
99
- "dist/**/*"
100
- ]
101
- },
102
- "test": {
103
- "command": "jest --passWithNoTests",
104
- "files": [
105
- "src/**/*",
106
- "tsconfig.json",
107
- "package.json",
108
- "tests/**/*"
109
- ],
110
- "output": []
111
- }
112
- },
113
103
  "scripts": {
114
- "new": "modern new",
115
- "dev": "modern build --watch",
116
- "build": "wireit",
117
- "test": "wireit"
118
- }
104
+ "new": "modern-lib new",
105
+ "dev": "modern-lib build --watch",
106
+ "build": "modern-lib build",
107
+ "test": "jest --passWithNoTests"
108
+ },
109
+ "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
119
110
  }