@modern-js/app-tools 2.3.1-alpha.2 → 2.5.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 (362) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +14 -18
  3. package/dist/{js/node → cjs}/analyze/constants.js +0 -0
  4. package/dist/cjs/analyze/generateCode.js +249 -0
  5. package/dist/{js/node → cjs}/analyze/getBundleEntry.js +6 -0
  6. package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutes.js +1 -18
  7. package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutesLegacy.js +1 -18
  8. package/dist/{js/node → cjs}/analyze/getClientRoutes/index.js +0 -0
  9. package/dist/{js/node → cjs}/analyze/getClientRoutes/utils.js +0 -0
  10. package/dist/{js/node → cjs}/analyze/getFileSystemEntry.js +0 -0
  11. package/dist/{js/node → cjs}/analyze/getHtmlTemplate.js +4 -24
  12. package/dist/{js/node → cjs}/analyze/getServerRoutes.js +22 -42
  13. package/dist/cjs/analyze/index.js +290 -0
  14. package/dist/{js/node → cjs}/analyze/isDefaultExportFunction.js +0 -0
  15. package/dist/{js/node → cjs}/analyze/makeLegalIdentifier.js +0 -0
  16. package/dist/{js/node → cjs}/analyze/nestedRoutes.js +16 -50
  17. package/dist/{js/node → cjs}/analyze/templates.js +16 -49
  18. package/dist/{js/node → cjs}/analyze/utils.js +9 -29
  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/{js/node/builder/webpackPlugins/routerPlugin.js → cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +14 -29
  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/{js/node/config/initial/index.js → cjs/builder/generator/createBuilderProviderConfig.js} +26 -18
  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/{js/node/builder/builderPlugins/compatModern.js → cjs/builder/shared/builderPlugins/adapterModern.js} +109 -137
  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/{js/node/utils → cjs/builder/shared}/types.js +0 -0
  36. package/dist/{js/node → cjs}/commands/build.js +9 -46
  37. package/dist/cjs/commands/deploy.js +31 -0
  38. package/dist/{js/node → cjs}/commands/dev.js +17 -52
  39. package/dist/{js/node → cjs}/commands/index.js +0 -0
  40. package/dist/{js/node → cjs}/commands/inspect.js +2 -22
  41. package/dist/{js/node → cjs}/commands/serve.js +8 -28
  42. package/dist/{js/node → cjs}/config/default.js +16 -27
  43. package/dist/cjs/config/index.js +19 -0
  44. package/dist/cjs/config/initialize/index.js +35 -0
  45. package/dist/{js/node/config/initial → cjs/config/initialize}/inits.js +8 -22
  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/{js/node → cjs}/exports/server.js +0 -0
  53. package/dist/{js/node → cjs}/hooks.js +0 -0
  54. package/dist/cjs/index.js +198 -0
  55. package/dist/cjs/initialize/index.js +102 -0
  56. package/dist/{js/node → cjs}/locale/en.js +0 -0
  57. package/dist/{js/node → cjs}/locale/index.js +0 -0
  58. package/dist/{js/node → cjs}/locale/zh.js +1 -1
  59. package/dist/{js/node → cjs}/schema/Schema.js +0 -0
  60. package/dist/{js/node → cjs}/schema/index.js +0 -0
  61. package/dist/{js/node → cjs}/schema/legacy.js +0 -0
  62. package/dist/{js/node → cjs}/types/config/deploy.js +0 -0
  63. package/dist/{js/node → cjs}/types/config/dev.js +0 -0
  64. package/dist/{js/node → cjs}/types/config/experiments.js +0 -0
  65. package/dist/{js/node → cjs}/types/config/html.js +0 -0
  66. package/dist/{js/node → cjs}/types/config/index.js +0 -0
  67. package/dist/{js/node → cjs}/types/config/output.js +0 -0
  68. package/dist/{js/node → cjs}/types/config/performance.js +0 -0
  69. package/dist/{js/node → cjs}/types/config/security.js +0 -0
  70. package/dist/{js/node → cjs}/types/config/source.js +0 -0
  71. package/dist/{js/node → cjs}/types/config/tools.js +0 -0
  72. package/dist/{js/node → cjs}/types/hooks.js +0 -0
  73. package/dist/{js/node → cjs}/types/index.js +0 -0
  74. package/dist/{js/node → cjs}/types/legacyConfig/deploy.js +0 -0
  75. package/dist/{js/node → cjs}/types/legacyConfig/dev.js +0 -0
  76. package/dist/{js/node → cjs}/types/legacyConfig/index.js +0 -0
  77. package/dist/{js/node → cjs}/types/legacyConfig/output.js +0 -0
  78. package/dist/{js/node → cjs}/types/legacyConfig/source.js +0 -0
  79. package/dist/{js/node → cjs}/types/legacyConfig/tools.js +0 -0
  80. package/dist/cjs/types/utils.js +15 -0
  81. package/dist/{js/node → cjs}/utils/config.js +19 -57
  82. package/dist/{js/node → cjs}/utils/createServer.js +10 -46
  83. package/dist/{js/node → cjs}/utils/env.js +0 -0
  84. package/dist/{js/node → cjs}/utils/generateWatchFiles.js +16 -38
  85. package/dist/{js/node → cjs}/utils/getSelectedEntries.js +3 -23
  86. package/dist/{js/node/config/index.js → cjs/utils/getServerInternalPlugins.js} +20 -13
  87. package/dist/{js/node → cjs}/utils/language.js +0 -0
  88. package/dist/{js/node → cjs}/utils/printInstructions.js +3 -23
  89. package/dist/cjs/utils/restart.js +45 -0
  90. package/dist/{js/node → cjs}/utils/routes.js +3 -23
  91. package/dist/cjs/utils/types.js +15 -0
  92. package/dist/{js/treeshaking → esm}/analyze/constants.js +0 -0
  93. package/dist/{js/treeshaking → esm}/analyze/generateCode.js +14 -14
  94. package/dist/{js/treeshaking → esm}/analyze/getBundleEntry.js +4 -2
  95. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutes.js +1 -1
  96. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
  97. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/index.js +0 -0
  98. package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/utils.js +0 -0
  99. package/dist/{js/treeshaking → esm}/analyze/getFileSystemEntry.js +1 -1
  100. package/dist/{js/treeshaking → esm}/analyze/getHtmlTemplate.js +0 -0
  101. package/dist/{js/treeshaking → esm}/analyze/getServerRoutes.js +8 -6
  102. package/dist/{js/treeshaking → esm}/analyze/index.js +142 -137
  103. package/dist/{js/treeshaking → esm}/analyze/isDefaultExportFunction.js +0 -0
  104. package/dist/{js/treeshaking → esm}/analyze/makeLegalIdentifier.js +0 -0
  105. package/dist/{js/treeshaking → esm}/analyze/nestedRoutes.js +5 -5
  106. package/dist/{js/treeshaking → esm}/analyze/templates.js +8 -7
  107. package/dist/{js/treeshaking → esm}/analyze/utils.js +3 -3
  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/{js/treeshaking/builder → esm/builder/builder-webpack}/index.js +44 -117
  111. package/dist/{js/treeshaking/builder/webpackPlugins/routerPlugin.js → esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +6 -3
  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/{js/treeshaking/builder/builderPlugins/compatModern.js → esm/builder/shared/builderPlugins/adapterModern.js} +138 -142
  119. package/dist/{js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js → esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
  120. package/dist/{js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js → esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js} +2 -2
  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/{js/treeshaking/utils → esm/builder/shared}/types.js +0 -0
  125. package/dist/{js/treeshaking → esm}/commands/build.js +0 -0
  126. package/dist/{js/treeshaking → esm}/commands/deploy.js +0 -0
  127. package/dist/{js/treeshaking → esm}/commands/dev.js +2 -2
  128. package/dist/{js/treeshaking → esm}/commands/index.js +0 -0
  129. package/dist/{js/treeshaking → esm}/commands/inspect.js +0 -0
  130. package/dist/{js/treeshaking → esm}/commands/serve.js +2 -2
  131. package/dist/{js/treeshaking → esm}/config/default.js +2 -2
  132. package/dist/esm/config/index.js +3 -0
  133. package/dist/esm/config/initialize/index.js +10 -0
  134. package/dist/{js/treeshaking/config/initial → esm/config/initialize}/inits.js +6 -4
  135. package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
  136. package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createOutputConfig.js +1 -1
  137. package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createSourceConfig.js +1 -1
  138. package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createToolsConfig.js +1 -1
  139. package/dist/{js/treeshaking/config/initial/transformNormalizedConfig.js → esm/config/legacy/index.js} +4 -1
  140. package/dist/{js/treeshaking → esm}/defineConfig.js +0 -0
  141. package/dist/{js/treeshaking → esm}/exports/server.js +0 -0
  142. package/dist/{js/treeshaking → esm}/hooks.js +0 -0
  143. package/dist/{js/treeshaking → esm}/index.js +19 -12
  144. package/dist/{js/treeshaking → esm}/initialize/index.js +36 -28
  145. package/dist/{js/treeshaking → esm}/locale/en.js +0 -0
  146. package/dist/{js/treeshaking → esm}/locale/index.js +0 -0
  147. package/dist/{js/treeshaking → esm}/locale/zh.js +1 -1
  148. package/dist/{js/treeshaking → esm}/schema/Schema.js +0 -0
  149. package/dist/{js/treeshaking → esm}/schema/index.js +0 -0
  150. package/dist/{js/treeshaking → esm}/schema/legacy.js +0 -0
  151. package/dist/{js/treeshaking → esm}/types/config/deploy.js +0 -0
  152. package/dist/{js/treeshaking → esm}/types/config/dev.js +0 -0
  153. package/dist/{js/treeshaking → esm}/types/config/experiments.js +0 -0
  154. package/dist/{js/treeshaking → esm}/types/config/html.js +0 -0
  155. package/dist/{js/treeshaking → esm}/types/config/index.js +0 -0
  156. package/dist/{js/treeshaking → esm}/types/config/output.js +0 -0
  157. package/dist/{js/treeshaking → esm}/types/config/performance.js +0 -0
  158. package/dist/{js/treeshaking → esm}/types/config/security.js +0 -0
  159. package/dist/{js/treeshaking → esm}/types/config/source.js +0 -0
  160. package/dist/{js/treeshaking → esm}/types/config/tools.js +0 -0
  161. package/dist/{js/treeshaking → esm}/types/hooks.js +0 -0
  162. package/dist/{js/treeshaking → esm}/types/index.js +0 -0
  163. package/dist/{js/treeshaking → esm}/types/legacyConfig/deploy.js +0 -0
  164. package/dist/{js/treeshaking → esm}/types/legacyConfig/dev.js +0 -0
  165. package/dist/{js/treeshaking → esm}/types/legacyConfig/index.js +0 -0
  166. package/dist/{js/treeshaking → esm}/types/legacyConfig/output.js +0 -0
  167. package/dist/{js/treeshaking → esm}/types/legacyConfig/source.js +0 -0
  168. package/dist/{js/treeshaking → esm}/types/legacyConfig/tools.js +0 -0
  169. package/dist/esm/types/utils.js +1 -0
  170. package/dist/{js/treeshaking → esm}/utils/config.js +2 -2
  171. package/dist/{js/treeshaking → esm}/utils/createServer.js +0 -0
  172. package/dist/{js/treeshaking → esm}/utils/env.js +0 -0
  173. package/dist/{js/treeshaking → esm}/utils/generateWatchFiles.js +0 -0
  174. package/dist/{js/treeshaking → esm}/utils/getSelectedEntries.js +0 -0
  175. package/dist/{js/treeshaking → esm}/utils/getServerInternalPlugins.js +2 -2
  176. package/dist/{js/treeshaking → esm}/utils/language.js +0 -0
  177. package/dist/{js/treeshaking → esm}/utils/printInstructions.js +0 -0
  178. package/dist/{js/treeshaking → esm}/utils/restart.js +0 -0
  179. package/dist/{js/treeshaking → esm}/utils/routes.js +0 -0
  180. package/dist/esm/utils/types.js +1 -0
  181. package/dist/{js/modern → esm-node}/analyze/constants.js +0 -0
  182. package/dist/esm-node/analyze/generateCode.js +225 -0
  183. package/dist/{js/modern → esm-node}/analyze/getBundleEntry.js +6 -0
  184. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutes.js +1 -20
  185. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutesLegacy.js +1 -20
  186. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/index.js +0 -0
  187. package/dist/{js/modern → esm-node}/analyze/getClientRoutes/utils.js +0 -0
  188. package/dist/{js/modern → esm-node}/analyze/getFileSystemEntry.js +0 -0
  189. package/dist/{js/modern → esm-node}/analyze/getHtmlTemplate.js +4 -24
  190. package/dist/{js/modern → esm-node}/analyze/getServerRoutes.js +24 -45
  191. package/dist/esm-node/analyze/index.js +281 -0
  192. package/dist/{js/modern → esm-node}/analyze/isDefaultExportFunction.js +0 -0
  193. package/dist/{js/modern → esm-node}/analyze/makeLegalIdentifier.js +0 -0
  194. package/dist/{js/modern → esm-node}/analyze/nestedRoutes.js +16 -52
  195. package/dist/{js/modern → esm-node}/analyze/templates.js +16 -51
  196. package/dist/{js/modern → esm-node}/analyze/utils.js +9 -29
  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/{js/modern/builder/webpackPlugins/routerPlugin.js → esm-node/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +8 -25
  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/{js/modern/builder/builderPlugins/compatModern.js → esm-node/builder/shared/builderPlugins/adapterModern.js} +104 -135
  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/{js/modern/utils → 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/{js/modern → esm-node}/commands/index.js +0 -0
  218. package/dist/esm-node/commands/inspect.js +18 -0
  219. package/dist/{js/modern → esm-node}/commands/serve.js +8 -28
  220. package/dist/{js/modern → esm-node}/config/default.js +16 -29
  221. package/dist/esm-node/config/index.js +3 -0
  222. package/dist/esm-node/config/initialize/index.js +12 -0
  223. package/dist/{js/modern/config/initial → esm-node/config/initialize}/inits.js +8 -24
  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/{js/modern → esm-node}/exports/server.js +0 -0
  231. package/dist/{js/modern → esm-node}/hooks.js +0 -0
  232. package/dist/esm-node/index.js +172 -0
  233. package/dist/esm-node/initialize/index.js +91 -0
  234. package/dist/{js/modern → esm-node}/locale/en.js +0 -0
  235. package/dist/{js/modern → esm-node}/locale/index.js +0 -0
  236. package/dist/{js/modern → esm-node}/locale/zh.js +1 -1
  237. package/dist/{js/modern → esm-node}/schema/Schema.js +0 -0
  238. package/dist/{js/modern → esm-node}/schema/index.js +0 -0
  239. package/dist/{js/modern → esm-node}/schema/legacy.js +0 -0
  240. package/dist/{js/modern → esm-node}/types/config/deploy.js +0 -0
  241. package/dist/{js/modern → esm-node}/types/config/dev.js +0 -0
  242. package/dist/{js/modern → esm-node}/types/config/experiments.js +0 -0
  243. package/dist/{js/modern → esm-node}/types/config/html.js +0 -0
  244. package/dist/{js/modern → esm-node}/types/config/index.js +0 -0
  245. package/dist/{js/modern → esm-node}/types/config/output.js +0 -0
  246. package/dist/{js/modern → esm-node}/types/config/performance.js +0 -0
  247. package/dist/{js/modern → esm-node}/types/config/security.js +0 -0
  248. package/dist/{js/modern → esm-node}/types/config/source.js +0 -0
  249. package/dist/{js/modern → esm-node}/types/config/tools.js +0 -0
  250. package/dist/{js/modern → esm-node}/types/hooks.js +0 -0
  251. package/dist/{js/modern → esm-node}/types/index.js +0 -0
  252. package/dist/{js/modern → esm-node}/types/legacyConfig/deploy.js +0 -0
  253. package/dist/{js/modern → esm-node}/types/legacyConfig/dev.js +0 -0
  254. package/dist/{js/modern → esm-node}/types/legacyConfig/index.js +0 -0
  255. package/dist/{js/modern → esm-node}/types/legacyConfig/output.js +0 -0
  256. package/dist/{js/modern → esm-node}/types/legacyConfig/source.js +0 -0
  257. package/dist/{js/modern → 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/{js/modern → esm-node}/utils/env.js +0 -0
  262. package/dist/esm-node/utils/generateWatchFiles.js +33 -0
  263. package/dist/{js/modern → esm-node}/utils/getSelectedEntries.js +3 -23
  264. package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
  265. package/dist/{js/modern → esm-node}/utils/language.js +0 -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/types/analyze/generateCode.d.ts +1 -1
  271. package/dist/types/analyze/getBundleEntry.d.ts +1 -1
  272. package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
  273. package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
  274. package/dist/types/analyze/getServerRoutes.d.ts +1 -1
  275. package/dist/types/analyze/index.d.ts +5 -1
  276. package/dist/types/builder/builder-rspack/index.d.ts +2 -0
  277. package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
  278. package/dist/types/builder/builder-webpack/index.d.ts +4 -0
  279. package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
  280. package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
  281. package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
  282. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
  283. package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
  284. package/dist/types/builder/generator/index.d.ts +17 -0
  285. package/dist/types/builder/index.d.ts +1 -18
  286. package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
  287. package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
  288. package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
  289. package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
  290. package/dist/types/builder/shared/index.d.ts +3 -0
  291. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
  292. package/dist/types/builder/shared/types.d.ts +16 -0
  293. package/dist/types/commands/build.d.ts +1 -1
  294. package/dist/types/commands/deploy.d.ts +1 -1
  295. package/dist/types/commands/dev.d.ts +1 -1
  296. package/dist/types/commands/inspect.d.ts +1 -1
  297. package/dist/types/commands/serve.d.ts +1 -1
  298. package/dist/types/config/default.d.ts +1 -1
  299. package/dist/types/config/index.d.ts +3 -2
  300. package/dist/types/config/initialize/index.d.ts +2 -0
  301. package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
  302. package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
  303. package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
  304. package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
  305. package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
  306. package/dist/types/config/legacy/index.d.ts +3 -0
  307. package/dist/types/defineConfig.d.ts +2 -2
  308. package/dist/types/index.d.ts +7 -3
  309. package/dist/types/initialize/index.d.ts +6 -2
  310. package/dist/types/types/config/deploy.d.ts +1 -2
  311. package/dist/types/types/config/dev.d.ts +2 -3
  312. package/dist/types/types/config/experiments.d.ts +1 -2
  313. package/dist/types/types/config/html.d.ts +5 -3
  314. package/dist/types/types/config/index.d.ts +41 -48
  315. package/dist/types/types/config/output.d.ts +8 -3
  316. package/dist/types/types/config/performance.d.ts +6 -3
  317. package/dist/types/types/config/security.d.ts +3 -3
  318. package/dist/types/types/config/source.d.ts +7 -3
  319. package/dist/types/types/config/tools.d.ts +10 -4
  320. package/dist/types/types/hooks.d.ts +6 -4
  321. package/dist/types/types/index.d.ts +19 -7
  322. package/dist/types/types/utils.d.ts +7 -0
  323. package/dist/types/utils/config.d.ts +1 -1
  324. package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
  325. package/dist/types/utils/printInstructions.d.ts +1 -1
  326. package/package.json +40 -32
  327. package/dist/js/modern/analyze/generateCode.js +0 -247
  328. package/dist/js/modern/analyze/index.js +0 -332
  329. package/dist/js/modern/builder/index.js +0 -159
  330. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
  331. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
  332. package/dist/js/modern/commands/build.js +0 -91
  333. package/dist/js/modern/commands/deploy.js +0 -28
  334. package/dist/js/modern/commands/dev.js +0 -109
  335. package/dist/js/modern/commands/inspect.js +0 -38
  336. package/dist/js/modern/config/index.js +0 -8
  337. package/dist/js/modern/config/initial/index.js +0 -16
  338. package/dist/js/modern/defineConfig.js +0 -27
  339. package/dist/js/modern/index.js +0 -211
  340. package/dist/js/modern/initialize/index.js +0 -124
  341. package/dist/js/modern/utils/config.js +0 -128
  342. package/dist/js/modern/utils/createServer.js +0 -75
  343. package/dist/js/modern/utils/generateWatchFiles.js +0 -55
  344. package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
  345. package/dist/js/modern/utils/printInstructions.js +0 -31
  346. package/dist/js/modern/utils/restart.js +0 -44
  347. package/dist/js/modern/utils/routes.js +0 -30
  348. package/dist/js/node/analyze/generateCode.js +0 -271
  349. package/dist/js/node/analyze/index.js +0 -339
  350. package/dist/js/node/builder/index.js +0 -177
  351. package/dist/js/node/commands/deploy.js +0 -51
  352. package/dist/js/node/defineConfig.js +0 -49
  353. package/dist/js/node/index.js +0 -235
  354. package/dist/js/node/initialize/index.js +0 -134
  355. package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
  356. package/dist/js/node/utils/restart.js +0 -67
  357. package/dist/js/treeshaking/config/index.js +0 -3
  358. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
  359. package/dist/js/treeshaking/config/initial/index.js +0 -12
  360. package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
  361. package/dist/types/config/initial/index.d.ts +0 -4
  362. package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
@@ -223,16 +223,17 @@ var __generator = this && this.__generator || function(thisArg, body) {
223
223
  import * as path from "path";
224
224
  import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
225
225
  import { cloneDeep } from "@modern-js/utils/lodash";
226
- import { createBuilderForModern } from "../builder";
227
226
  import { printInstructions } from "../utils/printInstructions";
228
227
  import { generateRoutes } from "../utils/routes";
229
228
  import { emitResolvedConfig } from "../utils/config";
230
229
  import { getSelectedEntries } from "../utils/getSelectedEntries";
231
230
  import { initialNormalizedConfig } from "../config";
231
+ import { createBuilderGenerator } from "../builder";
232
232
  import { getServerLoadersFile, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
233
233
  import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
234
234
  var debug = createDebugger("plugin-analyze");
235
- var analyze_default = function() {
235
+ var analyze_default = function(param) {
236
+ var bundler = param.bundler;
236
237
  return {
237
238
  name: "@modern-js/plugin-analyze",
238
239
  setup: function(api) {
@@ -242,7 +243,7 @@ var analyze_default = function() {
242
243
  return {
243
244
  prepare: function prepare() {
244
245
  return _asyncToGenerator(function() {
245
- var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, builder;
246
+ var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, _ref, routes2, _ref1, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, createBuilderForModern, builder;
246
247
  return __generator(this, function(_state) {
247
248
  switch(_state.label){
248
249
  case 0:
@@ -254,7 +255,7 @@ var analyze_default = function() {
254
255
  } catch (e) {}
255
256
  return [
256
257
  4,
257
- isApiOnly(appContext.appDirectory, (ref = resolvedConfig.source) === null || ref === void 0 ? void 0 : ref.entriesDir)
258
+ isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir)
258
259
  ];
259
260
  case 1:
260
261
  apiOnly = _state.sent();
@@ -275,7 +276,7 @@ var analyze_default = function() {
275
276
  })
276
277
  ];
277
278
  case 3:
278
- ref1 = _state.sent(), routes2 = ref1.routes;
279
+ _ref = _state.sent(), routes2 = _ref.routes;
279
280
  debug("server routes: %o", routes2);
280
281
  appContext = _objectSpreadProps(_objectSpread({}, appContext), {
281
282
  apiOnly: apiOnly,
@@ -296,10 +297,10 @@ var analyze_default = function() {
296
297
  ])
297
298
  ];
298
299
  case 5:
299
- ref2 = _slicedToArray.apply(void 0, [
300
+ _ref1 = _slicedToArray.apply(void 0, [
300
301
  _state.sent(),
301
302
  4
302
- ]), getBundleEntry = ref2[0].getBundleEntry, getServerRoutes = ref2[1].getServerRoutes, generateCode = ref2[2].generateCode, getHtmlTemplate = ref2[3].getHtmlTemplate;
303
+ ]), getBundleEntry = _ref1[0].getBundleEntry, getServerRoutes = _ref1[1].getServerRoutes, generateCode = _ref1[2].generateCode, getHtmlTemplate = _ref1[3].getHtmlTemplate;
303
304
  entrypoints = getBundleEntry(appContext, resolvedConfig);
304
305
  debug("entrypoints: %o", entrypoints);
305
306
  initialRoutes = getServerRoutes(entrypoints, {
@@ -384,149 +385,153 @@ var analyze_default = function() {
384
385
  ];
385
386
  if (!buildCommands.includes(command)) return [
386
387
  3,
387
- 13
388
+ 14
388
389
  ];
389
390
  normalizedConfig = api.useResolvedConfigContext();
391
+ return [
392
+ 4,
393
+ createBuilderGenerator(bundler)
394
+ ];
395
+ case 12:
396
+ createBuilderForModern = _state.sent();
390
397
  return [
391
398
  4,
392
399
  createBuilderForModern({
393
400
  normalizedConfig: normalizedConfig,
394
401
  appContext: appContext,
395
- compatPluginConfig: {
396
- onBeforeBuild: function onBeforeBuild(param) {
397
- var bundlerConfigs = param.bundlerConfigs;
398
- return _asyncToGenerator(function() {
399
- var hookRunners2;
400
- return __generator(this, function(_state) {
401
- switch(_state.label){
402
- case 0:
403
- hookRunners2 = api.useHookRunners();
404
- return [
405
- 4,
406
- generateRoutes(appContext)
407
- ];
408
- case 1:
409
- _state.sent();
410
- return [
411
- 4,
412
- hookRunners2.beforeBuild({
413
- bundlerConfigs: bundlerConfigs
414
- })
415
- ];
416
- case 2:
417
- _state.sent();
418
- return [
419
- 2
420
- ];
421
- }
422
- });
423
- })();
424
- },
425
- onAfterBuild: function onAfterBuild(param) {
426
- var stats = param.stats;
427
- return _asyncToGenerator(function() {
428
- var hookRunners2;
429
- return __generator(this, function(_state) {
430
- switch(_state.label){
431
- case 0:
432
- hookRunners2 = api.useHookRunners();
433
- return [
434
- 4,
435
- hookRunners2.afterBuild({
436
- stats: stats
437
- })
438
- ];
439
- case 1:
440
- _state.sent();
441
- return [
442
- 4,
443
- emitResolvedConfig(appContext.appDirectory, normalizedConfig)
444
- ];
445
- case 2:
446
- _state.sent();
447
- return [
448
- 2
449
- ];
450
- }
451
- });
452
- })();
453
- },
454
- onDevCompileDone: function onDevCompileDone(param) {
455
- var isFirstCompile = param.isFirstCompile;
456
- return _asyncToGenerator(function() {
457
- var hookRunners2;
458
- return __generator(this, function(_state) {
459
- hookRunners2 = api.useHookRunners();
460
- if (process.stdout.isTTY || isFirstCompile) {
461
- hookRunners2.afterDev();
462
- if (isFirstCompile) {
463
- printInstructions(hookRunners2, appContext, normalizedConfig);
464
- }
402
+ onBeforeBuild: function onBeforeBuild(param) {
403
+ var bundlerConfigs = param.bundlerConfigs;
404
+ return _asyncToGenerator(function() {
405
+ var hookRunners2;
406
+ return __generator(this, function(_state) {
407
+ switch(_state.label){
408
+ case 0:
409
+ hookRunners2 = api.useHookRunners();
410
+ return [
411
+ 4,
412
+ generateRoutes(appContext)
413
+ ];
414
+ case 1:
415
+ _state.sent();
416
+ return [
417
+ 4,
418
+ hookRunners2.beforeBuild({
419
+ bundlerConfigs: bundlerConfigs
420
+ })
421
+ ];
422
+ case 2:
423
+ _state.sent();
424
+ return [
425
+ 2
426
+ ];
427
+ }
428
+ });
429
+ })();
430
+ },
431
+ onAfterBuild: function onAfterBuild(param) {
432
+ var stats = param.stats;
433
+ return _asyncToGenerator(function() {
434
+ var hookRunners2;
435
+ return __generator(this, function(_state) {
436
+ switch(_state.label){
437
+ case 0:
438
+ hookRunners2 = api.useHookRunners();
439
+ return [
440
+ 4,
441
+ hookRunners2.afterBuild({
442
+ stats: stats
443
+ })
444
+ ];
445
+ case 1:
446
+ _state.sent();
447
+ return [
448
+ 4,
449
+ emitResolvedConfig(appContext.appDirectory, normalizedConfig)
450
+ ];
451
+ case 2:
452
+ _state.sent();
453
+ return [
454
+ 2
455
+ ];
456
+ }
457
+ });
458
+ })();
459
+ },
460
+ onDevCompileDone: function onDevCompileDone(param) {
461
+ var isFirstCompile = param.isFirstCompile;
462
+ return _asyncToGenerator(function() {
463
+ var hookRunners2;
464
+ return __generator(this, function(_state) {
465
+ hookRunners2 = api.useHookRunners();
466
+ if (process.stdout.isTTY || isFirstCompile) {
467
+ hookRunners2.afterDev();
468
+ if (isFirstCompile) {
469
+ printInstructions(hookRunners2, appContext, normalizedConfig);
465
470
  }
466
- return [
467
- 2
468
- ];
469
- });
470
- })();
471
- },
472
- onBeforeCreateCompiler: function onBeforeCreateCompiler(param) {
473
- var bundlerConfigs = param.bundlerConfigs;
474
- return _asyncToGenerator(function() {
475
- var hookRunners2;
476
- return __generator(this, function(_state) {
477
- switch(_state.label){
478
- case 0:
479
- hookRunners2 = api.useHookRunners();
480
- return [
481
- 4,
482
- hookRunners2.beforeCreateCompiler({
483
- bundlerConfigs: bundlerConfigs
484
- })
485
- ];
486
- case 1:
487
- _state.sent();
488
- return [
489
- 2
490
- ];
491
- }
492
- });
493
- })();
494
- },
495
- onAfterCreateCompiler: function onAfterCreateCompiler(param) {
496
- var compiler = param.compiler;
497
- return _asyncToGenerator(function() {
498
- var hookRunners2;
499
- return __generator(this, function(_state) {
500
- switch(_state.label){
501
- case 0:
502
- hookRunners2 = api.useHookRunners();
503
- return [
504
- 4,
505
- hookRunners2.afterCreateCompiler({
506
- compiler: compiler
507
- })
508
- ];
509
- case 1:
510
- _state.sent();
511
- return [
512
- 2
513
- ];
514
- }
515
- });
516
- })();
517
- }
471
+ }
472
+ return [
473
+ 2
474
+ ];
475
+ });
476
+ })();
477
+ },
478
+ onBeforeCreateCompiler: function onBeforeCreateCompiler(param) {
479
+ var bundlerConfigs = param.bundlerConfigs;
480
+ return _asyncToGenerator(function() {
481
+ var hookRunners2;
482
+ return __generator(this, function(_state) {
483
+ switch(_state.label){
484
+ case 0:
485
+ hookRunners2 = api.useHookRunners();
486
+ return [
487
+ 4,
488
+ hookRunners2.beforeCreateCompiler({
489
+ bundlerConfigs: bundlerConfigs
490
+ })
491
+ ];
492
+ case 1:
493
+ _state.sent();
494
+ return [
495
+ 2
496
+ ];
497
+ }
498
+ });
499
+ })();
500
+ },
501
+ onAfterCreateCompiler: function onAfterCreateCompiler(param) {
502
+ var compiler = param.compiler;
503
+ return _asyncToGenerator(function() {
504
+ var hookRunners2;
505
+ return __generator(this, function(_state) {
506
+ switch(_state.label){
507
+ case 0:
508
+ hookRunners2 = api.useHookRunners();
509
+ return [
510
+ 4,
511
+ hookRunners2.afterCreateCompiler({
512
+ compiler: compiler
513
+ })
514
+ ];
515
+ case 1:
516
+ _state.sent();
517
+ return [
518
+ 2
519
+ ];
520
+ }
521
+ });
522
+ })();
518
523
  }
519
524
  })
520
525
  ];
521
- case 12:
526
+ case 13:
522
527
  builder = _state.sent();
523
528
  builder.addPlugins(resolvedConfig.builderPlugins);
524
529
  appContext = _objectSpreadProps(_objectSpread({}, appContext), {
525
530
  builder: builder
526
531
  });
527
532
  api.setAppContext(appContext);
528
- _state.label = 13;
529
- case 13:
533
+ _state.label = 14;
534
+ case 14:
530
535
  return [
531
536
  2
532
537
  ];
@@ -560,7 +565,7 @@ var analyze_default = function() {
560
565
  resolvedConfig: function resolvedConfig(param) {
561
566
  var resolved = param.resolved;
562
567
  var appContext = api.useAppContext();
563
- var config = initialNormalizedConfig(resolved, appContext);
568
+ var config = initialNormalizedConfig(resolved, appContext, bundler);
564
569
  return {
565
570
  resolved: config
566
571
  };
@@ -568,7 +573,7 @@ var analyze_default = function() {
568
573
  modifyEntryImports: function modifyEntryImports(param) {
569
574
  var entrypoint = param.entrypoint, imports = param.imports;
570
575
  return _asyncToGenerator(function() {
571
- var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
576
+ var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, _ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
572
577
  return __generator(this, function(_state) {
573
578
  switch(_state.label){
574
579
  case 0:
@@ -607,10 +612,10 @@ var analyze_default = function() {
607
612
  })
608
613
  ];
609
614
  case 2:
610
- ref = _slicedToArray.apply(void 0, [
615
+ _ref = _slicedToArray.apply(void 0, [
611
616
  _state.sent(),
612
617
  2
613
- ]), moduleExports = ref[1];
618
+ ]), moduleExports = _ref[1];
614
619
  hasAppConfig = moduleExports.some(function(e) {
615
620
  return e.n === APP_CONFIG_NAME;
616
621
  });
@@ -197,7 +197,7 @@ var createRoute = function(routeInfo, rootDir, filename, entryName) {
197
197
  };
198
198
  var walk = function() {
199
199
  var _ref = _asyncToGenerator(function(dirname, rootDir, alias, entryName) {
200
- var ref, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, ref1, ref2, ref3, err, finalRoute, childRoute1, path2;
200
+ var _route_children, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, splatLoaderFile, splatRoute, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, extname, itemWithoutExt, isDirectory2, childRoute, _route_children1, _route_children2, _route_children3, err, finalRoute, childRoute1, path2;
201
201
  return __generator(this, function(_state) {
202
202
  switch(_state.label){
203
203
  case 0:
@@ -288,7 +288,7 @@ var walk = function() {
288
288
  childRoute = _state.sent();
289
289
  if (childRoute) {
290
290
  ;
291
- (ref1 = route.children) === null || ref1 === void 0 ? void 0 : ref1.push(childRoute);
291
+ (_route_children1 = route.children) === null || _route_children1 === void 0 ? void 0 : _route_children1.push(childRoute);
292
292
  }
293
293
  _state.label = 8;
294
294
  case 8:
@@ -317,7 +317,7 @@ var walk = function() {
317
317
  if (pageLoaderFile) {
318
318
  pageRoute.loader = pageLoaderFile;
319
319
  }
320
- (ref2 = route.children) === null || ref2 === void 0 ? void 0 : ref2.push(pageRoute);
320
+ (_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(pageRoute);
321
321
  }
322
322
  if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
323
323
  splatLoaderFile = itemPath;
@@ -331,7 +331,7 @@ var walk = function() {
331
331
  if (splatLoaderFile) {
332
332
  splatRoute.loader = splatLoaderFile;
333
333
  }
334
- (ref3 = route.children) === null || ref3 === void 0 ? void 0 : ref3.push(splatRoute);
334
+ (_route_children3 = route.children) === null || _route_children3 === void 0 ? void 0 : _route_children3.push(splatRoute);
335
335
  }
336
336
  if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
337
337
  route.loading = replaceWithAlias(alias.basename, itemPath, alias.name);
@@ -377,7 +377,7 @@ var walk = function() {
377
377
  if (isPathlessLayout) {
378
378
  delete finalRoute.path;
379
379
  }
380
- route.children = (ref = route.children) === null || ref === void 0 ? void 0 : ref.filter(function(childRoute) {
380
+ route.children = (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.filter(function(childRoute) {
381
381
  return childRoute;
382
382
  });
383
383
  if (route.children && route.children.length === 0 && !route.index) {
@@ -229,10 +229,11 @@ var index = function(param) {
229
229
  };
230
230
  var renderFunction = function(param) {
231
231
  var plugins = param.plugins, customBootstrap = param.customBootstrap, fileSystemRoutes2 = param.fileSystemRoutes;
232
+ var bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
232
233
  return "\n const finalAppConfig = {\n ...App.config,\n ...typeof ".concat(APP_CONFIG_NAME, " === 'function' ? ").concat(APP_CONFIG_NAME, "() : {},\n }\n\n AppWrapper = createApp({\n plugins: [\n ").concat(plugins.map(function(param) {
233
234
  var name = param.name, options = param.options, args = param.args;
234
235
  return "".concat(name, "({...").concat(options, ", ...finalAppConfig?.").concat(args || name, "}),");
235
- }).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper);" : "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);", "\n }\n\n return AppWrapper\n");
236
+ }).join("\n"), "\n ]\n })(").concat(fileSystemRoutes2 ? "" : "App", ")\n\n\n if(!AppWrapper.init && typeof appInit !== 'undefined') {\n AppWrapper.init = appInit;\n }\n\n\n if (IS_BROWSER) {\n ").concat(customBootstrap ? "customBootstrap(AppWrapper, () => ".concat(bootstrap, ");") : "".concat(bootstrap, ";"), "\n }\n\n return AppWrapper\n");
236
237
  };
237
238
  var html = function(partials) {
238
239
  return "\n<!DOCTYPE html>\n<html>\n<head>\n <%= meta %>\n <title><%= title %></title>\n\n ".concat(partials.top.join("\n"), "\n\n <script>\n window.__assetPrefix__ = '<%= assetPrefix %>';\n </script>\n ").concat(partials.head.join("\n"), "\n\n <!--<?- chunksMap.css ?>-->\n</head>\n\n<body>\n <noscript>\n We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.\n </noscript>\n <div id=\"<%= mountId %>\"><!--<?- html ?>--></div>\n ").concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
@@ -243,8 +244,8 @@ var routesForServer = function(param) {
243
244
  var traverseRouteTree = function(route) {
244
245
  var children;
245
246
  if ("children" in route && route.children) {
246
- var ref;
247
- children = route === null || route === void 0 ? void 0 : (ref = route.children) === null || ref === void 0 ? void 0 : ref.map(traverseRouteTree);
247
+ var _route_children;
248
+ children = route === null || route === void 0 ? void 0 : (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
248
249
  }
249
250
  var loader;
250
251
  if (route.type === "nested") {
@@ -296,7 +297,7 @@ var routesForServer = function(param) {
296
297
  };
297
298
  var fileSystemRoutes = function() {
298
299
  var _ref = _asyncToGenerator(function(param) {
299
- var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _value, key, loaderInfo;
300
+ var routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, loadings, errors, loaders, loadersMap, loadersMapFile, importLazyCode, rootLayoutCode, getDataLoaderPath, traverseRouteTree, routeComponentsCode, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, newRoute, component, finalRoute, importLoadingCode, importErrorComponentsCode, importLoadersCode, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, _step_value, key, loaderInfo;
300
301
  return __generator(this, function(_state) {
301
302
  switch(_state.label){
302
303
  case 0:
@@ -321,8 +322,8 @@ var fileSystemRoutes = function() {
321
322
  traverseRouteTree = function(route) {
322
323
  var children;
323
324
  if ("children" in route && route.children) {
324
- var ref;
325
- children = route === null || route === void 0 ? void 0 : (ref = route.children) === null || ref === void 0 ? void 0 : ref.map(traverseRouteTree);
325
+ var _route_children;
326
+ children = route === null || route === void 0 ? void 0 : (_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.map(traverseRouteTree);
326
327
  }
327
328
  var loading;
328
329
  var error;
@@ -417,7 +418,7 @@ var fileSystemRoutes = function() {
417
418
  _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
418
419
  try {
419
420
  for(_iterator1 = Object.entries(loadersMap)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
420
- _value = _slicedToArray(_step1.value, 2), key = _value[0], loaderInfo = _value[1];
421
+ _step_value = _slicedToArray(_step1.value, 2), key = _step_value[0], loaderInfo = _step_value[1];
421
422
  if (loaderInfo.inline) {
422
423
  importLoadersCode += "import { loader as ".concat(key, ' } from "').concat(getDataLoaderPath(key)).concat(slash(loaderInfo.filePath), '";\n');
423
424
  } else {
@@ -333,7 +333,7 @@ var parseModule = function() {
333
333
  }();
334
334
  var hasLoader = function() {
335
335
  var _ref = _asyncToGenerator(function(filename) {
336
- var source, ref, moduleExports;
336
+ var source, _ref, moduleExports;
337
337
  return __generator(this, function(_state) {
338
338
  switch(_state.label){
339
339
  case 0:
@@ -351,10 +351,10 @@ var hasLoader = function() {
351
351
  })
352
352
  ];
353
353
  case 2:
354
- ref = _slicedToArray.apply(void 0, [
354
+ _ref = _slicedToArray.apply(void 0, [
355
355
  _state.sent(),
356
356
  2
357
- ]), moduleExports = ref[1];
357
+ ]), moduleExports = _ref[1];
358
358
  return [
359
359
  2,
360
360
  moduleExports.some(function(e) {
@@ -0,0 +1,6 @@
1
+ import { builderRspackProvider } from "@modern-js/builder-rspack-provider";
2
+ import { generateBuilder } from "../generator";
3
+ function createRspackBuilderForModern(options) {
4
+ return generateBuilder(options, builderRspackProvider);
5
+ }
6
+ export { createRspackBuilderForModern };
@@ -0,0 +1,64 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ import { join } from "path";
27
+ import { createCopyPattern } from "../../shared";
28
+ import { RouterPlugin } from "../webpackPlugins";
29
+ var PluginCompatModern = function(options) {
30
+ return {
31
+ name: "builder-plugin-compat-modern",
32
+ setup: function setup(api) {
33
+ var modernConfig = options.normalizedConfig, appContext = options.appContext;
34
+ api.modifyWebpackChain(function(chain, param) {
35
+ var CHAIN_ID = param.CHAIN_ID;
36
+ var _modernConfig_runtime;
37
+ chain.resolve.modules.add("node_modules").add(join(api.context.rootPath, "node_modules"));
38
+ if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
39
+ var defaultCopyPattern = createCopyPattern(appContext, modernConfig, "public", chain);
40
+ chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(function(args) {
41
+ var _args_;
42
+ return [
43
+ {
44
+ patterns: _toConsumableArray(((_args_ = args[0]) === null || _args_ === void 0 ? void 0 : _args_.patterns) || []).concat([
45
+ defaultCopyPattern
46
+ ])
47
+ }
48
+ ];
49
+ });
50
+ }
51
+ var entrypoints = appContext.entrypoints;
52
+ var existNestedRoutes = entrypoints.some(function(entrypoint) {
53
+ return entrypoint.nestedRoutesEntry;
54
+ });
55
+ var routerConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_runtime = modernConfig.runtime) === null || _modernConfig_runtime === void 0 ? void 0 : _modernConfig_runtime.router;
56
+ var routerManifest = Boolean(routerConfig === null || routerConfig === void 0 ? void 0 : routerConfig.manifest);
57
+ if (existNestedRoutes || routerManifest) {
58
+ chain.plugin("route-plugin").use(RouterPlugin);
59
+ }
60
+ });
61
+ }
62
+ };
63
+ };
64
+ export { PluginCompatModern };