@modern-js/app-tools 2.3.1-alpha.2 → 2.5.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 (430) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +14 -18
  3. package/dist/cjs/analyze/constants.js +100 -0
  4. package/dist/cjs/analyze/generateCode.js +251 -0
  5. package/dist/cjs/analyze/getBundleEntry.js +101 -0
  6. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +225 -0
  7. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +221 -0
  8. package/dist/cjs/analyze/getClientRoutes/index.js +30 -0
  9. package/dist/cjs/analyze/getClientRoutes/utils.js +58 -0
  10. package/dist/cjs/analyze/getFileSystemEntry.js +131 -0
  11. package/dist/cjs/analyze/getHtmlTemplate.js +124 -0
  12. package/dist/cjs/analyze/getServerRoutes.js +174 -0
  13. package/dist/cjs/analyze/index.js +294 -0
  14. package/dist/cjs/analyze/isDefaultExportFunction.js +71 -0
  15. package/dist/cjs/analyze/makeLegalIdentifier.js +36 -0
  16. package/dist/cjs/analyze/nestedRoutes.js +179 -0
  17. package/dist/cjs/analyze/templates.js +330 -0
  18. package/dist/cjs/analyze/utils.js +152 -0
  19. package/dist/cjs/builder/builder-rspack/index.js +31 -0
  20. package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  21. package/dist/cjs/builder/builder-webpack/index.js +78 -0
  22. package/dist/cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js +120 -0
  23. package/dist/cjs/builder/builder-webpack/webpackPlugins/index.js +17 -0
  24. package/dist/cjs/builder/generator/createBuilderOptions.js +47 -0
  25. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +49 -0
  26. package/dist/cjs/builder/generator/getBuilderTargets.js +39 -0
  27. package/dist/cjs/builder/generator/index.js +58 -0
  28. package/dist/cjs/builder/index.js +46 -0
  29. package/dist/cjs/builder/shared/builderPlugins/adapterModern.js +230 -0
  30. package/dist/{js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js → cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
  31. package/dist/{js/node/builder/webpackPlugins/htmlBottomTemplate.js → cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
  32. package/dist/{js/node/builder/share.js → cjs/builder/shared/createCopyPattern.js} +3 -3
  33. package/dist/cjs/builder/shared/index.js +19 -0
  34. package/dist/{js/node/builder → cjs/builder/shared}/loaders/serverModuleLoader.js +0 -0
  35. package/dist/cjs/builder/shared/types.js +15 -0
  36. package/dist/cjs/commands/build.js +75 -0
  37. package/dist/cjs/commands/deploy.js +31 -0
  38. package/dist/cjs/commands/dev.js +91 -0
  39. package/dist/cjs/commands/index.js +19 -0
  40. package/dist/cjs/commands/inspect.js +41 -0
  41. package/dist/cjs/commands/serve.js +63 -0
  42. package/dist/cjs/config/default.js +186 -0
  43. package/dist/cjs/config/index.js +19 -0
  44. package/dist/{js/node/config/initial → cjs/config/initialize}/index.js +10 -16
  45. package/dist/cjs/config/initialize/inits.js +161 -0
  46. package/dist/{js/node/config/initial → cjs/config/legacy}/createHtmlConfig.js +0 -0
  47. package/dist/{js/node/config/initial → cjs/config/legacy}/createOutputConfig.js +0 -0
  48. package/dist/{js/node/config/initial → cjs/config/legacy}/createSourceConfig.js +0 -0
  49. package/dist/{js/node/config/initial → cjs/config/legacy}/createToolsConfig.js +0 -0
  50. package/dist/{js/node/config/initial/transformNormalizedConfig.js → cjs/config/legacy/index.js} +8 -3
  51. package/dist/cjs/defineConfig.js +33 -0
  52. package/dist/cjs/exports/server.js +27 -0
  53. package/dist/cjs/hooks.js +54 -0
  54. package/dist/cjs/index.js +198 -0
  55. package/dist/cjs/initialize/index.js +102 -0
  56. package/dist/cjs/locale/en.js +59 -0
  57. package/dist/cjs/locale/index.js +33 -0
  58. package/dist/cjs/locale/zh.js +59 -0
  59. package/dist/cjs/schema/Schema.js +63 -0
  60. package/dist/cjs/schema/index.js +118 -0
  61. package/dist/cjs/schema/legacy.js +169 -0
  62. package/dist/cjs/types/config/deploy.js +15 -0
  63. package/dist/cjs/types/config/dev.js +15 -0
  64. package/dist/cjs/types/config/experiments.js +15 -0
  65. package/dist/cjs/types/config/html.js +15 -0
  66. package/dist/cjs/types/config/index.js +17 -0
  67. package/dist/cjs/types/config/output.js +15 -0
  68. package/dist/cjs/types/config/performance.js +15 -0
  69. package/dist/cjs/types/config/security.js +15 -0
  70. package/dist/cjs/types/config/source.js +15 -0
  71. package/dist/cjs/types/config/tools.js +15 -0
  72. package/dist/cjs/types/hooks.js +15 -0
  73. package/dist/cjs/types/index.js +19 -0
  74. package/dist/cjs/types/legacyConfig/deploy.js +15 -0
  75. package/dist/cjs/types/legacyConfig/dev.js +15 -0
  76. package/dist/cjs/types/legacyConfig/index.js +15 -0
  77. package/dist/cjs/types/legacyConfig/output.js +15 -0
  78. package/dist/cjs/types/legacyConfig/source.js +15 -0
  79. package/dist/cjs/types/legacyConfig/tools.js +15 -0
  80. package/dist/cjs/types/utils.js +15 -0
  81. package/dist/cjs/utils/config.js +115 -0
  82. package/dist/cjs/utils/createServer.js +70 -0
  83. package/dist/cjs/utils/env.js +38 -0
  84. package/dist/cjs/utils/generateWatchFiles.js +63 -0
  85. package/dist/cjs/utils/getSelectedEntries.js +61 -0
  86. package/dist/cjs/utils/getServerInternalPlugins.js +41 -0
  87. package/dist/cjs/utils/language.js +31 -0
  88. package/dist/cjs/utils/printInstructions.js +34 -0
  89. package/dist/cjs/utils/restart.js +45 -0
  90. package/dist/cjs/utils/routes.js +39 -0
  91. package/dist/cjs/utils/types.js +15 -0
  92. package/dist/esm/analyze/constants.js +42 -0
  93. package/dist/esm/analyze/generateCode.js +486 -0
  94. package/dist/esm/analyze/getBundleEntry.js +64 -0
  95. package/dist/esm/analyze/getClientRoutes/getRoutes.js +233 -0
  96. package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
  97. package/dist/esm/analyze/getClientRoutes/index.js +3 -0
  98. package/dist/esm/analyze/getClientRoutes/utils.js +23 -0
  99. package/dist/esm/analyze/getFileSystemEntry.js +107 -0
  100. package/dist/esm/analyze/getHtmlTemplate.js +302 -0
  101. package/dist/esm/analyze/getServerRoutes.js +224 -0
  102. package/dist/esm/analyze/index.js +703 -0
  103. package/dist/esm/analyze/isDefaultExportFunction.js +47 -0
  104. package/dist/esm/analyze/makeLegalIdentifier.js +13 -0
  105. package/dist/esm/analyze/nestedRoutes.js +409 -0
  106. package/dist/esm/analyze/templates.js +466 -0
  107. package/dist/esm/analyze/utils.js +374 -0
  108. package/dist/esm/builder/builder-rspack/index.js +6 -0
  109. package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  110. package/dist/esm/builder/builder-webpack/index.js +301 -0
  111. package/dist/esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js +346 -0
  112. package/dist/esm/builder/builder-webpack/webpackPlugins/index.js +1 -0
  113. package/dist/esm/builder/generator/createBuilderOptions.js +41 -0
  114. package/dist/esm/builder/generator/createBuilderProviderConfig.js +70 -0
  115. package/dist/esm/builder/generator/getBuilderTargets.js +16 -0
  116. package/dist/esm/builder/generator/index.js +199 -0
  117. package/dist/esm/builder/index.js +175 -0
  118. package/dist/esm/builder/shared/builderPlugins/adapterModern.js +300 -0
  119. package/dist/{js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js → esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
  120. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +72 -0
  121. package/dist/{js/treeshaking/builder/share.js → esm/builder/shared/createCopyPattern.js} +0 -0
  122. package/dist/esm/builder/shared/index.js +3 -0
  123. package/dist/{js/treeshaking/builder → esm/builder/shared}/loaders/serverModuleLoader.js +0 -0
  124. package/dist/esm/builder/shared/types.js +1 -0
  125. package/dist/esm/commands/build.js +291 -0
  126. package/dist/esm/commands/deploy.js +154 -0
  127. package/dist/esm/commands/dev.js +301 -0
  128. package/dist/esm/commands/index.js +3 -0
  129. package/dist/esm/commands/inspect.js +149 -0
  130. package/dist/esm/commands/serve.js +199 -0
  131. package/dist/esm/config/default.js +210 -0
  132. package/dist/esm/config/index.js +3 -0
  133. package/dist/esm/config/initialize/index.js +10 -0
  134. package/dist/esm/config/initialize/inits.js +211 -0
  135. package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
  136. package/dist/esm/config/legacy/createOutputConfig.js +41 -0
  137. package/dist/esm/config/legacy/createSourceConfig.js +42 -0
  138. package/dist/esm/config/legacy/createToolsConfig.js +23 -0
  139. package/dist/{js/treeshaking/config/initial/transformNormalizedConfig.js → esm/config/legacy/index.js} +4 -1
  140. package/dist/esm/defineConfig.js +61 -0
  141. package/dist/esm/exports/server.js +2 -0
  142. package/dist/esm/hooks.js +29 -0
  143. package/dist/esm/index.js +713 -0
  144. package/dist/esm/initialize/index.js +284 -0
  145. package/dist/esm/locale/en.js +38 -0
  146. package/dist/esm/locale/index.js +9 -0
  147. package/dist/esm/locale/zh.js +38 -0
  148. package/dist/esm/schema/Schema.js +273 -0
  149. package/dist/esm/schema/index.js +181 -0
  150. package/dist/esm/schema/legacy.js +337 -0
  151. package/dist/esm/types/config/deploy.js +1 -0
  152. package/dist/esm/types/config/dev.js +1 -0
  153. package/dist/esm/types/config/experiments.js +1 -0
  154. package/dist/esm/types/config/html.js +1 -0
  155. package/dist/esm/types/config/index.js +1 -0
  156. package/dist/esm/types/config/output.js +1 -0
  157. package/dist/esm/types/config/performance.js +1 -0
  158. package/dist/esm/types/config/security.js +1 -0
  159. package/dist/esm/types/config/source.js +1 -0
  160. package/dist/esm/types/config/tools.js +1 -0
  161. package/dist/esm/types/hooks.js +1 -0
  162. package/dist/esm/types/index.js +3 -0
  163. package/dist/esm/types/legacyConfig/deploy.js +1 -0
  164. package/dist/esm/types/legacyConfig/dev.js +1 -0
  165. package/dist/esm/types/legacyConfig/index.js +1 -0
  166. package/dist/esm/types/legacyConfig/output.js +1 -0
  167. package/dist/esm/types/legacyConfig/source.js +1 -0
  168. package/dist/esm/types/legacyConfig/tools.js +1 -0
  169. package/dist/esm/types/utils.js +1 -0
  170. package/dist/esm/utils/config.js +302 -0
  171. package/dist/esm/utils/createServer.js +258 -0
  172. package/dist/esm/utils/env.js +13 -0
  173. package/dist/esm/utils/generateWatchFiles.js +214 -0
  174. package/dist/esm/utils/getSelectedEntries.js +186 -0
  175. package/dist/esm/utils/getServerInternalPlugins.js +210 -0
  176. package/dist/esm/utils/language.js +6 -0
  177. package/dist/esm/utils/printInstructions.js +152 -0
  178. package/dist/esm/utils/restart.js +187 -0
  179. package/dist/esm/utils/routes.js +153 -0
  180. package/dist/esm/utils/types.js +1 -0
  181. package/dist/esm-node/analyze/constants.js +56 -0
  182. package/dist/esm-node/analyze/generateCode.js +227 -0
  183. package/dist/esm-node/analyze/getBundleEntry.js +77 -0
  184. package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +201 -0
  185. package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +197 -0
  186. package/dist/esm-node/analyze/getClientRoutes/index.js +6 -0
  187. package/dist/esm-node/analyze/getClientRoutes/utils.js +31 -0
  188. package/dist/esm-node/analyze/getFileSystemEntry.js +109 -0
  189. package/dist/esm-node/analyze/getHtmlTemplate.js +95 -0
  190. package/dist/esm-node/analyze/getServerRoutes.js +154 -0
  191. package/dist/esm-node/analyze/index.js +285 -0
  192. package/dist/esm-node/analyze/isDefaultExportFunction.js +42 -0
  193. package/dist/esm-node/analyze/makeLegalIdentifier.js +13 -0
  194. package/dist/esm-node/analyze/nestedRoutes.js +150 -0
  195. package/dist/esm-node/analyze/templates.js +297 -0
  196. package/dist/esm-node/analyze/utils.js +121 -0
  197. package/dist/esm-node/builder/builder-rspack/index.js +8 -0
  198. package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
  199. package/dist/esm-node/builder/builder-webpack/index.js +51 -0
  200. package/dist/esm-node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +96 -0
  201. package/dist/esm-node/builder/builder-webpack/webpackPlugins/index.js +1 -0
  202. package/dist/esm-node/builder/generator/createBuilderOptions.js +24 -0
  203. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +26 -0
  204. package/dist/esm-node/builder/generator/getBuilderTargets.js +21 -0
  205. package/dist/esm-node/builder/generator/index.js +29 -0
  206. package/dist/esm-node/builder/index.js +17 -0
  207. package/dist/esm-node/builder/shared/builderPlugins/adapterModern.js +202 -0
  208. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
  209. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
  210. package/dist/{js/modern/builder/share.js → esm-node/builder/shared/createCopyPattern.js} +0 -0
  211. package/dist/esm-node/builder/shared/index.js +3 -0
  212. package/dist/{js/modern/builder → esm-node/builder/shared}/loaders/serverModuleLoader.js +0 -0
  213. package/dist/esm-node/builder/shared/types.js +0 -0
  214. package/dist/esm-node/commands/build.js +52 -0
  215. package/dist/esm-node/commands/deploy.js +8 -0
  216. package/dist/esm-node/commands/dev.js +72 -0
  217. package/dist/esm-node/commands/index.js +3 -0
  218. package/dist/esm-node/commands/inspect.js +18 -0
  219. package/dist/esm-node/commands/serve.js +34 -0
  220. package/dist/esm-node/config/default.js +162 -0
  221. package/dist/esm-node/config/index.js +3 -0
  222. package/dist/esm-node/config/initialize/index.js +12 -0
  223. package/dist/esm-node/config/initialize/inits.js +136 -0
  224. package/dist/{js/modern/config/initial → esm-node/config/legacy}/createHtmlConfig.js +0 -0
  225. package/dist/{js/modern/config/initial → esm-node/config/legacy}/createOutputConfig.js +0 -0
  226. package/dist/{js/modern/config/initial → esm-node/config/legacy}/createSourceConfig.js +0 -0
  227. package/dist/{js/modern/config/initial → esm-node/config/legacy}/createToolsConfig.js +0 -0
  228. package/dist/{js/modern/config/initial/transformNormalizedConfig.js → esm-node/config/legacy/index.js} +4 -0
  229. package/dist/esm-node/defineConfig.js +9 -0
  230. package/dist/esm-node/exports/server.js +4 -0
  231. package/dist/esm-node/hooks.js +35 -0
  232. package/dist/esm-node/index.js +172 -0
  233. package/dist/esm-node/initialize/index.js +91 -0
  234. package/dist/esm-node/locale/en.js +36 -0
  235. package/dist/esm-node/locale/index.js +9 -0
  236. package/dist/esm-node/locale/zh.js +36 -0
  237. package/dist/esm-node/schema/Schema.js +40 -0
  238. package/dist/esm-node/schema/index.js +88 -0
  239. package/dist/esm-node/schema/legacy.js +148 -0
  240. package/dist/esm-node/types/config/deploy.js +0 -0
  241. package/dist/esm-node/types/config/dev.js +0 -0
  242. package/dist/esm-node/types/config/experiments.js +0 -0
  243. package/dist/esm-node/types/config/html.js +0 -0
  244. package/dist/esm-node/types/config/index.js +1 -0
  245. package/dist/esm-node/types/config/output.js +0 -0
  246. package/dist/esm-node/types/config/performance.js +0 -0
  247. package/dist/esm-node/types/config/security.js +0 -0
  248. package/dist/esm-node/types/config/source.js +0 -0
  249. package/dist/esm-node/types/config/tools.js +0 -0
  250. package/dist/esm-node/types/hooks.js +0 -0
  251. package/dist/esm-node/types/index.js +3 -0
  252. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  253. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  254. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  255. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  256. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  257. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  258. package/dist/esm-node/types/utils.js +0 -0
  259. package/dist/esm-node/utils/config.js +88 -0
  260. package/dist/esm-node/utils/createServer.js +37 -0
  261. package/dist/esm-node/utils/env.js +15 -0
  262. package/dist/esm-node/utils/generateWatchFiles.js +33 -0
  263. package/dist/esm-node/utils/getSelectedEntries.js +38 -0
  264. package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
  265. package/dist/esm-node/utils/language.js +8 -0
  266. package/dist/esm-node/utils/printInstructions.js +11 -0
  267. package/dist/esm-node/utils/restart.js +22 -0
  268. package/dist/esm-node/utils/routes.js +10 -0
  269. package/dist/esm-node/utils/types.js +0 -0
  270. package/dist/js/modern/analyze/index.js +45 -48
  271. package/dist/js/modern/analyze/nestedRoutes.js +1 -10
  272. package/dist/js/modern/builder/builder-rspack/index.js +8 -0
  273. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
  274. package/dist/js/modern/builder/builder-webpack/index.js +93 -0
  275. package/dist/js/modern/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
  276. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
  277. package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
  278. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
  279. package/dist/js/modern/builder/generator/getBuilderTargets.js +12 -0
  280. package/dist/js/modern/builder/generator/index.js +53 -0
  281. package/dist/js/modern/builder/index.js +13 -133
  282. package/dist/js/modern/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +81 -111
  283. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
  284. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
  285. package/dist/js/modern/builder/shared/createCopyPattern.js +46 -0
  286. package/dist/js/modern/builder/shared/index.js +3 -0
  287. package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +7 -0
  288. package/dist/js/modern/builder/shared/types.js +0 -0
  289. package/dist/js/modern/config/default.js +2 -2
  290. package/dist/js/modern/config/index.js +3 -8
  291. package/dist/js/modern/config/initialize/index.js +12 -0
  292. package/dist/js/modern/config/{initial → initialize}/inits.js +4 -2
  293. package/dist/js/modern/config/legacy/createHtmlConfig.js +35 -0
  294. package/dist/js/modern/config/legacy/createOutputConfig.js +68 -0
  295. package/dist/js/modern/config/legacy/createSourceConfig.js +39 -0
  296. package/dist/js/modern/config/legacy/createToolsConfig.js +42 -0
  297. package/dist/js/modern/config/legacy/index.js +51 -0
  298. package/dist/js/modern/index.js +18 -8
  299. package/dist/js/modern/initialize/index.js +36 -28
  300. package/dist/js/modern/locale/zh.js +1 -1
  301. package/dist/js/modern/types/utils.js +0 -0
  302. package/dist/js/node/analyze/index.js +46 -49
  303. package/dist/js/node/analyze/nestedRoutes.js +1 -10
  304. package/dist/js/node/builder/builder-rspack/index.js +31 -0
  305. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  306. package/dist/js/node/builder/builder-webpack/index.js +118 -0
  307. package/dist/js/node/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +7 -5
  308. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
  309. package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
  310. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
  311. package/dist/js/node/builder/generator/getBuilderTargets.js +35 -0
  312. package/dist/js/node/builder/generator/index.js +82 -0
  313. package/dist/js/node/builder/index.js +14 -123
  314. package/dist/js/node/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +86 -115
  315. package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +50 -0
  316. package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +57 -0
  317. package/dist/js/node/builder/shared/createCopyPattern.js +75 -0
  318. package/dist/js/node/builder/shared/index.js +19 -0
  319. package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +28 -0
  320. package/dist/js/node/builder/shared/types.js +15 -0
  321. package/dist/js/node/config/default.js +2 -2
  322. package/dist/js/node/config/index.js +4 -19
  323. package/dist/js/node/config/initialize/index.js +35 -0
  324. package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
  325. package/dist/js/node/config/legacy/createHtmlConfig.js +58 -0
  326. package/dist/js/node/config/legacy/createOutputConfig.js +91 -0
  327. package/dist/js/node/config/legacy/createSourceConfig.js +62 -0
  328. package/dist/js/node/config/legacy/createToolsConfig.js +65 -0
  329. package/dist/js/node/config/legacy/index.js +75 -0
  330. package/dist/js/node/index.js +18 -8
  331. package/dist/js/node/initialize/index.js +35 -28
  332. package/dist/js/node/locale/zh.js +1 -1
  333. package/dist/js/node/types/utils.js +15 -0
  334. package/dist/js/treeshaking/analyze/index.js +135 -130
  335. package/dist/js/treeshaking/analyze/nestedRoutes.js +1 -10
  336. package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
  337. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
  338. package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
  339. package/dist/js/treeshaking/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +1 -1
  340. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
  341. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
  342. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
  343. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +12 -0
  344. package/dist/js/treeshaking/builder/generator/index.js +199 -0
  345. package/dist/js/treeshaking/builder/index.js +29 -228
  346. package/dist/js/treeshaking/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +103 -156
  347. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +110 -0
  348. package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +0 -0
  349. package/dist/js/treeshaking/builder/shared/createCopyPattern.js +40 -0
  350. package/dist/js/treeshaking/builder/shared/index.js +3 -0
  351. package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +5 -0
  352. package/dist/js/treeshaking/builder/shared/types.js +1 -0
  353. package/dist/js/treeshaking/config/default.js +2 -2
  354. package/dist/js/treeshaking/config/index.js +3 -3
  355. package/dist/js/treeshaking/config/initialize/index.js +10 -0
  356. package/dist/js/treeshaking/config/{initial → initialize}/inits.js +4 -2
  357. package/dist/js/treeshaking/config/{initial → legacy}/createHtmlConfig.js +0 -0
  358. package/dist/js/treeshaking/config/{initial → legacy}/createOutputConfig.js +0 -0
  359. package/dist/js/treeshaking/config/{initial → legacy}/createSourceConfig.js +0 -0
  360. package/dist/js/treeshaking/config/{initial → legacy}/createToolsConfig.js +0 -0
  361. package/dist/js/treeshaking/config/legacy/index.js +38 -0
  362. package/dist/js/treeshaking/index.js +19 -12
  363. package/dist/js/treeshaking/initialize/index.js +34 -26
  364. package/dist/js/treeshaking/locale/zh.js +1 -1
  365. package/dist/js/treeshaking/types/utils.js +1 -0
  366. package/dist/types/analyze/generateCode.d.ts +1 -1
  367. package/dist/types/analyze/getBundleEntry.d.ts +1 -1
  368. package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
  369. package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
  370. package/dist/types/analyze/getServerRoutes.d.ts +1 -1
  371. package/dist/types/analyze/index.d.ts +5 -1
  372. package/dist/types/analyze/templates.d.ts +3 -1
  373. package/dist/types/builder/builder-rspack/index.d.ts +2 -0
  374. package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
  375. package/dist/types/builder/builder-webpack/index.d.ts +4 -0
  376. package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
  377. package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
  378. package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
  379. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
  380. package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
  381. package/dist/types/builder/generator/index.d.ts +17 -0
  382. package/dist/types/builder/index.d.ts +1 -18
  383. package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
  384. package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
  385. package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
  386. package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
  387. package/dist/types/builder/shared/index.d.ts +3 -0
  388. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
  389. package/dist/types/builder/shared/types.d.ts +16 -0
  390. package/dist/types/commands/build.d.ts +1 -1
  391. package/dist/types/commands/deploy.d.ts +1 -1
  392. package/dist/types/commands/dev.d.ts +1 -1
  393. package/dist/types/commands/inspect.d.ts +1 -1
  394. package/dist/types/commands/serve.d.ts +1 -1
  395. package/dist/types/config/default.d.ts +1 -1
  396. package/dist/types/config/index.d.ts +3 -2
  397. package/dist/types/config/initialize/index.d.ts +2 -0
  398. package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
  399. package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
  400. package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
  401. package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
  402. package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
  403. package/dist/types/config/legacy/index.d.ts +3 -0
  404. package/dist/types/defineConfig.d.ts +2 -2
  405. package/dist/types/index.d.ts +7 -3
  406. package/dist/types/initialize/index.d.ts +6 -2
  407. package/dist/types/types/config/deploy.d.ts +1 -2
  408. package/dist/types/types/config/dev.d.ts +2 -3
  409. package/dist/types/types/config/experiments.d.ts +1 -2
  410. package/dist/types/types/config/html.d.ts +5 -3
  411. package/dist/types/types/config/index.d.ts +41 -48
  412. package/dist/types/types/config/output.d.ts +8 -3
  413. package/dist/types/types/config/performance.d.ts +6 -3
  414. package/dist/types/types/config/security.d.ts +3 -3
  415. package/dist/types/types/config/source.d.ts +7 -3
  416. package/dist/types/types/config/tools.d.ts +10 -4
  417. package/dist/types/types/hooks.d.ts +6 -4
  418. package/dist/types/types/index.d.ts +19 -7
  419. package/dist/types/types/utils.d.ts +7 -0
  420. package/dist/types/utils/config.d.ts +1 -1
  421. package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
  422. package/dist/types/utils/printInstructions.d.ts +1 -1
  423. package/package.json +40 -32
  424. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
  425. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
  426. package/dist/js/modern/config/initial/index.js +0 -16
  427. package/dist/js/treeshaking/config/initial/index.js +0 -12
  428. package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
  429. package/dist/types/config/initial/index.d.ts +0 -4
  430. package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
@@ -38,25 +38,39 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
38
38
  mod
39
39
  ));
40
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
- var compatModern_exports = {};
42
- __export(compatModern_exports, {
43
- PluginCompatModern: () => PluginCompatModern
41
+ var adapterModern_exports = {};
42
+ __export(adapterModern_exports, {
43
+ applyCallbacks: () => applyCallbacks,
44
+ builderPluginAdapterModern: () => builderPluginAdapterModern
44
45
  });
45
- module.exports = __toCommonJS(compatModern_exports);
46
- var import_path = require("path");
46
+ module.exports = __toCommonJS(adapterModern_exports);
47
47
  var import_builder_shared = require("@modern-js/builder-shared");
48
- var import_lodash = require("@modern-js/utils/lodash");
49
- var import_html_webpack_plugin = __toESM(require("@modern-js/builder-webpack-provider/html-webpack-plugin"));
50
48
  var import_utils = require("@modern-js/utils");
51
- var import_htmlBottomTemplate = require("../webpackPlugins/htmlBottomTemplate");
52
- var import_htmlAsyncChunkPlugin = require("../webpackPlugins/htmlAsyncChunkPlugin");
53
- var import_share = require("../share");
54
- var import_routerPlugin = __toESM(require("../webpackPlugins/routerPlugin"));
55
- const PluginCompatModern = (appContext, modernConfig, options) => ({
56
- name: "builder-plugin-compat-modern",
49
+ var import_html_webpack_plugin = __toESM(require("@modern-js/builder-webpack-provider/html-webpack-plugin"));
50
+ var import_lodash = require("@modern-js/utils/lodash");
51
+ var import_HtmlAsyncChunkPlugin = require("../bundlerPlugins/HtmlAsyncChunkPlugin");
52
+ var import_HtmlBottomTemplate = require("../bundlerPlugins/HtmlBottomTemplate");
53
+ const isStreamingSSR = (userConfig) => {
54
+ const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
55
+ const { server } = userConfig;
56
+ if (isStreaming(server.ssr)) {
57
+ return true;
58
+ }
59
+ if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
60
+ for (const name of Object.keys(server.ssrByEntries)) {
61
+ if (isStreaming(server.ssrByEntries[name])) {
62
+ return true;
63
+ }
64
+ }
65
+ }
66
+ return false;
67
+ };
68
+ const builderPluginAdapterModern = (options) => ({
69
+ name: "builder-plugin-adapter-modern",
57
70
  setup(api) {
71
+ const { normalizedConfig, appContext } = options;
58
72
  api.modifyBuilderConfig((config) => {
59
- if (isStreamingSSR(modernConfig)) {
73
+ if (isStreamingSSR(normalizedConfig)) {
60
74
  return (0, import_builder_shared.mergeBuilderConfig)(config, {
61
75
  html: {
62
76
  inject: "body"
@@ -65,9 +79,8 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
65
79
  }
66
80
  return config;
67
81
  });
68
- api.modifyWebpackChain((chain, { target, CHAIN_ID, isProd }) => {
69
- var _a;
70
- const builderNormalizedConfig = api.getNormalizedConfig();
82
+ api.modifyBundlerChain((chain, { target, CHAIN_ID, isProd }) => {
83
+ const builderConfig = api.getNormalizedConfig();
71
84
  if (target === "node") {
72
85
  chain.name("server");
73
86
  } else if (target === "modern-web") {
@@ -75,61 +88,33 @@ const PluginCompatModern = (appContext, modernConfig, options) => ({
75
88
  } else {
76
89
  chain.name("client");
77
90
  }
78
- chain.resolve.modules.add("node_modules").add((0, import_path.join)(api.context.rootPath, "node_modules"));
79
91
  if (target === "node") {
80
- applyNodeCompat(chain, modernConfig, isProd);
92
+ applyNodeCompat(chain, normalizedConfig, isProd);
81
93
  }
82
- if (isHtmlEnabled(builderNormalizedConfig, target)) {
83
- applyBottomHtmlWebpackPlugin({
94
+ if (isHtmlEnabled(builderConfig, target)) {
95
+ applyBottomHtmlPlugin({
84
96
  api,
85
97
  chain,
86
- CHAIN_ID,
98
+ modernConfig: normalizedConfig,
87
99
  appContext,
88
- modernConfig
100
+ CHAIN_ID
89
101
  });
90
102
  applyAsyncChunkHtmlPlugin({
91
103
  chain,
92
- CHAIN_ID,
93
- modernConfig
104
+ modernConfig: normalizedConfig,
105
+ CHAIN_ID
94
106
  });
95
107
  }
96
- if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
97
- const defaultCopyPattern = (0, import_share.createCopyPattern)(
98
- appContext,
99
- modernConfig,
100
- "public",
101
- chain
102
- );
103
- chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
104
- var _a2;
105
- return [
106
- {
107
- patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
108
- }
109
- ];
110
- });
111
- }
112
- const { entrypoints } = appContext;
113
- const existNestedRoutes = entrypoints.some(
114
- (entrypoint) => entrypoint.nestedRoutesEntry
115
- );
116
- const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
117
- const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
118
- if (existNestedRoutes || routerManifest) {
119
- chain.plugin("route-plugin").use(import_routerPlugin.default);
120
- }
121
108
  if (target !== "node") {
122
109
  const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
123
110
  chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
124
111
  chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
125
112
  }
126
- function isHtmlEnabled(config, target2) {
127
- var _a2;
128
- return ((_a2 = config.tools) == null ? void 0 : _a2.htmlPlugin) !== false && target2 !== "node" && target2 !== "web-worker";
129
- }
130
113
  });
131
- if (options) {
132
- applyCallbacks(api, options);
114
+ applyCallbacks(api, options);
115
+ function isHtmlEnabled(config, target) {
116
+ var _a;
117
+ return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "web-worker";
133
118
  }
134
119
  }
135
120
  });
@@ -143,6 +128,49 @@ function applyCallbacks(api, options) {
143
128
  options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
144
129
  options.onExit && api.onExit(options.onExit);
145
130
  }
131
+ function applyBottomHtmlPlugin({
132
+ api,
133
+ chain,
134
+ modernConfig,
135
+ appContext,
136
+ CHAIN_ID
137
+ }) {
138
+ for (const entryName of Object.keys(api.context.entry)) {
139
+ const baseTemplateParams = __spreadValues({
140
+ entryName,
141
+ title: (0, import_utils.getEntryOptions)(
142
+ entryName,
143
+ modernConfig.html.title,
144
+ modernConfig.html.titleByEntries,
145
+ appContext.packageName
146
+ ),
147
+ mountId: modernConfig.html.mountId
148
+ }, (0, import_utils.getEntryOptions)(
149
+ entryName,
150
+ modernConfig.html.templateParameters,
151
+ modernConfig.html.templateParametersByEntries,
152
+ appContext.packageName
153
+ ));
154
+ chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
155
+ __spreadProps(__spreadValues({}, args[0] || {}), {
156
+ __internal__: true,
157
+ bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, import_lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(
158
+ baseTemplateParams
159
+ )
160
+ })
161
+ ]);
162
+ }
163
+ chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(import_HtmlBottomTemplate.BottomTemplatePlugin, [import_html_webpack_plugin.default]);
164
+ }
165
+ function applyAsyncChunkHtmlPlugin({
166
+ chain,
167
+ modernConfig,
168
+ CHAIN_ID
169
+ }) {
170
+ if (isStreamingSSR(modernConfig)) {
171
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_HtmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [import_html_webpack_plugin.default]);
172
+ }
173
+ }
146
174
  function applyNodeCompat(chain, modernConfig, isProd) {
147
175
  for (const ext of [
148
176
  ".node.js",
@@ -194,65 +222,8 @@ function applyNodeCompat(chain, modernConfig, isProd) {
194
222
  });
195
223
  }
196
224
  }
197
- function applyBottomHtmlWebpackPlugin({
198
- api,
199
- chain,
200
- modernConfig,
201
- appContext,
202
- CHAIN_ID
203
- }) {
204
- for (const entryName of Object.keys(api.context.entry)) {
205
- const baseTemplateParams = __spreadValues({
206
- entryName,
207
- title: (0, import_utils.getEntryOptions)(
208
- entryName,
209
- modernConfig.html.title,
210
- modernConfig.html.titleByEntries,
211
- appContext.packageName
212
- ),
213
- mountId: modernConfig.html.mountId
214
- }, (0, import_utils.getEntryOptions)(
215
- entryName,
216
- modernConfig.html.templateParameters,
217
- modernConfig.html.templateParametersByEntries,
218
- appContext.packageName
219
- ));
220
- chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
221
- __spreadProps(__spreadValues({}, args[0] || {}), {
222
- __internal__: true,
223
- bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, import_lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(
224
- baseTemplateParams
225
- )
226
- })
227
- ]);
228
- }
229
- chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(import_htmlBottomTemplate.BottomTemplatePlugin, [import_html_webpack_plugin.default]);
230
- }
231
- const isStreamingSSR = (userConfig) => {
232
- const isStreaming = (ssr) => ssr && typeof ssr === "object" && ssr.mode === "stream";
233
- const { server } = userConfig;
234
- if (isStreaming(server.ssr)) {
235
- return true;
236
- }
237
- if ((server == null ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
238
- for (const name of Object.keys(server.ssrByEntries)) {
239
- if (isStreaming(server.ssrByEntries[name])) {
240
- return true;
241
- }
242
- }
243
- }
244
- return false;
245
- };
246
- function applyAsyncChunkHtmlPlugin({
247
- chain,
248
- modernConfig,
249
- CHAIN_ID
250
- }) {
251
- if (isStreamingSSR(modernConfig)) {
252
- chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(import_htmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [import_html_webpack_plugin.default]);
253
- }
254
- }
255
225
  // Annotate the CommonJS export names for ESM import in node:
256
226
  0 && (module.exports = {
257
- PluginCompatModern
227
+ applyCallbacks,
228
+ builderPluginAdapterModern
258
229
  });
@@ -0,0 +1,50 @@
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 HtmlAsyncChunkPlugin_exports = {};
19
+ __export(HtmlAsyncChunkPlugin_exports, {
20
+ HtmlAsyncChunkPlugin: () => HtmlAsyncChunkPlugin
21
+ });
22
+ module.exports = __toCommonJS(HtmlAsyncChunkPlugin_exports);
23
+ class HtmlAsyncChunkPlugin {
24
+ constructor(htmlWebpackPlugin) {
25
+ this.name = "HtmlAsyncChunkPlugin";
26
+ this.htmlWebpackPlugin = htmlWebpackPlugin;
27
+ }
28
+ apply(compiler) {
29
+ compiler.hooks.compilation.tap(this.name, (compilation) => {
30
+ const hooks = this.htmlWebpackPlugin.getHooks(compilation);
31
+ hooks.alterAssetTagGroups.tap(this.name, (assets) => {
32
+ const tags = [...assets.headTags, ...assets.bodyTags];
33
+ for (const tag of tags) {
34
+ if (tag.tagName === "script") {
35
+ const { attributes } = tag;
36
+ if (attributes && attributes.defer === true) {
37
+ attributes.async = true;
38
+ delete attributes.defer;
39
+ }
40
+ }
41
+ }
42
+ return assets;
43
+ });
44
+ });
45
+ }
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ HtmlAsyncChunkPlugin
50
+ });
@@ -0,0 +1,57 @@
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 HtmlBottomTemplate_exports = {};
19
+ __export(HtmlBottomTemplate_exports, {
20
+ BottomTemplatePlugin: () => BottomTemplatePlugin
21
+ });
22
+ module.exports = __toCommonJS(HtmlBottomTemplate_exports);
23
+ class BottomTemplatePlugin {
24
+ constructor(htmlWebpackPlugin) {
25
+ this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
26
+ this.bodyRegExp = /(<\/\s*body\s*>)/i;
27
+ this.htmlWebpackPlugin = htmlWebpackPlugin;
28
+ this.name = "bottom-template";
29
+ }
30
+ apply(compiler) {
31
+ compiler.hooks.compilation.tap(this.name, (compilation) => {
32
+ this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(this.name, (data) => {
33
+ var _a;
34
+ if (!((_a = data.plugin.options) == null ? void 0 : _a.__internal__)) {
35
+ return data;
36
+ }
37
+ if (this.bottomTemplateReg.test(data.html)) {
38
+ data.html = data.html.replace(this.bottomTemplateReg, "");
39
+ const { bottomTemplate } = data.plugin.options;
40
+ if (bottomTemplate) {
41
+ data.html = data.html.replace(
42
+ this.bodyRegExp,
43
+ (match) => `
44
+ ${bottomTemplate}
45
+ ${match}`
46
+ );
47
+ }
48
+ }
49
+ return data;
50
+ });
51
+ });
52
+ }
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ BottomTemplatePlugin
57
+ });
@@ -0,0 +1,75 @@
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
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var createCopyPattern_exports = {};
25
+ __export(createCopyPattern_exports, {
26
+ createCopyPattern: () => createCopyPattern
27
+ });
28
+ module.exports = __toCommonJS(createCopyPattern_exports);
29
+ var import_path = __toESM(require("path"));
30
+ var import_utils = require("@modern-js/utils");
31
+ function createCopyPattern(appContext, config, patternsType, chain) {
32
+ const configDir = import_path.default.resolve(
33
+ appContext.appDirectory,
34
+ config.source.configDir || "./config"
35
+ );
36
+ const uploadDir = import_path.default.posix.join(configDir.replace(/\\/g, "/"), "upload");
37
+ const publicDir = import_path.default.posix.join(configDir.replace(/\\/g, "/"), "public");
38
+ const minifiedJsRexExp = /\.min\.js/;
39
+ const info = (file) => ({
40
+ minimized: minifiedJsRexExp.test(file.sourceFilename)
41
+ });
42
+ if (patternsType === "public") {
43
+ if (!chain) {
44
+ throw new Error("expect get a webpackChain, but receive 'undefined'");
45
+ }
46
+ return {
47
+ info,
48
+ from: "**/*",
49
+ to: "public",
50
+ context: publicDir,
51
+ noErrorOnMissing: true,
52
+ transform: (content, absoluteFrom) => {
53
+ if (!/\.html?$/.test(absoluteFrom)) {
54
+ return content;
55
+ }
56
+ return content.toString("utf8").replace(
57
+ /<%=\s*assetPrefix\s*%>/g,
58
+ (0, import_utils.removeTailSlash)(chain.output.get("publicPath"))
59
+ );
60
+ }
61
+ };
62
+ } else {
63
+ return {
64
+ info,
65
+ from: "**/*",
66
+ to: "upload",
67
+ context: uploadDir,
68
+ noErrorOnMissing: true
69
+ };
70
+ }
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ createCopyPattern
75
+ });
@@ -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 shared_exports = {};
16
+ module.exports = __toCommonJS(shared_exports);
17
+ __reExport(shared_exports, require("./createCopyPattern"), module.exports);
18
+ __reExport(shared_exports, require("./types"), module.exports);
19
+ __reExport(shared_exports, require("./builderPlugins/adapterModern"), module.exports);
@@ -0,0 +1,28 @@
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 serverModuleLoader_exports = {};
19
+ __export(serverModuleLoader_exports, {
20
+ default: () => serverModuleLoader_default
21
+ });
22
+ module.exports = __toCommonJS(serverModuleLoader_exports);
23
+ function loader() {
24
+ return `module.exports = {}`;
25
+ }
26
+ var serverModuleLoader_default = loader;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {});
@@ -0,0 +1,15 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var types_exports = {};
15
+ module.exports = __toCommonJS(types_exports);
@@ -39,12 +39,11 @@ __export(default_exports, {
39
39
  });
40
40
  module.exports = __toCommonJS(default_exports);
41
41
  var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
42
- function createDefaultConfig(appContext) {
42
+ function createDefaultConfig(appContext, bundler) {
43
43
  const defaultBuilderConfig = (0, import_builder_webpack_provider.createDefaultConfig)();
44
44
  const dev = __spreadProps(__spreadValues({}, defaultBuilderConfig.dev), {
45
45
  port: void 0
46
46
  });
47
- const tools = __spreadValues({}, defaultBuilderConfig.tools);
48
47
  const output = __spreadProps(__spreadValues({}, defaultBuilderConfig.output), {
49
48
  disableNodePolyfill: true
50
49
  });
@@ -82,6 +81,7 @@ function createDefaultConfig(appContext) {
82
81
  baseUrl: "/",
83
82
  port: 8080
84
83
  };
84
+ const tools = bundler === "webpack" ? __spreadValues({}, defaultBuilderConfig.tools) : void 0;
85
85
  return {
86
86
  source,
87
87
  output,
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
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
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -14,21 +10,10 @@ var __copyProps = (to, from, except, desc) => {
14
10
  }
15
11
  return to;
16
12
  };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
15
  var config_exports = {};
19
- __export(config_exports, {
20
- checkIsLegacyConfig: () => import_initial.checkIsLegacyConfig,
21
- createDefaultConfig: () => import_default.createDefaultConfig,
22
- createLegacyDefaultConfig: () => import_default.createLegacyDefaultConfig,
23
- initialNormalizedConfig: () => import_initial.initialNormalizedConfig
24
- });
25
16
  module.exports = __toCommonJS(config_exports);
26
- var import_default = require("./default");
27
- var import_initial = require("./initial");
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- checkIsLegacyConfig,
31
- createDefaultConfig,
32
- createLegacyDefaultConfig,
33
- initialNormalizedConfig
34
- });
17
+ __reExport(config_exports, require("./legacy"), module.exports);
18
+ __reExport(config_exports, require("./initialize"), module.exports);
19
+ __reExport(config_exports, require("./default"), module.exports);
@@ -0,0 +1,35 @@
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 initialize_exports = {};
19
+ __export(initialize_exports, {
20
+ initialNormalizedConfig: () => initialNormalizedConfig
21
+ });
22
+ module.exports = __toCommonJS(initialize_exports);
23
+ var import_inits = require("./inits");
24
+ function initialNormalizedConfig(config, appContext, bundler) {
25
+ (0, import_inits.initHtmlConfig)(config, appContext);
26
+ (0, import_inits.initSourceConfig)(config, appContext, bundler);
27
+ if (bundler === "webpack") {
28
+ (0, import_inits.initToolsConfig)(config);
29
+ }
30
+ return config;
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ initialNormalizedConfig
35
+ });
@@ -81,10 +81,12 @@ function initHtmlConfig(config, appContext) {
81
81
  return favicon || defaultFavicon || void 0;
82
82
  }
83
83
  }
84
- function initSourceConfig(config, appContext) {
84
+ function initSourceConfig(config, appContext, bundler) {
85
85
  config.source.include = createBuilderInclude(config, appContext);
86
- config.source.moduleScopes = createBuilderModuleScope(config);
87
86
  config.source.globalVars = createBuilderGlobalVars(config, appContext);
87
+ if (bundler === "webpack") {
88
+ config.source.moduleScopes = createBuilderModuleScope(config);
89
+ }
88
90
  function createBuilderGlobalVars(config2, appContext2) {
89
91
  const { globalVars = {} } = config2.source;
90
92
  const publicEnv = (0, import_env.getAutoInjectEnv)(appContext2);
@@ -0,0 +1,58 @@
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 createHtmlConfig_exports = {};
19
+ __export(createHtmlConfig_exports, {
20
+ createHtmlConfig: () => createHtmlConfig
21
+ });
22
+ module.exports = __toCommonJS(createHtmlConfig_exports);
23
+ function createHtmlConfig(config) {
24
+ const {
25
+ disableHtmlFolder,
26
+ favicon,
27
+ faviconByEntries,
28
+ inject,
29
+ injectByEntries,
30
+ meta,
31
+ metaByEntries,
32
+ mountId,
33
+ title,
34
+ titleByEntries,
35
+ templateParameters,
36
+ templateParametersByEntries,
37
+ crossorigin
38
+ } = config.output;
39
+ return {
40
+ disableHtmlFolder,
41
+ favicon,
42
+ faviconByEntries,
43
+ inject,
44
+ injectByEntries,
45
+ meta,
46
+ metaByEntries,
47
+ mountId,
48
+ title,
49
+ titleByEntries,
50
+ crossorigin,
51
+ templateParameters,
52
+ templateParametersByEntries
53
+ };
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ createHtmlConfig
58
+ });