@modern-js/app-tools 2.69.4 → 3.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 (578) hide show
  1. package/bin/modern.js +2 -8
  2. package/dist/cjs/builder/builder-rspack/index.js +35 -27
  3. package/dist/cjs/builder/generator/adapterCopy.js +75 -46
  4. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +83 -81
  5. package/dist/cjs/builder/generator/createCopyPattern.js +59 -58
  6. package/dist/cjs/builder/generator/getBuilderEnvironments.js +80 -82
  7. package/dist/cjs/builder/generator/index.js +70 -85
  8. package/dist/cjs/builder/index.js +44 -47
  9. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +106 -83
  10. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +79 -74
  11. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +131 -165
  12. package/dist/cjs/builder/shared/builderPlugins/builderHooks.js +47 -46
  13. package/dist/cjs/builder/shared/builderPlugins/index.js +76 -25
  14. package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +66 -49
  15. package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +51 -50
  16. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +178 -317
  17. package/dist/cjs/builder/shared/bundlerPlugins/index.js +69 -23
  18. package/dist/cjs/builder/shared/createCopyInfo.js +54 -43
  19. package/dist/cjs/builder/shared/index.js +69 -23
  20. package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +35 -23
  21. package/dist/cjs/builder/shared/types.js +17 -15
  22. package/dist/cjs/commands/build.js +107 -96
  23. package/dist/cjs/commands/deploy.js +40 -32
  24. package/dist/cjs/commands/dev.js +122 -141
  25. package/dist/cjs/commands/index.js +74 -121
  26. package/dist/cjs/commands/inspect.js +45 -39
  27. package/dist/cjs/commands/serve.js +87 -84
  28. package/dist/cjs/compat/hooks.js +97 -177
  29. package/dist/cjs/compat/index.js +57 -59
  30. package/dist/cjs/compat/utils.js +125 -116
  31. package/dist/cjs/config/default.js +118 -225
  32. package/dist/cjs/config/index.js +62 -23
  33. package/dist/cjs/config/initialize/index.js +37 -29
  34. package/dist/cjs/config/initialize/inits.js +92 -106
  35. package/dist/cjs/constants.js +37 -37
  36. package/dist/cjs/defineConfig.js +33 -35
  37. package/dist/cjs/esm/esbuild-loader.js +62 -0
  38. package/dist/cjs/esm/esbuild-loader.mjs +11 -23
  39. package/dist/cjs/esm/register-esm.js +85 -0
  40. package/dist/cjs/esm/register-esm.mjs +41 -54
  41. package/dist/cjs/esm/ts-node-loader.js +62 -0
  42. package/dist/cjs/esm/ts-node-loader.mjs +11 -23
  43. package/dist/cjs/esm/utils.js +69 -0
  44. package/dist/cjs/esm/utils.mjs +24 -36
  45. package/dist/cjs/exports/server.js +16 -26
  46. package/dist/cjs/index.js +288 -199
  47. package/dist/cjs/locale/en.js +70 -62
  48. package/dist/cjs/locale/index.js +42 -33
  49. package/dist/cjs/locale/zh.js +70 -62
  50. package/dist/cjs/plugins/analyze/constants.js +43 -36
  51. package/dist/cjs/plugins/analyze/getBundleEntry.js +90 -94
  52. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +110 -137
  53. package/dist/cjs/plugins/analyze/getHtmlTemplate.js +125 -127
  54. package/dist/cjs/plugins/analyze/getServerRoutes.js +160 -164
  55. package/dist/cjs/plugins/analyze/index.js +221 -208
  56. package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +81 -76
  57. package/dist/cjs/plugins/analyze/templates.js +36 -28
  58. package/dist/cjs/plugins/analyze/utils.js +109 -104
  59. package/dist/cjs/plugins/deploy/index.js +64 -56
  60. package/dist/cjs/plugins/deploy/platforms/gh-pages.js +82 -86
  61. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +35 -2
  62. package/dist/cjs/plugins/deploy/platforms/netlify-handler.js +86 -62
  63. package/dist/cjs/plugins/deploy/platforms/netlify.js +145 -157
  64. package/dist/cjs/plugins/deploy/platforms/node-entry.js +73 -45
  65. package/dist/cjs/plugins/deploy/platforms/node.js +113 -113
  66. package/dist/cjs/plugins/deploy/platforms/platform.js +17 -15
  67. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +36 -2
  68. package/dist/cjs/plugins/deploy/platforms/vercel-handler.js +87 -63
  69. package/dist/cjs/plugins/deploy/platforms/vercel.js +165 -169
  70. package/dist/cjs/plugins/deploy/utils.js +85 -85
  71. package/dist/cjs/plugins/initialize/index.js +86 -91
  72. package/dist/cjs/plugins/serverBuild.js +85 -78
  73. package/dist/cjs/plugins/serverRuntime.js +46 -34
  74. package/dist/cjs/run/index.js +86 -128
  75. package/dist/cjs/types/config/deploy.js +17 -15
  76. package/dist/cjs/types/config/dev.js +17 -15
  77. package/dist/cjs/types/config/experiments.js +17 -15
  78. package/dist/cjs/types/config/html.js +17 -15
  79. package/dist/cjs/types/config/index.js +55 -19
  80. package/dist/cjs/types/config/output.js +17 -15
  81. package/dist/cjs/types/config/performance.js +17 -15
  82. package/dist/cjs/types/config/resolve.js +17 -15
  83. package/dist/cjs/types/config/security.js +17 -15
  84. package/dist/cjs/types/config/source.js +17 -15
  85. package/dist/cjs/types/config/testing.js +17 -15
  86. package/dist/cjs/types/config/tools.js +17 -15
  87. package/dist/cjs/types/index.js +55 -23
  88. package/dist/cjs/types/plugin.js +18 -0
  89. package/dist/cjs/types/utils.js +17 -15
  90. package/dist/cjs/utils/config.js +40 -80
  91. package/dist/cjs/utils/createServer.js +46 -47
  92. package/dist/cjs/utils/env.js +41 -35
  93. package/dist/cjs/utils/generateWatchFiles.js +49 -60
  94. package/dist/cjs/utils/getConfigFile.js +46 -38
  95. package/dist/cjs/utils/getSelectedEntries.js +55 -53
  96. package/dist/cjs/utils/initAppContext.js +66 -59
  97. package/dist/cjs/utils/loadPlugins.js +77 -70
  98. package/dist/cjs/utils/printInstructions.js +39 -31
  99. package/dist/cjs/utils/register.js +108 -117
  100. package/dist/cjs/utils/restart.js +46 -41
  101. package/dist/cjs/utils/routes.js +60 -52
  102. package/dist/cjs/utils/types.js +17 -15
  103. package/dist/esm/builder/builder-rspack/index.mjs +6 -0
  104. package/dist/esm/builder/generator/adapterCopy.mjs +35 -0
  105. package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +59 -0
  106. package/dist/esm/builder/generator/createCopyPattern.mjs +30 -0
  107. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +56 -0
  108. package/dist/esm/builder/generator/index.mjs +45 -0
  109. package/dist/esm/builder/index.mjs +7 -0
  110. package/dist/esm/builder/shared/builderPlugins/adapterBasic.mjs +78 -0
  111. package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +55 -0
  112. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +117 -0
  113. package/dist/esm/builder/shared/builderPlugins/builderHooks.mjs +17 -0
  114. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +37 -0
  115. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.mjs +22 -0
  116. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +157 -0
  117. package/dist/esm/builder/shared/createCopyInfo.mjs +15 -0
  118. package/dist/esm/builder/shared/loaders/serverModuleLoader.mjs +5 -0
  119. package/dist/esm/commands/build.mjs +68 -0
  120. package/dist/esm/commands/deploy.mjs +10 -0
  121. package/dist/esm/commands/dev.mjs +82 -0
  122. package/dist/esm/commands/index.mjs +37 -0
  123. package/dist/esm/commands/inspect.mjs +15 -0
  124. package/dist/esm/commands/serve.mjs +47 -0
  125. package/dist/esm/compat/hooks.mjs +67 -0
  126. package/dist/esm/compat/index.mjs +28 -0
  127. package/dist/esm/compat/utils.mjs +95 -0
  128. package/dist/esm/config/default.mjs +90 -0
  129. package/dist/{esm-node/config/index.js → esm/config/index.mjs} +0 -1
  130. package/dist/esm/config/initialize/index.mjs +7 -0
  131. package/dist/esm/config/initialize/inits.mjs +54 -0
  132. package/dist/esm/constants.mjs +3 -0
  133. package/dist/esm/defineConfig.mjs +2 -0
  134. package/dist/esm/esm/esbuild-loader.mjs +18 -29
  135. package/dist/esm/esm/register-esm.mjs +45 -57
  136. package/dist/esm/esm/ts-node-loader.mjs +18 -30
  137. package/dist/esm/esm/utils.mjs +31 -42
  138. package/dist/esm/index.mjs +121 -0
  139. package/dist/esm/locale/en.mjs +42 -0
  140. package/dist/esm/locale/index.mjs +9 -0
  141. package/dist/esm/locale/zh.mjs +42 -0
  142. package/dist/esm/plugins/analyze/constants.mjs +8 -0
  143. package/dist/esm/plugins/analyze/getBundleEntry.mjs +53 -0
  144. package/dist/esm/plugins/analyze/getFileSystemEntry.mjs +66 -0
  145. package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +85 -0
  146. package/dist/esm/plugins/analyze/getServerRoutes.mjs +130 -0
  147. package/dist/esm/plugins/analyze/index.mjs +193 -0
  148. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +41 -0
  149. package/dist/esm/plugins/analyze/templates.mjs +22 -0
  150. package/dist/esm/plugins/analyze/utils.mjs +55 -0
  151. package/dist/esm/plugins/deploy/index.mjs +38 -0
  152. package/dist/esm/plugins/deploy/platforms/gh-pages.mjs +43 -0
  153. package/dist/esm/plugins/deploy/platforms/netlify-entry.mjs +2 -1
  154. package/dist/esm/plugins/deploy/platforms/netlify-handler.mjs +85 -0
  155. package/dist/esm/plugins/deploy/platforms/netlify.mjs +111 -0
  156. package/dist/esm/plugins/deploy/platforms/node-entry.mjs +68 -0
  157. package/dist/esm/plugins/deploy/platforms/node.mjs +77 -0
  158. package/dist/esm/plugins/deploy/platforms/vercel-entry.mjs +3 -3
  159. package/dist/esm/plugins/deploy/platforms/vercel-handler.mjs +85 -0
  160. package/dist/esm/plugins/deploy/platforms/vercel.mjs +131 -0
  161. package/dist/esm/plugins/deploy/utils.mjs +39 -0
  162. package/dist/esm/plugins/initialize/index.mjs +59 -0
  163. package/dist/esm/plugins/serverBuild.mjs +48 -0
  164. package/dist/esm/plugins/serverRuntime.mjs +15 -0
  165. package/dist/esm/run/index.mjs +60 -0
  166. package/dist/esm/types/index.mjs +1 -0
  167. package/dist/esm/utils/config.mjs +11 -0
  168. package/dist/esm/utils/createServer.mjs +12 -0
  169. package/dist/esm/utils/env.mjs +12 -0
  170. package/dist/esm/utils/generateWatchFiles.mjs +10 -0
  171. package/dist/esm/utils/getConfigFile.mjs +5 -0
  172. package/dist/esm/utils/getSelectedEntries.mjs +26 -0
  173. package/dist/esm/utils/initAppContext.mjs +26 -0
  174. package/dist/esm/utils/loadPlugins.mjs +45 -0
  175. package/dist/esm/utils/printInstructions.mjs +9 -0
  176. package/dist/esm/utils/register.mjs +75 -0
  177. package/dist/esm/utils/restart.mjs +18 -0
  178. package/dist/esm/utils/routes.mjs +15 -0
  179. package/dist/esm-node/builder/builder-rspack/index.mjs +6 -0
  180. package/dist/esm-node/builder/generator/adapterCopy.mjs +35 -0
  181. package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +59 -0
  182. package/dist/esm-node/builder/generator/createCopyPattern.mjs +30 -0
  183. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +56 -0
  184. package/dist/esm-node/builder/generator/index.mjs +45 -0
  185. package/dist/esm-node/builder/index.mjs +7 -0
  186. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +78 -0
  187. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +55 -0
  188. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +117 -0
  189. package/dist/esm-node/builder/shared/builderPlugins/builderHooks.mjs +17 -0
  190. package/dist/esm-node/builder/shared/builderPlugins/index.mjs +4 -0
  191. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +37 -0
  192. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.mjs +22 -0
  193. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +157 -0
  194. package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +3 -0
  195. package/dist/esm-node/builder/shared/createCopyInfo.mjs +15 -0
  196. package/dist/esm-node/builder/shared/index.mjs +3 -0
  197. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.mjs +5 -0
  198. package/dist/esm-node/commands/build.mjs +68 -0
  199. package/dist/esm-node/commands/deploy.mjs +10 -0
  200. package/dist/esm-node/commands/dev.mjs +82 -0
  201. package/dist/esm-node/commands/index.mjs +37 -0
  202. package/dist/esm-node/commands/inspect.mjs +15 -0
  203. package/dist/esm-node/commands/serve.mjs +47 -0
  204. package/dist/esm-node/compat/hooks.mjs +67 -0
  205. package/dist/esm-node/compat/index.mjs +28 -0
  206. package/dist/esm-node/compat/utils.mjs +95 -0
  207. package/dist/esm-node/config/default.mjs +90 -0
  208. package/dist/esm-node/config/index.mjs +2 -0
  209. package/dist/esm-node/config/initialize/index.mjs +7 -0
  210. package/dist/esm-node/config/initialize/inits.mjs +54 -0
  211. package/dist/esm-node/constants.mjs +3 -0
  212. package/dist/esm-node/defineConfig.mjs +2 -0
  213. package/dist/esm-node/esm/esbuild-loader.mjs +18 -29
  214. package/dist/esm-node/esm/register-esm.mjs +45 -57
  215. package/dist/esm-node/esm/ts-node-loader.mjs +18 -30
  216. package/dist/esm-node/esm/utils.mjs +31 -42
  217. package/dist/esm-node/index.mjs +121 -0
  218. package/dist/esm-node/locale/en.mjs +42 -0
  219. package/dist/esm-node/locale/index.mjs +9 -0
  220. package/dist/esm-node/locale/zh.mjs +42 -0
  221. package/dist/esm-node/plugins/analyze/constants.mjs +8 -0
  222. package/dist/esm-node/plugins/analyze/getBundleEntry.mjs +53 -0
  223. package/dist/esm-node/plugins/analyze/getFileSystemEntry.mjs +66 -0
  224. package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +85 -0
  225. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +130 -0
  226. package/dist/esm-node/plugins/analyze/index.mjs +193 -0
  227. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +41 -0
  228. package/dist/esm-node/plugins/analyze/{templates.js → templates.mjs} +5 -7
  229. package/dist/esm-node/plugins/analyze/utils.mjs +55 -0
  230. package/dist/esm-node/plugins/deploy/index.mjs +38 -0
  231. package/dist/esm-node/plugins/deploy/platforms/gh-pages.mjs +43 -0
  232. package/dist/esm-node/plugins/deploy/platforms/netlify-entry.mjs +2 -1
  233. package/dist/esm-node/plugins/deploy/platforms/netlify-handler.mjs +85 -0
  234. package/dist/esm-node/plugins/deploy/platforms/netlify.mjs +111 -0
  235. package/dist/esm-node/plugins/deploy/platforms/node-entry.mjs +68 -0
  236. package/dist/esm-node/plugins/deploy/platforms/node.mjs +77 -0
  237. package/dist/esm-node/plugins/deploy/platforms/vercel-entry.mjs +3 -3
  238. package/dist/esm-node/plugins/deploy/platforms/vercel-handler.mjs +85 -0
  239. package/dist/esm-node/plugins/deploy/platforms/vercel.mjs +131 -0
  240. package/dist/esm-node/plugins/deploy/utils.mjs +39 -0
  241. package/dist/esm-node/plugins/initialize/index.mjs +59 -0
  242. package/dist/esm-node/plugins/serverBuild.mjs +48 -0
  243. package/dist/esm-node/plugins/serverRuntime.mjs +15 -0
  244. package/dist/esm-node/run/index.mjs +60 -0
  245. package/dist/esm-node/types/config/index.mjs +1 -0
  246. package/dist/esm-node/types/index.mjs +1 -0
  247. package/dist/esm-node/utils/config.mjs +11 -0
  248. package/dist/esm-node/utils/createServer.mjs +12 -0
  249. package/dist/esm-node/utils/env.mjs +12 -0
  250. package/dist/esm-node/utils/generateWatchFiles.mjs +10 -0
  251. package/dist/esm-node/utils/getConfigFile.mjs +5 -0
  252. package/dist/esm-node/utils/getSelectedEntries.mjs +26 -0
  253. package/dist/esm-node/utils/initAppContext.mjs +26 -0
  254. package/dist/esm-node/utils/loadPlugins.mjs +45 -0
  255. package/dist/esm-node/utils/printInstructions.mjs +9 -0
  256. package/dist/esm-node/utils/register.mjs +75 -0
  257. package/dist/esm-node/utils/restart.mjs +18 -0
  258. package/dist/esm-node/utils/routes.mjs +15 -0
  259. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  260. package/dist/types/builder/generator/adapterCopy.d.ts +2 -3
  261. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -3
  262. package/dist/types/builder/generator/createCopyPattern.d.ts +5 -5
  263. package/dist/types/builder/generator/getBuilderEnvironments.d.ts +4 -4
  264. package/dist/types/builder/generator/index.d.ts +2 -3
  265. package/dist/types/builder/index.d.ts +2 -2
  266. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +1 -2
  267. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -2
  268. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -2
  269. package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +1 -2
  270. package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +4 -4
  271. package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +4 -4
  272. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +3 -5
  273. package/dist/types/builder/shared/createCopyInfo.d.ts +4 -3
  274. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +2 -2
  275. package/dist/types/builder/shared/types.d.ts +5 -5
  276. package/dist/types/commands/build.d.ts +2 -2
  277. package/dist/types/commands/deploy.d.ts +2 -2
  278. package/dist/types/commands/dev.d.ts +2 -2
  279. package/dist/types/commands/index.d.ts +7 -9
  280. package/dist/types/commands/inspect.d.ts +2 -2
  281. package/dist/types/commands/serve.d.ts +2 -2
  282. package/dist/types/compat/hooks.d.ts +2 -2
  283. package/dist/types/compat/index.d.ts +2 -2
  284. package/dist/types/config/default.d.ts +3 -4
  285. package/dist/types/config/index.d.ts +0 -1
  286. package/dist/types/config/initialize/index.d.ts +2 -2
  287. package/dist/types/config/initialize/inits.d.ts +3 -4
  288. package/dist/types/constants.d.ts +0 -3
  289. package/dist/types/defineConfig.d.ts +7 -8
  290. package/dist/types/exports/server.d.ts +1 -5
  291. package/dist/types/index.d.ts +4 -5
  292. package/dist/types/locale/index.d.ts +1 -1
  293. package/dist/types/plugins/analyze/constants.d.ts +0 -1
  294. package/dist/types/plugins/analyze/getBundleEntry.d.ts +2 -2
  295. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +2 -2
  296. package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +4 -4
  297. package/dist/types/plugins/analyze/getServerRoutes.d.ts +3 -3
  298. package/dist/types/plugins/analyze/index.d.ts +2 -4
  299. package/dist/types/plugins/deploy/index.d.ts +2 -2
  300. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  301. package/dist/types/plugins/deploy/utils.d.ts +2 -2
  302. package/dist/types/plugins/initialize/index.d.ts +2 -4
  303. package/dist/types/plugins/serverBuild.d.ts +2 -2
  304. package/dist/types/plugins/serverRuntime.d.ts +2 -2
  305. package/dist/types/run/index.d.ts +3 -8
  306. package/dist/types/types/config/deploy.d.ts +0 -1
  307. package/dist/types/types/config/dev.d.ts +50 -9
  308. package/dist/types/types/config/experiments.d.ts +2 -2
  309. package/dist/types/types/config/html.d.ts +2 -2
  310. package/dist/types/types/config/index.d.ts +10 -14
  311. package/dist/types/types/config/output.d.ts +8 -8
  312. package/dist/types/types/config/performance.d.ts +2 -2
  313. package/dist/types/types/config/resolve.d.ts +2 -2
  314. package/dist/types/types/config/security.d.ts +2 -2
  315. package/dist/types/types/config/source.d.ts +2 -23
  316. package/dist/types/types/config/tools.d.ts +5 -22
  317. package/dist/types/types/index.d.ts +7 -34
  318. package/dist/types/types/{new.d.ts → plugin.d.ts} +10 -39
  319. package/dist/types/types/utils.d.ts +0 -6
  320. package/dist/types/utils/config.d.ts +1 -11
  321. package/dist/types/utils/createServer.d.ts +1 -3
  322. package/dist/types/utils/env.d.ts +2 -2
  323. package/dist/types/utils/generateWatchFiles.d.ts +2 -3
  324. package/dist/types/utils/initAppContext.d.ts +1 -3
  325. package/dist/types/utils/loadPlugins.d.ts +5 -5
  326. package/dist/types/utils/printInstructions.d.ts +2 -2
  327. package/dist/types/utils/restart.d.ts +2 -2
  328. package/dist/types/utils/routes.d.ts +2 -3
  329. package/lib/types.d.ts +5 -16
  330. package/package.json +51 -38
  331. package/rslib.config.mts +20 -0
  332. package/dist/cjs/builder/builder-webpack/index.js +0 -50
  333. package/dist/cjs/config/legacy/createHtmlConfig.js +0 -45
  334. package/dist/cjs/config/legacy/createOutputConfig.js +0 -69
  335. package/dist/cjs/config/legacy/createSourceConfig.js +0 -53
  336. package/dist/cjs/config/legacy/createToolsConfig.js +0 -52
  337. package/dist/cjs/config/legacy/index.js +0 -68
  338. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +0 -1
  339. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +0 -3
  340. package/dist/cjs/types/hooks.js +0 -16
  341. package/dist/cjs/types/legacyConfig/deploy.js +0 -16
  342. package/dist/cjs/types/legacyConfig/dev.js +0 -16
  343. package/dist/cjs/types/legacyConfig/index.js +0 -16
  344. package/dist/cjs/types/legacyConfig/output.js +0 -16
  345. package/dist/cjs/types/legacyConfig/source.js +0 -16
  346. package/dist/cjs/types/legacyConfig/testing.js +0 -16
  347. package/dist/cjs/types/legacyConfig/tools.js +0 -16
  348. package/dist/cjs/types/new.js +0 -16
  349. package/dist/cjs/utils/getUserConfig.js +0 -34
  350. package/dist/esm/builder/builder-rspack/index.js +0 -30
  351. package/dist/esm/builder/builder-webpack/index.js +0 -48
  352. package/dist/esm/builder/generator/adapterCopy.js +0 -29
  353. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -56
  354. package/dist/esm/builder/generator/createCopyPattern.js +0 -43
  355. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -89
  356. package/dist/esm/builder/generator/index.js +0 -116
  357. package/dist/esm/builder/index.js +0 -50
  358. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -92
  359. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  360. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -262
  361. package/dist/esm/builder/shared/builderPlugins/builderHooks.js +0 -120
  362. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  363. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  364. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  365. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -420
  366. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  367. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  368. package/dist/esm/builder/shared/index.js +0 -3
  369. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  370. package/dist/esm/commands/build.js +0 -142
  371. package/dist/esm/commands/deploy.js +0 -48
  372. package/dist/esm/commands/dev.js +0 -197
  373. package/dist/esm/commands/index.js +0 -401
  374. package/dist/esm/commands/inspect.js +0 -31
  375. package/dist/esm/commands/serve.js +0 -96
  376. package/dist/esm/compat/hooks.js +0 -503
  377. package/dist/esm/compat/index.js +0 -45
  378. package/dist/esm/compat/utils.js +0 -100
  379. package/dist/esm/config/default.js +0 -205
  380. package/dist/esm/config/index.js +0 -3
  381. package/dist/esm/config/initialize/index.js +0 -9
  382. package/dist/esm/config/initialize/inits.js +0 -89
  383. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  384. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  385. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  386. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  387. package/dist/esm/config/legacy/index.js +0 -43
  388. package/dist/esm/constants.js +0 -12
  389. package/dist/esm/defineConfig.js +0 -16
  390. package/dist/esm/exports/server.js +0 -4
  391. package/dist/esm/index.js +0 -265
  392. package/dist/esm/locale/en.js +0 -44
  393. package/dist/esm/locale/index.js +0 -12
  394. package/dist/esm/locale/zh.js +0 -44
  395. package/dist/esm/plugins/analyze/constants.js +0 -14
  396. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -108
  397. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -268
  398. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -251
  399. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -148
  400. package/dist/esm/plugins/analyze/index.js +0 -439
  401. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  402. package/dist/esm/plugins/analyze/templates.js +0 -6
  403. package/dist/esm/plugins/analyze/utils.js +0 -106
  404. package/dist/esm/plugins/deploy/index.js +0 -133
  405. package/dist/esm/plugins/deploy/platforms/gh-pages.js +0 -184
  406. package/dist/esm/plugins/deploy/platforms/netlify-entry.js +0 -11
  407. package/dist/esm/plugins/deploy/platforms/netlify-handler.js +0 -207
  408. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -346
  409. package/dist/esm/plugins/deploy/platforms/node-entry.js +0 -110
  410. package/dist/esm/plugins/deploy/platforms/node.js +0 -178
  411. package/dist/esm/plugins/deploy/platforms/vercel-entry.js +0 -11
  412. package/dist/esm/plugins/deploy/platforms/vercel-handler.js +0 -207
  413. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -280
  414. package/dist/esm/plugins/deploy/utils.js +0 -59
  415. package/dist/esm/plugins/initialize/index.js +0 -116
  416. package/dist/esm/plugins/serverBuild.js +0 -83
  417. package/dist/esm/plugins/serverRuntime.js +0 -22
  418. package/dist/esm/run/index.js +0 -134
  419. package/dist/esm/types/config/index.js +0 -1
  420. package/dist/esm/types/config/source.js +0 -0
  421. package/dist/esm/types/config/testing.js +0 -0
  422. package/dist/esm/types/config/tools.js +0 -0
  423. package/dist/esm/types/hooks.js +0 -0
  424. package/dist/esm/types/index.js +0 -3
  425. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  426. package/dist/esm/types/legacyConfig/dev.js +0 -0
  427. package/dist/esm/types/legacyConfig/index.js +0 -0
  428. package/dist/esm/types/legacyConfig/output.js +0 -0
  429. package/dist/esm/types/legacyConfig/source.js +0 -0
  430. package/dist/esm/types/legacyConfig/testing.js +0 -0
  431. package/dist/esm/types/legacyConfig/tools.js +0 -0
  432. package/dist/esm/types/new.js +0 -0
  433. package/dist/esm/types/utils.js +0 -0
  434. package/dist/esm/utils/config.js +0 -122
  435. package/dist/esm/utils/createServer.js +0 -58
  436. package/dist/esm/utils/env.js +0 -16
  437. package/dist/esm/utils/generateWatchFiles.js +0 -71
  438. package/dist/esm/utils/getConfigFile.js +0 -11
  439. package/dist/esm/utils/getSelectedEntries.js +0 -67
  440. package/dist/esm/utils/getUserConfig.js +0 -32
  441. package/dist/esm/utils/initAppContext.js +0 -30
  442. package/dist/esm/utils/loadPlugins.js +0 -162
  443. package/dist/esm/utils/printInstructions.js +0 -32
  444. package/dist/esm/utils/register.js +0 -182
  445. package/dist/esm/utils/restart.js +0 -68
  446. package/dist/esm/utils/routes.js +0 -42
  447. package/dist/esm/utils/types.js +0 -0
  448. package/dist/esm-node/builder/builder-rspack/index.js +0 -8
  449. package/dist/esm-node/builder/builder-webpack/index.js +0 -16
  450. package/dist/esm-node/builder/generator/adapterCopy.js +0 -26
  451. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -67
  452. package/dist/esm-node/builder/generator/createCopyPattern.js +0 -41
  453. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -68
  454. package/dist/esm-node/builder/generator/index.js +0 -60
  455. package/dist/esm-node/builder/index.js +0 -16
  456. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -55
  457. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  458. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -151
  459. package/dist/esm-node/builder/shared/builderPlugins/builderHooks.js +0 -26
  460. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  461. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  462. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -305
  463. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  464. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  465. package/dist/esm-node/commands/build.js +0 -67
  466. package/dist/esm-node/commands/deploy.js +0 -12
  467. package/dist/esm-node/commands/dev.js +0 -111
  468. package/dist/esm-node/commands/index.js +0 -90
  469. package/dist/esm-node/commands/inspect.js +0 -19
  470. package/dist/esm-node/commands/serve.js +0 -54
  471. package/dist/esm-node/compat/hooks.js +0 -159
  472. package/dist/esm-node/compat/index.js +0 -40
  473. package/dist/esm-node/compat/utils.js +0 -100
  474. package/dist/esm-node/config/default.js +0 -206
  475. package/dist/esm-node/config/initialize/index.js +0 -9
  476. package/dist/esm-node/config/initialize/inits.js +0 -79
  477. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  478. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  479. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  480. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  481. package/dist/esm-node/config/legacy/index.js +0 -43
  482. package/dist/esm-node/constants.js +0 -12
  483. package/dist/esm-node/defineConfig.js +0 -13
  484. package/dist/esm-node/exports/server.js +0 -4
  485. package/dist/esm-node/index.js +0 -160
  486. package/dist/esm-node/locale/en.js +0 -44
  487. package/dist/esm-node/locale/index.js +0 -12
  488. package/dist/esm-node/locale/zh.js +0 -44
  489. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  490. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -67
  491. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -108
  492. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -99
  493. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -146
  494. package/dist/esm-node/plugins/analyze/index.js +0 -184
  495. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  496. package/dist/esm-node/plugins/analyze/utils.js +0 -73
  497. package/dist/esm-node/plugins/deploy/index.js +0 -44
  498. package/dist/esm-node/plugins/deploy/platforms/gh-pages.js +0 -57
  499. package/dist/esm-node/plugins/deploy/platforms/netlify-entry.js +0 -11
  500. package/dist/esm-node/plugins/deploy/platforms/netlify-handler.js +0 -73
  501. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -133
  502. package/dist/esm-node/plugins/deploy/platforms/node-entry.js +0 -46
  503. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -87
  504. package/dist/esm-node/plugins/deploy/platforms/vercel-entry.js +0 -11
  505. package/dist/esm-node/plugins/deploy/platforms/vercel-handler.js +0 -73
  506. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -145
  507. package/dist/esm-node/plugins/deploy/utils.js +0 -55
  508. package/dist/esm-node/plugins/initialize/index.js +0 -78
  509. package/dist/esm-node/plugins/serverBuild.js +0 -56
  510. package/dist/esm-node/plugins/serverRuntime.js +0 -17
  511. package/dist/esm-node/run/index.js +0 -104
  512. package/dist/esm-node/types/index.js +0 -3
  513. package/dist/esm-node/utils/config.js +0 -49
  514. package/dist/esm-node/utils/createServer.js +0 -26
  515. package/dist/esm-node/utils/env.js +0 -16
  516. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  517. package/dist/esm-node/utils/getConfigFile.js +0 -7
  518. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  519. package/dist/esm-node/utils/getUserConfig.js +0 -10
  520. package/dist/esm-node/utils/initAppContext.js +0 -29
  521. package/dist/esm-node/utils/loadPlugins.js +0 -52
  522. package/dist/esm-node/utils/printInstructions.js +0 -11
  523. package/dist/esm-node/utils/register.js +0 -94
  524. package/dist/esm-node/utils/restart.js +0 -23
  525. package/dist/esm-node/utils/routes.js +0 -21
  526. package/dist/types/builder/builder-webpack/index.d.ts +0 -2
  527. package/dist/types/config/legacy/createHtmlConfig.d.ts +0 -2
  528. package/dist/types/config/legacy/createOutputConfig.d.ts +0 -2
  529. package/dist/types/config/legacy/createSourceConfig.d.ts +0 -2
  530. package/dist/types/config/legacy/createToolsConfig.d.ts +0 -2
  531. package/dist/types/config/legacy/index.d.ts +0 -3
  532. package/dist/types/types/hooks.d.ts +0 -69
  533. package/dist/types/types/legacyConfig/deploy.d.ts +0 -8
  534. package/dist/types/types/legacyConfig/dev.d.ts +0 -12
  535. package/dist/types/types/legacyConfig/index.d.ts +0 -35
  536. package/dist/types/types/legacyConfig/output.d.ts +0 -50
  537. package/dist/types/types/legacyConfig/source.d.ts +0 -28
  538. package/dist/types/types/legacyConfig/testing.d.ts +0 -8
  539. package/dist/types/types/legacyConfig/tools.d.ts +0 -15
  540. package/dist/types/utils/getUserConfig.d.ts +0 -6
  541. /package/dist/{esm-node/builder/shared/builderPlugins/index.js → esm/builder/shared/builderPlugins/index.mjs} +0 -0
  542. /package/dist/{esm-node/builder/shared/bundlerPlugins/index.js → esm/builder/shared/bundlerPlugins/index.mjs} +0 -0
  543. /package/dist/{esm-node/builder/shared/index.js → esm/builder/shared/index.mjs} +0 -0
  544. /package/dist/{esm-node/types/legacyConfig/output.js → esm/builder/shared/types.mjs} +0 -0
  545. /package/dist/{esm-node/types/legacyConfig/source.js → esm/exports/server.mjs} +0 -0
  546. /package/dist/{esm-node/types/legacyConfig/testing.js → esm/plugins/deploy/platforms/platform.mjs} +0 -0
  547. /package/dist/{esm-node/types/legacyConfig/tools.js → esm/types/config/deploy.mjs} +0 -0
  548. /package/dist/{esm-node/types/new.js → esm/types/config/dev.mjs} +0 -0
  549. /package/dist/{esm-node/types/utils.js → esm/types/config/experiments.mjs} +0 -0
  550. /package/dist/{esm-node/utils/types.js → esm/types/config/html.mjs} +0 -0
  551. /package/dist/{esm-node/types/config/index.js → esm/types/config/index.mjs} +0 -0
  552. /package/dist/esm/{builder/shared/types.js → types/config/output.mjs} +0 -0
  553. /package/dist/esm/{plugins/deploy/platforms/platform.js → types/config/performance.mjs} +0 -0
  554. /package/dist/esm/types/config/{deploy.js → resolve.mjs} +0 -0
  555. /package/dist/esm/types/config/{dev.js → security.mjs} +0 -0
  556. /package/dist/esm/types/config/{experiments.js → source.mjs} +0 -0
  557. /package/dist/esm/types/config/{html.js → testing.mjs} +0 -0
  558. /package/dist/esm/types/config/{output.js → tools.mjs} +0 -0
  559. /package/dist/esm/types/{config/performance.js → plugin.mjs} +0 -0
  560. /package/dist/esm/types/{config/resolve.js → utils.mjs} +0 -0
  561. /package/dist/esm/{types/config/security.js → utils/types.mjs} +0 -0
  562. /package/dist/esm-node/builder/shared/{types.js → types.mjs} +0 -0
  563. /package/dist/esm-node/{plugins/deploy/platforms/platform.js → exports/server.mjs} +0 -0
  564. /package/dist/esm-node/{types/config/deploy.js → plugins/deploy/platforms/platform.mjs} +0 -0
  565. /package/dist/esm-node/types/config/{dev.js → deploy.mjs} +0 -0
  566. /package/dist/esm-node/types/config/{experiments.js → dev.mjs} +0 -0
  567. /package/dist/esm-node/types/config/{html.js → experiments.mjs} +0 -0
  568. /package/dist/esm-node/types/config/{output.js → html.mjs} +0 -0
  569. /package/dist/esm-node/types/config/{performance.js → output.mjs} +0 -0
  570. /package/dist/esm-node/types/config/{resolve.js → performance.mjs} +0 -0
  571. /package/dist/esm-node/types/config/{security.js → resolve.mjs} +0 -0
  572. /package/dist/esm-node/types/config/{source.js → security.mjs} +0 -0
  573. /package/dist/esm-node/types/config/{testing.js → source.mjs} +0 -0
  574. /package/dist/esm-node/types/config/{tools.js → testing.mjs} +0 -0
  575. /package/dist/esm-node/types/{hooks.js → config/tools.mjs} +0 -0
  576. /package/dist/esm-node/types/{legacyConfig/deploy.js → plugin.mjs} +0 -0
  577. /package/dist/esm-node/types/{legacyConfig/dev.js → utils.mjs} +0 -0
  578. /package/dist/esm-node/{types/legacyConfig/index.js → utils/types.mjs} +0 -0
@@ -1,420 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
3
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
- import { createHash } from "crypto";
7
- import { ROUTE_MANIFEST_FILE } from "@modern-js/utils";
8
- import { merge, mergeWith } from "@modern-js/utils/lodash";
9
- import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
10
- var PLUGIN_NAME = "ModernjsRouterPlugin";
11
- var ROUTE_DEPS_COMPILATION_KEY = Symbol.for("".concat(PLUGIN_NAME, "RouteSources"));
12
- var generateContentHash = function(content) {
13
- return createHash("md5").update(content).digest("hex").slice(0, 8);
14
- };
15
- var RouterPlugin = /* @__PURE__ */ function() {
16
- "use strict";
17
- function RouterPlugin2(param) {
18
- var _param_staticJsDir = param.staticJsDir, staticJsDir = _param_staticJsDir === void 0 ? "static/js" : _param_staticJsDir, HtmlBundlerPlugin = param.HtmlBundlerPlugin, enableInlineRouteManifests = param.enableInlineRouteManifests, _param_disableFilenameHash = param.disableFilenameHash, disableFilenameHash = _param_disableFilenameHash === void 0 ? false : _param_disableFilenameHash, _param_scriptLoading = param.scriptLoading, scriptLoading = _param_scriptLoading === void 0 ? "defer" : _param_scriptLoading, nonce = param.nonce;
19
- _class_call_check(this, RouterPlugin2);
20
- this.name = "RouterPlugin";
21
- this.HtmlBundlerPlugin = HtmlBundlerPlugin;
22
- this.enableInlineRouteManifests = enableInlineRouteManifests;
23
- this.staticJsDir = staticJsDir;
24
- this.disableFilenameHash = disableFilenameHash;
25
- this.scriptLoading = scriptLoading;
26
- this.nonce = nonce;
27
- }
28
- var _proto = RouterPlugin2.prototype;
29
- _proto.isTargetNodeOrWebWorker = function isTargetNodeOrWebWorker(target) {
30
- if (target === "node" || Array.isArray(target) && target.includes("node")) {
31
- return true;
32
- }
33
- if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
34
- return true;
35
- }
36
- return false;
37
- };
38
- _proto.getEntryChunks = function getEntryChunks(compilation, chunks) {
39
- var entrypointsArray = Array.from(compilation.entrypoints.entries());
40
- var entryChunkIds = entrypointsArray.map(function(entrypoint) {
41
- return entrypoint[0];
42
- });
43
- var entryChunks = _to_consumable_array(chunks).filter(function(chunk) {
44
- var _chunk_names;
45
- return (_chunk_names = chunk.names) === null || _chunk_names === void 0 ? void 0 : _chunk_names.some(function(name) {
46
- return entryChunkIds.includes(name);
47
- });
48
- });
49
- return entryChunks;
50
- };
51
- _proto.getEntryChunkFiles = function getEntryChunkFiles(entryChunks) {
52
- return entryChunks.map(function(chunk) {
53
- return _to_consumable_array(chunk.files || []).find(function(fname) {
54
- return fname.includes(".js");
55
- });
56
- });
57
- };
58
- _proto.apply = function apply(compiler) {
59
- var _this = this;
60
- var target = compiler.options.target;
61
- if (this.isTargetNodeOrWebWorker(target)) {
62
- return;
63
- }
64
- var webpack = compiler.webpack;
65
- var isRspack = "rspackVersion" in webpack;
66
- var Compilation = webpack.Compilation, sources = webpack.sources;
67
- var RawSource = sources.RawSource;
68
- var normalizePath = function(path) {
69
- if (!path.endsWith("/")) {
70
- return "".concat(path, "/");
71
- }
72
- return path;
73
- };
74
- var chunksToHtmlName = /* @__PURE__ */ new Map();
75
- var ROUTE_MANIFEST_HOLDER = "route-manifest";
76
- var placeholder = "<!--<?- ".concat(ROUTE_MANIFEST_HOLDER, " ?>-->");
77
- compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function(compilation) {
78
- _this.HtmlBundlerPlugin.getHooks(compilation).beforeEmit.tapAsync("RouterManifestPlugin", function(data, callback) {
79
- var outputName = data.outputName;
80
- var chunks = data.plugin.options.chunks;
81
- chunksToHtmlName.set(chunks, outputName);
82
- data.html = data.html.replace("</script>", "</script>".concat(placeholder));
83
- callback(null, data);
84
- });
85
- var _this1 = _this;
86
- compilation.hooks.processAssets.tapPromise({
87
- name: PLUGIN_NAME,
88
- stage: Compilation.PROCESS_ASSETS_STAGE_REPORT
89
- }, /* @__PURE__ */ _async_to_generator(function() {
90
- var _loop, stats, publicPath, _stats_chunks, chunks, namedChunkGroups, routeAssets, route2Sources, prevManifestAsset, prevManifestStr, prevManifest, asyncEntryNames, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step_value, name, chunkGroup, assets, referenceCssAssets, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, asyncEntryName, syncEntryName, syncEntry, asyncEntry, manifest, getChunkModules, addModuleResources, depsByName, namedGroups, groupNames, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _loop1, _iterator2, _step2, entryNames, entryChunks, orignalEntryIds, entryChunkFiles, entryChunkFileIds, i;
91
- return _ts_generator(this, function(_state) {
92
- _loop = function(i2) {
93
- var entryName = entryNames[i2];
94
- var file = entryChunkFiles[i2];
95
- var chunkNames = entryChunks[i2].names;
96
- var chunkId = entryChunkFileIds[i2];
97
- var asset = compilation.assets[file];
98
- if (!asset || !chunkId) {
99
- return "continue";
100
- }
101
- var relatedAssets = {};
102
- if (entryChunkFiles.length > 1) {
103
- Object.keys(routeAssets).forEach(function(routeId) {
104
- var segments = routeId.split("_");
105
- var chunkName = segments[0];
106
- if (chunkNames === null || chunkNames === void 0 ? void 0 : chunkNames.includes(chunkName)) {
107
- relatedAssets[routeId] = routeAssets[routeId];
108
- }
109
- });
110
- } else {
111
- relatedAssets = routeAssets;
112
- }
113
- var manifest2 = {
114
- routeAssets: relatedAssets
115
- };
116
- var injectedContent = "\n ;(function(){\n window.".concat(ROUTE_MANIFEST, " = ").concat(JSON.stringify(manifest2, function(k, v) {
117
- if ((k === "assets" || k === "referenceCssAssets") && Array.isArray(v)) {
118
- return v.map(function(item) {
119
- return item.replace(publicPath, "");
120
- });
121
- }
122
- return v;
123
- }), ";\n })();\n ");
124
- var htmlName = void 0;
125
- var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
126
- try {
127
- var _loop2 = function() {
128
- var _step_value2 = _sliced_to_array(_step3.value, 2), chunks2 = _step_value2[0], name2 = _step_value2[1];
129
- if (Array.isArray(chunkNames) && Array.isArray(chunks2) && chunkNames.every(function(value, index) {
130
- return value === chunks2[index];
131
- })) {
132
- htmlName = name2;
133
- return "break";
134
- }
135
- };
136
- for (var _iterator3 = chunksToHtmlName.entries()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
137
- var _ret = _loop2();
138
- if (_ret === "break")
139
- break;
140
- }
141
- } catch (err) {
142
- _didIteratorError3 = true;
143
- _iteratorError3 = err;
144
- } finally {
145
- try {
146
- if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
147
- _iterator3.return();
148
- }
149
- } finally {
150
- if (_didIteratorError3) {
151
- throw _iteratorError3;
152
- }
153
- }
154
- }
155
- var oldHtml = compilation.assets[htmlName];
156
- var enableInlineRouteManifests = _this1.enableInlineRouteManifests, disableFilenameHash = _this1.disableFilenameHash, staticJsDir = _this1.staticJsDir, scriptLoading = _this1.scriptLoading, nonce = _this1.nonce;
157
- var nonceAttr = nonce ? 'nonce="'.concat(nonce, '"') : "";
158
- if (oldHtml) {
159
- if (enableInlineRouteManifests) {
160
- compilation.updateAsset(
161
- htmlName,
162
- new RawSource(oldHtml.source().toString().replace(placeholder, "<script ".concat(nonceAttr, ">").concat(injectedContent, "</script>"))),
163
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
164
- void 0
165
- );
166
- } else {
167
- var scriptPath = "".concat(staticJsDir, "/").concat(ROUTE_MANIFEST_HOLDER, "-").concat(entryName).concat(disableFilenameHash ? ".js" : ".".concat(generateContentHash(injectedContent), ".js"));
168
- var scriptUrl = "".concat(publicPath).concat(scriptPath);
169
- var scriptLoadingAttr = scriptLoading === "defer" ? scriptLoading : scriptLoading === "module" ? 'type="module"' : "";
170
- var script = "<script ".concat(scriptLoadingAttr, " ").concat(nonceAttr, ' src="').concat(scriptUrl, '"></script>');
171
- compilation.updateAsset(
172
- htmlName,
173
- new RawSource(oldHtml.source().toString().replace(placeholder, script)),
174
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
175
- void 0
176
- );
177
- compilation.emitAsset(scriptPath, new RawSource(injectedContent));
178
- }
179
- }
180
- };
181
- stats = compilation.getStats().toJson({
182
- all: false,
183
- publicPath: true,
184
- assets: true,
185
- chunkGroups: true,
186
- chunks: true,
187
- ids: true,
188
- modules: true,
189
- chunkModules: true
190
- });
191
- publicPath = stats.publicPath, _stats_chunks = stats.chunks, chunks = _stats_chunks === void 0 ? [] : _stats_chunks, namedChunkGroups = stats.namedChunkGroups;
192
- routeAssets = {};
193
- route2Sources = {};
194
- if (!namedChunkGroups) {
195
- return [
196
- 2
197
- ];
198
- }
199
- prevManifestAsset = compilation.getAsset(ROUTE_MANIFEST_FILE);
200
- prevManifestStr = prevManifestAsset ? prevManifestAsset.source.source().toString() : JSON.stringify({
201
- routeAssets: {}
202
- });
203
- prevManifest = JSON.parse(prevManifestStr);
204
- asyncEntryNames = [];
205
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
206
- try {
207
- for (_iterator = Object.entries(namedChunkGroups)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
208
- _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], chunkGroup = _step_value[1];
209
- if (name.startsWith("async-")) {
210
- asyncEntryNames.push(name);
211
- }
212
- assets = chunkGroup.assets.map(function(asset) {
213
- var filename = asset.name;
214
- return publicPath ? normalizePath(publicPath) + filename : filename;
215
- });
216
- referenceCssAssets = assets.filter(function(asset) {
217
- return /\.css$/.test(asset);
218
- });
219
- routeAssets[name] = {
220
- chunkIds: chunkGroup.chunks,
221
- assets,
222
- referenceCssAssets
223
- };
224
- if (prevManifest.routeAssets[name]) {
225
- mergeWith(routeAssets[name], prevManifest.routeAssets[name], function(obj, source) {
226
- if (Array.isArray(obj)) {
227
- return obj.concat(source);
228
- }
229
- return Object.assign(source, obj);
230
- });
231
- }
232
- }
233
- } catch (err) {
234
- _didIteratorError = true;
235
- _iteratorError = err;
236
- } finally {
237
- try {
238
- if (!_iteratorNormalCompletion && _iterator.return != null) {
239
- _iterator.return();
240
- }
241
- } finally {
242
- if (_didIteratorError) {
243
- throw _iteratorError;
244
- }
245
- }
246
- }
247
- if (asyncEntryNames.length > 0) {
248
- _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
249
- try {
250
- for (_iterator1 = asyncEntryNames[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
251
- asyncEntryName = _step1.value;
252
- syncEntryName = asyncEntryName.replace("async-", "");
253
- syncEntry = routeAssets[syncEntryName];
254
- asyncEntry = routeAssets[asyncEntryName];
255
- merge(syncEntry, asyncEntry);
256
- }
257
- } catch (err) {
258
- _didIteratorError1 = true;
259
- _iteratorError1 = err;
260
- } finally {
261
- try {
262
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
263
- _iterator1.return();
264
- }
265
- } finally {
266
- if (_didIteratorError1) {
267
- throw _iteratorError1;
268
- }
269
- }
270
- }
271
- }
272
- manifest = {
273
- routeAssets
274
- };
275
- try {
276
- getChunkModules = function(chunk) {
277
- if (!chunk)
278
- return [];
279
- if (typeof chunk.getModules === "function") {
280
- return chunk.getModules() || [];
281
- }
282
- var cg = compilation.chunkGraph;
283
- if (cg && typeof cg.getChunkModules === "function") {
284
- return cg.getChunkModules(chunk) || [];
285
- }
286
- return [];
287
- };
288
- addModuleResources = function(mod, bucket) {
289
- if (!mod)
290
- return;
291
- if (mod.resource) {
292
- if (!/[\\/]node_modules[\\/]/.test(mod.resource)) {
293
- bucket.add(mod.resource);
294
- }
295
- }
296
- if (Array.isArray(mod.modules)) {
297
- mod.modules.forEach(function(m) {
298
- return addModuleResources(m, bucket);
299
- });
300
- }
301
- };
302
- depsByName = /* @__PURE__ */ new Map();
303
- namedGroups = compilation.namedChunkGroups;
304
- groupNames = namedGroups && typeof namedGroups.forEach === "function" ? function() {
305
- var names = [];
306
- namedGroups.forEach(function(_, key) {
307
- return names.push(key);
308
- });
309
- return names;
310
- }() : Object.keys(namedChunkGroups || {});
311
- groupNames.forEach(function(name2) {
312
- var resourceSet = /* @__PURE__ */ new Set();
313
- var group = namedGroups && typeof namedGroups.get === "function" ? namedGroups.get(name2) : void 0;
314
- if (group && Array.isArray(group.chunks)) {
315
- group.chunks.forEach(function(chunk) {
316
- var modules = getChunkModules(chunk);
317
- modules.forEach(function(m) {
318
- return addModuleResources(m, resourceSet);
319
- });
320
- });
321
- } else {
322
- var matched = Array.from(compilation.chunks || []).filter(function(c) {
323
- var _c_names_includes, _c_names;
324
- return (c === null || c === void 0 ? void 0 : c.name) === name2 || (c === null || c === void 0 ? void 0 : (_c_names = c.names) === null || _c_names === void 0 ? void 0 : (_c_names_includes = _c_names.includes) === null || _c_names_includes === void 0 ? void 0 : _c_names_includes.call(_c_names, name2));
325
- });
326
- matched.forEach(function(chunk) {
327
- var modules = getChunkModules(chunk);
328
- modules.forEach(function(m) {
329
- return addModuleResources(m, resourceSet);
330
- });
331
- });
332
- }
333
- depsByName.set(name2, resourceSet);
334
- });
335
- Object.keys(routeAssets).forEach(function(routeId) {
336
- var set = depsByName.get(routeId);
337
- if (set && set.size > 0) {
338
- route2Sources[routeId] = Array.from(set);
339
- }
340
- });
341
- if (asyncEntryNames.length > 0) {
342
- _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
343
- try {
344
- _loop1 = function() {
345
- var asyncEntryName2 = _step2.value;
346
- var syncEntryName2 = asyncEntryName2.replace("async-", "");
347
- var asyncSet = depsByName.get(asyncEntryName2);
348
- if (asyncSet && asyncSet.size > 0) {
349
- var base = new Set(route2Sources[syncEntryName2] || []);
350
- asyncSet.forEach(function(v) {
351
- return base.add(v);
352
- });
353
- route2Sources[syncEntryName2] = Array.from(base);
354
- }
355
- };
356
- for (_iterator2 = asyncEntryNames[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true)
357
- _loop1();
358
- } catch (err) {
359
- _didIteratorError2 = true;
360
- _iteratorError2 = err;
361
- } finally {
362
- try {
363
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
364
- _iterator2.return();
365
- }
366
- } finally {
367
- if (_didIteratorError2) {
368
- throw _iteratorError2;
369
- }
370
- }
371
- }
372
- }
373
- compilation[ROUTE_DEPS_COMPILATION_KEY] = route2Sources;
374
- } catch (e) {
375
- }
376
- entryNames = Array.from(compilation.entrypoints.keys());
377
- entryChunks = [];
378
- if (isRspack) {
379
- entryChunks = _this1.getEntryChunks(compilation, chunks);
380
- } else {
381
- orignalEntryIds = Object.keys(compilation.options.entry).map(function(entryName) {
382
- var chunk = compilation.namedChunks.get(entryName);
383
- if (chunk) {
384
- return chunk.id;
385
- }
386
- return entryName;
387
- });
388
- entryChunks = _this1.getEntryChunks(compilation, chunks).filter(function(chunk) {
389
- return orignalEntryIds.includes(chunk.id);
390
- });
391
- }
392
- entryChunkFiles = _this1.getEntryChunkFiles(entryChunks);
393
- entryChunkFileIds = entryChunks.map(function(chunk) {
394
- return chunk.id;
395
- });
396
- for (i = 0; i < entryChunkFiles.length; i++)
397
- _loop(i);
398
- if (prevManifestAsset) {
399
- compilation.updateAsset(
400
- ROUTE_MANIFEST_FILE,
401
- new RawSource(JSON.stringify(manifest, null, 2)),
402
- // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
403
- void 0
404
- );
405
- } else {
406
- compilation.emitAsset(ROUTE_MANIFEST_FILE, new RawSource(JSON.stringify(manifest, null, 2)));
407
- }
408
- return [
409
- 2
410
- ];
411
- });
412
- }));
413
- });
414
- };
415
- return RouterPlugin2;
416
- }();
417
- export {
418
- ROUTE_DEPS_COMPILATION_KEY,
419
- RouterPlugin
420
- };
@@ -1,3 +0,0 @@
1
- export * from "./HtmlAsyncChunkPlugin";
2
- export * from "./HtmlBottomTemplate";
3
- export * from "./RouterPlugin";
@@ -1,14 +0,0 @@
1
- import path from "path";
2
- function createCopyInfo(appContext, config) {
3
- var configDir = path.resolve(appContext.appDirectory, config.source.configDir || "./config");
4
- var uploadDir = path.posix.join(configDir.replace(/\\/g, "/"), "upload");
5
- var publicDir = path.posix.join(configDir.replace(/\\/g, "/"), "public");
6
- return {
7
- configDir,
8
- uploadDir,
9
- publicDir
10
- };
11
- }
12
- export {
13
- createCopyInfo
14
- };
@@ -1,3 +0,0 @@
1
- export * from "./types";
2
- export * from "./builderPlugins";
3
- export * from "./createCopyInfo";
@@ -1,7 +0,0 @@
1
- function loader() {
2
- return "module.exports = {}";
3
- }
4
- var serverModuleLoader_default = loader;
5
- export {
6
- serverModuleLoader_default as default
7
- };
@@ -1,142 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { logger } from "@modern-js/utils";
4
- import { buildServerConfig } from "../utils/config";
5
- import { loadServerPlugins } from "../utils/loadPlugins";
6
- import { registerCompiler } from "../utils/register";
7
- import { generateRoutes } from "../utils/routes";
8
- var build = function() {
9
- var _ref = _async_to_generator(function(api, options) {
10
- var _resolvedConfig_resolve, _resolvedConfig_source, resolvedConfig, appContext, hooks, _resolvedConfig_resolve_alias, _resolvedConfig_source_alias, combinedAlias, registerEsm, apiOnly, appDirectory, distDirectory, serverConfigFile, distDirectory1, appDirectory1, serverConfigFile1;
11
- return _ts_generator(this, function(_state) {
12
- switch (_state.label) {
13
- case 0:
14
- if (options === null || options === void 0 ? void 0 : options.analyze) {
15
- process.env.BUNDLE_ANALYZE = "true";
16
- }
17
- resolvedConfig = api.getNormalizedConfig();
18
- appContext = api.getAppContext();
19
- hooks = api.getHooks();
20
- combinedAlias = [].concat((_resolvedConfig_resolve_alias = resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_resolve = resolvedConfig.resolve) === null || _resolvedConfig_resolve === void 0 ? void 0 : _resolvedConfig_resolve.alias) !== null && _resolvedConfig_resolve_alias !== void 0 ? _resolvedConfig_resolve_alias : []).concat((_resolvedConfig_source_alias = resolvedConfig === null || resolvedConfig === void 0 ? void 0 : (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.alias) !== null && _resolvedConfig_source_alias !== void 0 ? _resolvedConfig_source_alias : []);
21
- return [
22
- 4,
23
- loadServerPlugins(api, appContext.appDirectory, appContext.metaName)
24
- ];
25
- case 1:
26
- _state.sent();
27
- if (!(appContext.moduleType && appContext.moduleType === "module"))
28
- return [
29
- 3,
30
- 4
31
- ];
32
- return [
33
- 4,
34
- import("../esm/register-esm.mjs")
35
- ];
36
- case 2:
37
- registerEsm = _state.sent().registerEsm;
38
- return [
39
- 4,
40
- registerEsm({
41
- appDir: appContext.appDirectory,
42
- distDir: appContext.distDirectory,
43
- alias: combinedAlias
44
- })
45
- ];
46
- case 3:
47
- _state.sent();
48
- _state.label = 4;
49
- case 4:
50
- return [
51
- 4,
52
- registerCompiler(appContext.appDirectory, appContext.distDirectory, combinedAlias)
53
- ];
54
- case 5:
55
- _state.sent();
56
- apiOnly = appContext.apiOnly;
57
- if (!apiOnly)
58
- return [
59
- 3,
60
- 10
61
- ];
62
- appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverConfigFile = appContext.serverConfigFile;
63
- return [
64
- 4,
65
- hooks.onBeforeBuild.call({
66
- environments: {},
67
- // "null" bundlerConfigs
68
- bundlerConfigs: void 0,
69
- isFirstCompile: false,
70
- isWatch: false
71
- })
72
- ];
73
- case 6:
74
- _state.sent();
75
- return [
76
- 4,
77
- buildServerConfig({
78
- appDirectory,
79
- distDirectory,
80
- configFile: serverConfigFile
81
- })
82
- ];
83
- case 7:
84
- _state.sent();
85
- return [
86
- 4,
87
- generateRoutes(appContext)
88
- ];
89
- case 8:
90
- _state.sent();
91
- return [
92
- 4,
93
- hooks.onAfterBuild.call({
94
- environments: {},
95
- // "null" stats
96
- stats: void 0,
97
- isFirstCompile: false,
98
- isWatch: false
99
- })
100
- ];
101
- case 9:
102
- _state.sent();
103
- return [
104
- 2
105
- ];
106
- case 10:
107
- distDirectory1 = appContext.distDirectory, appDirectory1 = appContext.appDirectory, serverConfigFile1 = appContext.serverConfigFile;
108
- return [
109
- 4,
110
- buildServerConfig({
111
- appDirectory: appDirectory1,
112
- distDirectory: distDirectory1,
113
- configFile: serverConfigFile1
114
- })
115
- ];
116
- case 11:
117
- _state.sent();
118
- logger.info("Starting production build...");
119
- if (!appContext.builder) {
120
- throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
121
- }
122
- return [
123
- 4,
124
- appContext.builder.build({
125
- watch: options === null || options === void 0 ? void 0 : options.watch
126
- })
127
- ];
128
- case 12:
129
- _state.sent();
130
- return [
131
- 2
132
- ];
133
- }
134
- });
135
- });
136
- return function build2(api, options) {
137
- return _ref.apply(this, arguments);
138
- };
139
- }();
140
- export {
141
- build
142
- };
@@ -1,48 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { getServerPlugins } from "../utils/loadPlugins";
4
- var deploy = function() {
5
- var _ref = _async_to_generator(function(api, options) {
6
- var hooks, metaName;
7
- return _ts_generator(this, function(_state) {
8
- switch (_state.label) {
9
- case 0:
10
- hooks = api.getHooks();
11
- metaName = api.getAppContext().metaName;
12
- return [
13
- 4,
14
- getServerPlugins(api, metaName)
15
- ];
16
- case 1:
17
- _state.sent();
18
- return [
19
- 4,
20
- hooks.onBeforeDeploy.call(options)
21
- ];
22
- case 2:
23
- _state.sent();
24
- return [
25
- 4,
26
- hooks.deploy.call()
27
- ];
28
- case 3:
29
- _state.sent();
30
- return [
31
- 4,
32
- hooks.onAfterDeploy.call(options)
33
- ];
34
- case 4:
35
- _state.sent();
36
- return [
37
- 2
38
- ];
39
- }
40
- });
41
- });
42
- return function deploy2(api, options) {
43
- return _ref.apply(this, arguments);
44
- };
45
- }();
46
- export {
47
- deploy
48
- };