@modern-js/app-tools 2.7.0 → 2.7.1-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 (302) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/analyze/generateCode.js +6 -3
  3. package/dist/cjs/analyze/index.js +14 -1
  4. package/dist/cjs/analyze/templates.js +6 -4
  5. package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +2 -13
  6. package/dist/cjs/builder/generator/index.js +10 -2
  7. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +101 -0
  8. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +91 -0
  9. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +140 -0
  10. package/dist/cjs/builder/shared/builderPlugins/index.js +19 -0
  11. package/dist/cjs/builder/{builder-webpack/webpackPlugins → shared/bundlerPlugins}/RouterPlugin.js +11 -5
  12. package/dist/cjs/builder/shared/bundlerPlugins/index.js +19 -0
  13. package/dist/cjs/builder/shared/index.js +1 -1
  14. package/dist/cjs/index.js +1 -1
  15. package/dist/cjs/locale/en.js +1 -0
  16. package/dist/cjs/locale/zh.js +1 -0
  17. package/dist/esm/analyze/generateCode.js +7 -5
  18. package/dist/esm/analyze/index.js +11 -2
  19. package/dist/esm/analyze/templates.js +6 -5
  20. package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +0 -11
  21. package/dist/esm/builder/generator/index.js +6 -4
  22. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +101 -0
  23. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +120 -0
  24. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +131 -0
  25. package/dist/esm/builder/shared/builderPlugins/index.js +3 -0
  26. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +350 -0
  27. package/dist/esm/builder/shared/bundlerPlugins/index.js +3 -0
  28. package/dist/esm/builder/shared/index.js +1 -1
  29. package/dist/esm/index.js +1 -1
  30. package/dist/esm/locale/en.js +1 -0
  31. package/dist/esm/locale/zh.js +1 -0
  32. package/dist/esm-node/analyze/generateCode.js +14 -4
  33. package/dist/esm-node/analyze/index.js +16 -2
  34. package/dist/esm-node/analyze/templates.js +6 -4
  35. package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -13
  36. package/dist/esm-node/builder/generator/index.js +10 -2
  37. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +67 -0
  38. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +67 -0
  39. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +119 -0
  40. package/dist/esm-node/builder/shared/builderPlugins/index.js +3 -0
  41. package/dist/esm-node/builder/{builder-webpack/webpackPlugins → shared/bundlerPlugins}/RouterPlugin.js +11 -5
  42. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +3 -0
  43. package/dist/esm-node/builder/shared/index.js +1 -1
  44. package/dist/esm-node/index.js +1 -1
  45. package/dist/esm-node/locale/en.js +1 -0
  46. package/dist/esm-node/locale/zh.js +1 -0
  47. package/dist/js/modern/analyze/constants.js +54 -0
  48. package/dist/js/modern/analyze/generateCode.js +247 -0
  49. package/dist/js/modern/analyze/getBundleEntry.js +71 -0
  50. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
  51. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
  52. package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
  53. package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
  54. package/dist/js/modern/analyze/getFileSystemEntry.js +109 -0
  55. package/dist/js/modern/analyze/getHtmlTemplate.js +115 -0
  56. package/dist/js/modern/analyze/getServerRoutes.js +175 -0
  57. package/dist/js/modern/analyze/index.js +332 -0
  58. package/dist/js/modern/analyze/isDefaultExportFunction.js +42 -0
  59. package/dist/js/modern/analyze/makeLegalIdentifier.js +13 -0
  60. package/dist/js/modern/analyze/nestedRoutes.js +157 -0
  61. package/dist/js/modern/analyze/templates.js +334 -0
  62. package/dist/js/modern/analyze/utils.js +141 -0
  63. package/dist/{esm-node/builder/shared/builderPlugins/adapterModern.js → js/modern/builder/builderPlugins/compatModern.js} +135 -104
  64. package/dist/js/modern/builder/index.js +159 -0
  65. package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
  66. package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
  67. package/dist/js/modern/builder/share.js +46 -0
  68. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
  69. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
  70. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
  71. package/dist/js/modern/commands/build.js +91 -0
  72. package/dist/js/modern/commands/deploy.js +28 -0
  73. package/dist/js/modern/commands/dev.js +109 -0
  74. package/dist/js/modern/commands/index.js +3 -0
  75. package/dist/js/modern/commands/inspect.js +38 -0
  76. package/dist/js/modern/commands/serve.js +54 -0
  77. package/dist/js/modern/config/default.js +175 -0
  78. package/dist/js/modern/config/index.js +8 -0
  79. package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
  80. package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
  81. package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
  82. package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
  83. package/dist/js/modern/config/initial/index.js +16 -0
  84. package/dist/js/modern/config/initial/inits.js +152 -0
  85. package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
  86. package/dist/js/modern/defineConfig.js +27 -0
  87. package/dist/js/modern/exports/server.js +4 -0
  88. package/dist/js/modern/hooks.js +35 -0
  89. package/dist/js/modern/index.js +211 -0
  90. package/dist/js/modern/initialize/index.js +124 -0
  91. package/dist/js/modern/locale/en.js +36 -0
  92. package/dist/js/modern/locale/index.js +9 -0
  93. package/dist/js/modern/locale/zh.js +36 -0
  94. package/dist/js/modern/schema/Schema.js +40 -0
  95. package/dist/js/modern/schema/index.js +88 -0
  96. package/dist/js/modern/schema/legacy.js +148 -0
  97. package/dist/js/modern/types/config/deploy.js +0 -0
  98. package/dist/js/modern/types/config/dev.js +0 -0
  99. package/dist/js/modern/types/config/experiments.js +0 -0
  100. package/dist/js/modern/types/config/html.js +0 -0
  101. package/dist/js/modern/types/config/index.js +1 -0
  102. package/dist/js/modern/types/config/output.js +0 -0
  103. package/dist/js/modern/types/config/performance.js +0 -0
  104. package/dist/js/modern/types/config/security.js +0 -0
  105. package/dist/js/modern/types/config/source.js +0 -0
  106. package/dist/js/modern/types/config/tools.js +0 -0
  107. package/dist/js/modern/types/hooks.js +0 -0
  108. package/dist/js/modern/types/index.js +3 -0
  109. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  110. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  111. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  112. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  113. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  114. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  115. package/dist/js/modern/utils/config.js +128 -0
  116. package/dist/js/modern/utils/createServer.js +75 -0
  117. package/dist/js/modern/utils/env.js +15 -0
  118. package/dist/js/modern/utils/generateWatchFiles.js +55 -0
  119. package/dist/js/modern/utils/getSelectedEntries.js +58 -0
  120. package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
  121. package/dist/js/modern/utils/language.js +8 -0
  122. package/dist/js/modern/utils/printInstructions.js +31 -0
  123. package/dist/js/modern/utils/restart.js +44 -0
  124. package/dist/js/modern/utils/routes.js +30 -0
  125. package/dist/js/modern/utils/types.js +0 -0
  126. package/dist/js/node/analyze/constants.js +98 -0
  127. package/dist/js/node/analyze/generateCode.js +271 -0
  128. package/dist/js/node/analyze/getBundleEntry.js +95 -0
  129. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
  130. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
  131. package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
  132. package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
  133. package/dist/js/node/analyze/getFileSystemEntry.js +131 -0
  134. package/dist/js/node/analyze/getHtmlTemplate.js +144 -0
  135. package/dist/js/node/analyze/getServerRoutes.js +194 -0
  136. package/dist/js/node/analyze/index.js +339 -0
  137. package/dist/js/node/analyze/isDefaultExportFunction.js +71 -0
  138. package/dist/js/node/analyze/makeLegalIdentifier.js +36 -0
  139. package/dist/js/node/analyze/nestedRoutes.js +184 -0
  140. package/dist/js/node/analyze/templates.js +365 -0
  141. package/dist/js/node/analyze/utils.js +172 -0
  142. package/dist/{cjs/builder/shared/builderPlugins/adapterModern.js → js/node/builder/builderPlugins/compatModern.js} +137 -113
  143. package/dist/js/node/builder/index.js +177 -0
  144. package/dist/js/node/builder/loaders/routerLoader.js +38 -0
  145. package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
  146. package/dist/js/node/builder/share.js +75 -0
  147. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
  148. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
  149. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
  150. package/dist/js/node/commands/build.js +112 -0
  151. package/dist/js/node/commands/deploy.js +51 -0
  152. package/dist/js/node/commands/dev.js +126 -0
  153. package/dist/js/node/commands/index.js +19 -0
  154. package/dist/js/node/commands/inspect.js +61 -0
  155. package/dist/js/node/commands/serve.js +83 -0
  156. package/dist/js/node/config/default.js +197 -0
  157. package/dist/js/node/config/index.js +34 -0
  158. package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
  159. package/dist/js/node/config/initial/createOutputConfig.js +91 -0
  160. package/dist/js/node/config/initial/createSourceConfig.js +62 -0
  161. package/dist/js/node/config/initial/createToolsConfig.js +65 -0
  162. package/dist/js/node/config/initial/index.js +41 -0
  163. package/dist/js/node/config/initial/inits.js +175 -0
  164. package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
  165. package/dist/js/node/defineConfig.js +49 -0
  166. package/dist/js/node/exports/server.js +27 -0
  167. package/dist/js/node/hooks.js +54 -0
  168. package/dist/js/node/index.js +235 -0
  169. package/dist/js/node/initialize/index.js +134 -0
  170. package/dist/js/node/locale/en.js +59 -0
  171. package/dist/js/node/locale/index.js +33 -0
  172. package/dist/js/node/locale/zh.js +59 -0
  173. package/dist/js/node/schema/Schema.js +63 -0
  174. package/dist/js/node/schema/index.js +118 -0
  175. package/dist/js/node/schema/legacy.js +169 -0
  176. package/dist/js/node/types/config/deploy.js +15 -0
  177. package/dist/js/node/types/config/dev.js +15 -0
  178. package/dist/js/node/types/config/experiments.js +15 -0
  179. package/dist/js/node/types/config/html.js +15 -0
  180. package/dist/{cjs/builder/builder-webpack/webpackPlugins → js/node/types/config}/index.js +3 -3
  181. package/dist/js/node/types/config/output.js +15 -0
  182. package/dist/js/node/types/config/performance.js +15 -0
  183. package/dist/js/node/types/config/security.js +15 -0
  184. package/dist/js/node/types/config/source.js +15 -0
  185. package/dist/js/node/types/config/tools.js +15 -0
  186. package/dist/js/node/types/hooks.js +15 -0
  187. package/dist/js/node/types/index.js +19 -0
  188. package/dist/js/node/types/legacyConfig/deploy.js +15 -0
  189. package/dist/js/node/types/legacyConfig/dev.js +15 -0
  190. package/dist/js/node/types/legacyConfig/index.js +15 -0
  191. package/dist/js/node/types/legacyConfig/output.js +15 -0
  192. package/dist/js/node/types/legacyConfig/source.js +15 -0
  193. package/dist/js/node/types/legacyConfig/tools.js +15 -0
  194. package/dist/js/node/utils/config.js +153 -0
  195. package/dist/js/node/utils/createServer.js +106 -0
  196. package/dist/js/node/utils/env.js +38 -0
  197. package/dist/js/node/utils/generateWatchFiles.js +85 -0
  198. package/dist/js/node/utils/getSelectedEntries.js +81 -0
  199. package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
  200. package/dist/js/node/utils/language.js +31 -0
  201. package/dist/js/node/utils/printInstructions.js +54 -0
  202. package/dist/js/node/utils/restart.js +67 -0
  203. package/dist/js/node/utils/routes.js +59 -0
  204. package/dist/js/node/utils/types.js +15 -0
  205. package/dist/js/treeshaking/analyze/constants.js +40 -0
  206. package/dist/js/treeshaking/analyze/generateCode.js +485 -0
  207. package/dist/js/treeshaking/analyze/getBundleEntry.js +62 -0
  208. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
  209. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
  210. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
  211. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
  212. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
  213. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
  214. package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
  215. package/dist/js/treeshaking/analyze/index.js +697 -0
  216. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
  217. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
  218. package/dist/js/treeshaking/analyze/nestedRoutes.js +384 -0
  219. package/dist/js/treeshaking/analyze/templates.js +468 -0
  220. package/dist/js/treeshaking/analyze/utils.js +374 -0
  221. package/dist/{esm/builder/shared/builderPlugins/adapterModern.js → js/treeshaking/builder/builderPlugins/compatModern.js} +142 -138
  222. package/dist/js/treeshaking/builder/index.js +374 -0
  223. package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
  224. package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
  225. package/dist/js/treeshaking/builder/share.js +40 -0
  226. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
  227. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
  228. package/dist/{esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js → js/treeshaking/builder/webpackPlugins/routerPlugin.js} +3 -6
  229. package/dist/js/treeshaking/commands/build.js +291 -0
  230. package/dist/js/treeshaking/commands/deploy.js +154 -0
  231. package/dist/js/treeshaking/commands/dev.js +301 -0
  232. package/dist/js/treeshaking/commands/index.js +3 -0
  233. package/dist/js/treeshaking/commands/inspect.js +149 -0
  234. package/dist/js/treeshaking/commands/serve.js +199 -0
  235. package/dist/js/treeshaking/config/default.js +210 -0
  236. package/dist/js/treeshaking/config/index.js +3 -0
  237. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
  238. package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
  239. package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
  240. package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
  241. package/dist/js/treeshaking/config/initial/index.js +12 -0
  242. package/dist/js/treeshaking/config/initial/inits.js +209 -0
  243. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
  244. package/dist/js/treeshaking/defineConfig.js +61 -0
  245. package/dist/js/treeshaking/exports/server.js +2 -0
  246. package/dist/js/treeshaking/hooks.js +29 -0
  247. package/dist/js/treeshaking/index.js +706 -0
  248. package/dist/js/treeshaking/initialize/index.js +276 -0
  249. package/dist/js/treeshaking/locale/en.js +38 -0
  250. package/dist/js/treeshaking/locale/index.js +9 -0
  251. package/dist/js/treeshaking/locale/zh.js +38 -0
  252. package/dist/js/treeshaking/schema/Schema.js +273 -0
  253. package/dist/js/treeshaking/schema/index.js +181 -0
  254. package/dist/js/treeshaking/schema/legacy.js +337 -0
  255. package/dist/js/treeshaking/types/config/deploy.js +1 -0
  256. package/dist/js/treeshaking/types/config/dev.js +1 -0
  257. package/dist/js/treeshaking/types/config/experiments.js +1 -0
  258. package/dist/js/treeshaking/types/config/html.js +1 -0
  259. package/dist/js/treeshaking/types/config/index.js +1 -0
  260. package/dist/js/treeshaking/types/config/output.js +1 -0
  261. package/dist/js/treeshaking/types/config/performance.js +1 -0
  262. package/dist/js/treeshaking/types/config/security.js +1 -0
  263. package/dist/js/treeshaking/types/config/source.js +1 -0
  264. package/dist/js/treeshaking/types/config/tools.js +1 -0
  265. package/dist/js/treeshaking/types/hooks.js +1 -0
  266. package/dist/js/treeshaking/types/index.js +3 -0
  267. package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
  268. package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
  269. package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
  270. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  271. package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
  272. package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
  273. package/dist/js/treeshaking/utils/config.js +302 -0
  274. package/dist/js/treeshaking/utils/createServer.js +258 -0
  275. package/dist/js/treeshaking/utils/env.js +13 -0
  276. package/dist/js/treeshaking/utils/generateWatchFiles.js +214 -0
  277. package/dist/js/treeshaking/utils/getSelectedEntries.js +186 -0
  278. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
  279. package/dist/js/treeshaking/utils/language.js +6 -0
  280. package/dist/js/treeshaking/utils/printInstructions.js +152 -0
  281. package/dist/js/treeshaking/utils/restart.js +187 -0
  282. package/dist/js/treeshaking/utils/routes.js +153 -0
  283. package/dist/js/treeshaking/utils/types.js +1 -0
  284. package/dist/types/analyze/templates.d.ts +3 -1
  285. package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +7 -0
  286. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +5 -0
  287. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +4 -0
  288. package/dist/types/builder/shared/builderPlugins/index.d.ts +3 -0
  289. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +5 -0
  290. package/dist/types/builder/shared/bundlerPlugins/index.d.ts +3 -0
  291. package/dist/types/builder/shared/index.d.ts +1 -1
  292. package/dist/types/builder/shared/types.d.ts +7 -4
  293. package/dist/types/locale/en.d.ts +1 -0
  294. package/dist/types/locale/index.d.ts +2 -0
  295. package/dist/types/locale/zh.d.ts +1 -0
  296. package/dist/types/types/config/output.d.ts +3 -15
  297. package/package.json +12 -12
  298. package/dist/esm/builder/builder-webpack/webpackPlugins/index.js +0 -1
  299. package/dist/esm-node/builder/builder-webpack/webpackPlugins/index.js +0 -1
  300. package/dist/types/builder/builder-webpack/webpackPlugins/RouterPlugin.d.ts +0 -4
  301. package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +0 -1
  302. package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +0 -13
package/README.md CHANGED
@@ -19,8 +19,8 @@ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-sta
19
19
 
20
20
  ## Contributing
21
21
 
22
- Please read the [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md).
22
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
23
23
 
24
24
  ## License
25
25
 
26
- Modern.js is [MIT licensed](https://github.com/modern-js-dev/modern.js/blob/main/LICENSE).
26
+ Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
@@ -99,6 +99,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
99
99
  const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
100
100
  await Promise.all(entrypoints.map(generateEntryCode));
101
101
  async function generateEntryCode(entrypoint) {
102
+ var _a;
102
103
  const { entryName, isAutoMount, customBootstrap, fileSystemRoutes } = entrypoint;
103
104
  if (isAutoMount) {
104
105
  if (fileSystemRoutes) {
@@ -138,6 +139,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
138
139
  config2.server.ssrByEntries,
139
140
  packageName
140
141
  );
142
+ const useSSG = (0, import_utils.isSSGEntry)(config2, entryName, entrypoints);
141
143
  let mode;
142
144
  if (ssr) {
143
145
  mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
@@ -157,13 +159,14 @@ const generateCode = async (appContext, config, entrypoints, api) => {
157
159
  entrypoint,
158
160
  code: await templates.fileSystemRoutes({
159
161
  routes,
160
- ssrMode: mode,
162
+ ssrMode: useSSG ? "string" : mode,
161
163
  nestedRoutesEntry: entrypoint.nestedRoutesEntry,
162
164
  entryName: entrypoint.entryName,
163
- internalDirectory
165
+ internalDirectory,
166
+ splitRoutesChunks: (_a = config2 == null ? void 0 : config2.output) == null ? void 0 : _a.splitRoutesChunks
164
167
  })
165
168
  });
166
- if (entrypoint.nestedRoutesEntry && mode) {
169
+ if (entrypoint.nestedRoutesEntry && (0, import_utils.isUseSSRBundle)(config2)) {
167
170
  const routesServerFile = (0, import_utils2.getServerLoadersFile)(
168
171
  internalDirectory,
169
172
  entryName
@@ -205,7 +205,12 @@ var analyze_default = ({
205
205
  resolvedConfig.server.ssrByEntries,
206
206
  packageName
207
207
  );
208
- if (entrypoint.nestedRoutesEntry && ssr && name === "server") {
208
+ const useSSG = (0, import_utils.isSSGEntry)(
209
+ resolvedConfig,
210
+ entryName,
211
+ entrypoints
212
+ );
213
+ if (entrypoint.nestedRoutesEntry && (ssr || useSSG) && name === "server") {
209
214
  const serverLoaderRuntime = require.resolve("@modern-js/plugin-data-loader/runtime");
210
215
  const serverLoadersFile = (0, import_utils2.getServerLoadersFile)(
211
216
  internalDirectory,
@@ -279,6 +284,14 @@ var analyze_default = ({
279
284
  imports
280
285
  };
281
286
  },
287
+ validateSchema() {
288
+ return {
289
+ target: "output.splitRoutesChunks",
290
+ schema: {
291
+ type: "boolean"
292
+ }
293
+ };
294
+ },
282
295
  async fileChange(e) {
283
296
  const appContext = api.useAppContext();
284
297
  const { appDirectory } = appContext;
@@ -180,12 +180,14 @@ const fileSystemRoutes = async ({
180
180
  ssrMode,
181
181
  nestedRoutesEntry,
182
182
  entryName,
183
- internalDirectory
183
+ internalDirectory,
184
+ splitRoutesChunks = true
184
185
  }) => {
185
186
  const loadings = [];
186
187
  const errors = [];
187
188
  const loaders = [];
188
189
  const loadersMap = {};
190
+ const webpackMode = splitRoutesChunks ? "lazy" : "eager";
189
191
  const loadersMapFile = import_path.default.join(
190
192
  internalDirectory,
191
193
  entryName,
@@ -244,15 +246,15 @@ const fileSystemRoutes = async ({
244
246
  rootLayoutCode = `import RootLayout from '${route._component}'`;
245
247
  component = `RootLayout`;
246
248
  } else if (ssrMode === "string") {
247
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}')`;
249
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ /* webpackMode: "${webpackMode}" */ '${route._component}')`;
248
250
  component = `loadable(${lazyImport})`;
249
251
  } else {
250
- lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}')`;
252
+ lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ /* webpackMode: "${webpackMode}" */ '${route._component}')`;
251
253
  component = `lazy(${lazyImport})`;
252
254
  }
253
255
  }
254
256
  } else if (route._component) {
255
- lazyImport = `() => import('${route._component}')`;
257
+ lazyImport = `() => import( /* webpackMode: "${webpackMode}" */ '${route._component}')`;
256
258
  component = `loadable(${lazyImport})`;
257
259
  }
258
260
  const finalRoute = {
@@ -22,13 +22,11 @@ __export(compatModern_exports, {
22
22
  module.exports = __toCommonJS(compatModern_exports);
23
23
  var import_path = require("path");
24
24
  var import_shared = require("../../shared");
25
- var import_webpackPlugins = require("../webpackPlugins");
26
25
  const builderPluginCompatModern = (options) => ({
27
26
  name: "builder-plugin-compat-modern",
28
27
  setup(api) {
29
28
  const { normalizedConfig: modernConfig, appContext } = options;
30
29
  api.modifyWebpackChain((chain, { CHAIN_ID }) => {
31
- var _a;
32
30
  chain.resolve.modules.add("node_modules").add((0, import_path.join)(api.context.rootPath, "node_modules"));
33
31
  if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
34
32
  const defaultCopyPattern = (0, import_shared.createCopyPattern)(
@@ -38,23 +36,14 @@ const builderPluginCompatModern = (options) => ({
38
36
  chain
39
37
  );
40
38
  chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
41
- var _a2;
39
+ var _a;
42
40
  return [
43
41
  {
44
- patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
42
+ patterns: [...((_a = args[0]) == null ? void 0 : _a.patterns) || [], defaultCopyPattern]
45
43
  }
46
44
  ];
47
45
  });
48
46
  }
49
- const { entrypoints } = appContext;
50
- const existNestedRoutes = entrypoints.some(
51
- (entrypoint) => entrypoint.nestedRoutesEntry
52
- );
53
- const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
54
- const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
55
- if (existNestedRoutes || routerManifest) {
56
- chain.plugin("route-plugin").use(import_webpackPlugins.RouterPlugin);
57
- }
58
47
  });
59
48
  }
60
49
  });
@@ -53,8 +53,16 @@ async function generateBuilder(options, generateProvider, utils) {
53
53
  return builder;
54
54
  }
55
55
  async function applyBuilderPlugins(builder, options) {
56
- const { builderPluginAdapterModern } = await Promise.resolve().then(() => __toESM(require("../shared/builderPlugins/adapterModern")));
57
- builder.addPlugins([builderPluginAdapterModern(options)]);
56
+ const {
57
+ builderPluginAdapterBasic,
58
+ builderPluginAdapterHtml,
59
+ builderPluginAdapterSSR
60
+ } = await Promise.resolve().then(() => __toESM(require("../shared/builderPlugins")));
61
+ builder.addPlugins([
62
+ builderPluginAdapterBasic(options),
63
+ builderPluginAdapterSSR(options),
64
+ builderPluginAdapterHtml(options)
65
+ ]);
58
66
  }
59
67
  // Annotate the CommonJS export names for ESM import in node:
60
68
  0 && (module.exports = {
@@ -0,0 +1,101 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var adapterBasic_exports = {};
29
+ __export(adapterBasic_exports, {
30
+ applyCallbacks: () => applyCallbacks,
31
+ builderPluginAdapterBasic: () => builderPluginAdapterBasic
32
+ });
33
+ module.exports = __toCommonJS(adapterBasic_exports);
34
+ const builderPluginAdapterBasic = (options) => ({
35
+ name: "builder-plugin-adapter-modern-basic",
36
+ setup(api) {
37
+ api.modifyBundlerChain((chain, { target, CHAIN_ID }) => {
38
+ if (target === "node") {
39
+ chain.name("server");
40
+ } else if (target === "service-worker") {
41
+ chain.name("service-worker");
42
+ } else if (target === "web-worker") {
43
+ chain.name("worker");
44
+ } else if (target === "modern-web") {
45
+ chain.name("modern");
46
+ } else {
47
+ chain.name("client");
48
+ }
49
+ if (target === "node" || target === "service-worker") {
50
+ applyNodeCompat(target, chain);
51
+ }
52
+ if (target === "web" || target === "modern-web") {
53
+ const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
54
+ chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
55
+ chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
56
+ }
57
+ });
58
+ applyCallbacks(api, options);
59
+ }
60
+ });
61
+ function applyCallbacks(api, options) {
62
+ options.onAfterBuild && api.onAfterBuild(options.onAfterBuild);
63
+ options.onAfterCreateCompiler && api.onAfterCreateCompiler(options.onAfterCreateCompiler);
64
+ options.onAfterStartDevServer && api.onAfterStartDevServer(options.onAfterStartDevServer);
65
+ options.onBeforeBuild && api.onBeforeBuild(options.onBeforeBuild);
66
+ options.onBeforeCreateCompiler && api.onBeforeCreateCompiler(options.onBeforeCreateCompiler);
67
+ options.onBeforeStartDevServer && api.onBeforeStartDevServer(options.onBeforeStartDevServer);
68
+ options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
69
+ options.onExit && api.onExit(options.onExit);
70
+ }
71
+ function applyNodeCompat(target, chain) {
72
+ const nodeExts = [
73
+ ".node.js",
74
+ ".node.jsx",
75
+ ".node.ts",
76
+ ".node.tsx",
77
+ ".server.js",
78
+ ".server.ts",
79
+ ".server.ts",
80
+ ".server.tsx"
81
+ ];
82
+ const webWorkerExts = [
83
+ ".worker.js",
84
+ ".worker.jsx",
85
+ ".worker.ts",
86
+ ".worker.tsx"
87
+ ];
88
+ for (const ext of nodeExts) {
89
+ chain.resolve.extensions.prepend(ext);
90
+ }
91
+ if (target === "service-worker") {
92
+ for (const ext of webWorkerExts) {
93
+ chain.resolve.extensions.prepend(ext);
94
+ }
95
+ }
96
+ }
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ applyCallbacks,
100
+ builderPluginAdapterBasic
101
+ });
@@ -0,0 +1,91 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var adapterHtml_exports = {};
19
+ __export(adapterHtml_exports, {
20
+ builderPluginAdapterHtml: () => builderPluginAdapterHtml,
21
+ isHtmlEnabled: () => isHtmlEnabled
22
+ });
23
+ module.exports = __toCommonJS(adapterHtml_exports);
24
+ var import_utils = require("@modern-js/utils");
25
+ var import_lodash = require("@modern-js/utils/lodash");
26
+ var import_bundlerPlugins = require("../bundlerPlugins");
27
+ function isHtmlEnabled(config, target) {
28
+ var _a;
29
+ return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
30
+ }
31
+ const builderPluginAdapterHtml = (options) => ({
32
+ name: "builder-plugin-adpater-modern-html",
33
+ setup(api) {
34
+ api.modifyBundlerChain(
35
+ (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin }) => {
36
+ const builderConfig = api.getNormalizedConfig();
37
+ if (isHtmlEnabled(builderConfig, target)) {
38
+ applyBottomHtmlPlugin({
39
+ api,
40
+ options,
41
+ chain,
42
+ CHAIN_ID,
43
+ HtmlBundlerPlugin
44
+ });
45
+ }
46
+ }
47
+ );
48
+ }
49
+ });
50
+ function applyBottomHtmlPlugin({
51
+ api,
52
+ chain,
53
+ options,
54
+ CHAIN_ID,
55
+ HtmlBundlerPlugin
56
+ }) {
57
+ const { normalizedConfig: modernConfig, appContext } = options;
58
+ for (const entryName of Object.keys(api.context.entry)) {
59
+ const baseTemplateParams = {
60
+ entryName,
61
+ title: (0, import_utils.getEntryOptions)(
62
+ entryName,
63
+ modernConfig.html.title,
64
+ modernConfig.html.titleByEntries,
65
+ appContext.packageName
66
+ ),
67
+ mountId: modernConfig.html.mountId,
68
+ ...(0, import_utils.getEntryOptions)(
69
+ entryName,
70
+ modernConfig.html.templateParameters,
71
+ modernConfig.html.templateParametersByEntries,
72
+ appContext.packageName
73
+ )
74
+ };
75
+ chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
76
+ {
77
+ ...args[0] || {},
78
+ __internal__: true,
79
+ bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, import_lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(
80
+ baseTemplateParams
81
+ )
82
+ }
83
+ ]);
84
+ }
85
+ chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(import_bundlerPlugins.BottomTemplatePlugin, [HtmlBundlerPlugin]);
86
+ }
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ builderPluginAdapterHtml,
90
+ isHtmlEnabled
91
+ });
@@ -0,0 +1,140 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var adapterSSR_exports = {};
19
+ __export(adapterSSR_exports, {
20
+ builderPluginAdapterSSR: () => builderPluginAdapterSSR
21
+ });
22
+ module.exports = __toCommonJS(adapterSSR_exports);
23
+ var import_builder_shared = require("@modern-js/builder-shared");
24
+ var import_bundlerPlugins = require("../bundlerPlugins");
25
+ var import_adapterHtml = require("./adapterHtml");
26
+ const builderPluginAdapterSSR = (options) => ({
27
+ name: "builder-plugin-adapter-modern-ssr",
28
+ setup(api) {
29
+ const { normalizedConfig } = options;
30
+ api.modifyBuilderConfig((config) => {
31
+ if (isStreamingSSR(normalizedConfig)) {
32
+ return (0, import_builder_shared.mergeBuilderConfig)(config, {
33
+ html: {
34
+ inject: "body"
35
+ }
36
+ });
37
+ }
38
+ return config;
39
+ });
40
+ api.modifyBundlerChain(
41
+ (chain, { target, CHAIN_ID, isProd, HtmlPlugin: HtmlBundlerPlugin }) => {
42
+ const builderConfig = api.getNormalizedConfig();
43
+ applyRouterPlugin(chain, options);
44
+ if (["node", "service-worker"].includes(target)) {
45
+ applyFilterEntriesBySSRConfig({
46
+ isProd,
47
+ chain,
48
+ appNormalizedConfig: options.normalizedConfig
49
+ });
50
+ }
51
+ if ((0, import_adapterHtml.isHtmlEnabled)(builderConfig, target)) {
52
+ applyAsyncChunkHtmlPlugin({
53
+ chain,
54
+ modernConfig: options.normalizedConfig,
55
+ CHAIN_ID,
56
+ HtmlBundlerPlugin
57
+ });
58
+ }
59
+ }
60
+ );
61
+ }
62
+ });
63
+ const isStreamingSSR = (userConfig) => {
64
+ const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
65
+ const { server } = userConfig;
66
+ if (isStreaming(server.ssr)) {
67
+ return true;
68
+ }
69
+ if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
70
+ for (const name of Object.keys(server.ssrByEntries)) {
71
+ if (isStreaming(server.ssrByEntries[name])) {
72
+ return true;
73
+ }
74
+ }
75
+ }
76
+ return false;
77
+ };
78
+ function applyAsyncChunkHtmlPlugin({
79
+ chain,
80
+ modernConfig,
81
+ CHAIN_ID,
82
+ HtmlBundlerPlugin
83
+ }) {
84
+ if (isStreamingSSR(modernConfig)) {
85
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_bundlerPlugins.HtmlAsyncChunkPlugin, [HtmlBundlerPlugin]);
86
+ }
87
+ }
88
+ function applyRouterPlugin(chain, options) {
89
+ var _a;
90
+ const { appContext, normalizedConfig } = options;
91
+ const { entrypoints } = appContext;
92
+ const existNestedRoutes = entrypoints.some(
93
+ (entrypoint) => entrypoint.nestedRoutesEntry
94
+ );
95
+ const routerConfig = (_a = normalizedConfig == null ? void 0 : normalizedConfig.runtime) == null ? void 0 : _a.router;
96
+ const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
97
+ if (existNestedRoutes || routerManifest) {
98
+ chain.plugin("route-plugin").use(import_bundlerPlugins.RouterPlugin);
99
+ }
100
+ }
101
+ function applyFilterEntriesBySSRConfig({
102
+ isProd,
103
+ chain,
104
+ appNormalizedConfig
105
+ }) {
106
+ var _a;
107
+ const { server: serverConfig, output: outputConfig } = appNormalizedConfig;
108
+ const entries = chain.entryPoints.entries();
109
+ if (isProd && ((outputConfig == null ? void 0 : outputConfig.ssg) === true || typeof ((_a = outputConfig == null ? void 0 : outputConfig.ssg) == null ? void 0 : _a[0]) === "function")) {
110
+ return;
111
+ }
112
+ if (typeof entries === "undefined") {
113
+ throw new Error(
114
+ "No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required"
115
+ );
116
+ }
117
+ const entryNames = Object.keys(entries);
118
+ if (isProd && entryNames.length === 1 && (outputConfig == null ? void 0 : outputConfig.ssg)) {
119
+ return;
120
+ }
121
+ const ssgEntries = [];
122
+ if (isProd && (outputConfig == null ? void 0 : outputConfig.ssg)) {
123
+ const { ssg } = outputConfig;
124
+ entryNames.forEach((name) => {
125
+ if (ssg[name]) {
126
+ ssgEntries.push(name);
127
+ }
128
+ });
129
+ }
130
+ const { ssr, ssrByEntries } = serverConfig || {};
131
+ entryNames.forEach((name) => {
132
+ if (!ssgEntries.includes(name) && (ssr && (ssrByEntries == null ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries == null ? void 0 : ssrByEntries[name]))) {
133
+ chain.entryPoints.delete(name);
134
+ }
135
+ });
136
+ }
137
+ // Annotate the CommonJS export names for ESM import in node:
138
+ 0 && (module.exports = {
139
+ builderPluginAdapterSSR
140
+ });
@@ -0,0 +1,19 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var builderPlugins_exports = {};
16
+ module.exports = __toCommonJS(builderPlugins_exports);
17
+ __reExport(builderPlugins_exports, require("./adapterBasic"), module.exports);
18
+ __reExport(builderPlugins_exports, require("./adapterHtml"), module.exports);
19
+ __reExport(builderPlugins_exports, require("./adapterSSR"), module.exports);
@@ -65,7 +65,7 @@ class RouterPlugin {
65
65
  chunkGroups: true,
66
66
  chunks: true
67
67
  });
68
- const { publicPath } = stats;
68
+ const { publicPath, chunks = [] } = stats;
69
69
  const routeAssets = {};
70
70
  const { namedChunkGroups, assetsByChunkName } = stats;
71
71
  if (!namedChunkGroups || !assetsByChunkName) {
@@ -98,17 +98,23 @@ class RouterPlugin {
98
98
  const entryChunkIds = entrypointsArray.map(
99
99
  (entrypoint) => entrypoint[0]
100
100
  );
101
- const entryChunks = [...compilation.chunks].filter((chunk) => {
102
- return entryChunkIds.includes(chunk.name);
101
+ const entryChunks = [...chunks].filter((chunk) => {
102
+ var _a;
103
+ return (_a = chunk.names) == null ? void 0 : _a.some((name) => entryChunkIds.includes(name));
103
104
  });
104
105
  const entryChunkFiles = entryChunks.map(
105
- (chunk) => [...chunk.files].find((fname) => fname.includes(".js"))
106
+ (chunk) => [...chunk.files || []].find((fname) => fname.includes(".js"))
106
107
  );
107
108
  for (const file of entryChunkFiles) {
108
109
  const asset = compilation.assets[file];
109
110
  const newContent = `${injectedContent}${asset.source().toString()}`;
110
111
  newAssetsMap.set(import_path.default.join(outputPath, file), newContent);
111
- compilation.updateAsset(file, new RawSource(newContent));
112
+ compilation.updateAsset(
113
+ file,
114
+ new RawSource(newContent),
115
+ // FIXME: The arguments third of updatgeAsset is a optional function in webpack.
116
+ void 0
117
+ );
112
118
  }
113
119
  const filename = import_path.default.join(outputPath, import_utils.ROUTE_MINIFEST_FILE);
114
120
  await import_utils.fs.ensureFile(filename);
@@ -0,0 +1,19 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var bundlerPlugins_exports = {};
16
+ module.exports = __toCommonJS(bundlerPlugins_exports);
17
+ __reExport(bundlerPlugins_exports, require("./HtmlAsyncChunkPlugin"), module.exports);
18
+ __reExport(bundlerPlugins_exports, require("./HtmlBottomTemplate"), module.exports);
19
+ __reExport(bundlerPlugins_exports, require("./RouterPlugin"), module.exports);
@@ -16,4 +16,4 @@ var shared_exports = {};
16
16
  module.exports = __toCommonJS(shared_exports);
17
17
  __reExport(shared_exports, require("./createCopyPattern"), module.exports);
18
18
  __reExport(shared_exports, require("./types"), module.exports);
19
- __reExport(shared_exports, require("./builderPlugins/adapterModern"), module.exports);
19
+ __reExport(shared_exports, require("./builderPlugins"), module.exports);
package/dist/cjs/index.js CHANGED
@@ -53,7 +53,7 @@ const upgradeModel = import_utils.Import.lazy(
53
53
  const devCommand = async (program, api) => {
54
54
  const runner = api.useHookRunners();
55
55
  const devToolMetas = await runner.registerDev();
56
- const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).action(async (options) => {
56
+ const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).option("--web-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.webOnly)).action(async (options) => {
57
57
  const { dev } = await Promise.resolve().then(() => __toESM(require("./commands/dev")));
58
58
  await dev(api, options);
59
59
  });
@@ -30,6 +30,7 @@ const EN_LOCALE = {
30
30
  describe: "start dev server",
31
31
  entry: "compiler by entry",
32
32
  apiOnly: "start api server only",
33
+ webOnly: "start web server only",
33
34
  selectEntry: "Please select the entry that needs to be built",
34
35
  requireEntry: "You must choose at least one entry"
35
36
  },
@@ -30,6 +30,7 @@ const ZH_LOCALE = {
30
30
  describe: "本地开发命令",
31
31
  entry: "指定入口,编译特定的页面",
32
32
  apiOnly: "仅启动 API 接口服务",
33
+ webOnly: "仅启动 Web 服务",
33
34
  selectEntry: "请选择需要构建的入口",
34
35
  requireEntry: "请至少选择一个入口"
35
36
  },