@modern-js/app-tools 2.5.1-alpha.1 → 2.7.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 (344) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/cjs/analyze/generateCode.js +18 -23
  3. package/dist/cjs/analyze/getBundleEntry.js +5 -1
  4. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +5 -1
  5. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +5 -1
  6. package/dist/cjs/analyze/getClientRoutes/utils.js +4 -0
  7. package/dist/cjs/analyze/getFileSystemEntry.js +4 -0
  8. package/dist/cjs/analyze/getHtmlTemplate.js +4 -0
  9. package/dist/cjs/analyze/getServerRoutes.js +4 -0
  10. package/dist/cjs/analyze/index.js +11 -1
  11. package/dist/cjs/analyze/isDefaultExportFunction.js +4 -0
  12. package/dist/cjs/analyze/nestedRoutes.js +5 -1
  13. package/dist/cjs/analyze/templates.js +5 -1
  14. package/dist/cjs/analyze/utils.js +4 -0
  15. package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
  16. package/dist/cjs/builder/builder-webpack/index.js +9 -11
  17. package/dist/cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js +4 -0
  18. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +1 -0
  19. package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
  20. package/dist/cjs/builder/generator/index.js +4 -0
  21. package/dist/cjs/builder/index.js +4 -0
  22. package/dist/cjs/builder/shared/builderPlugins/adapterModern.js +4 -0
  23. package/dist/cjs/builder/shared/createCopyPattern.js +8 -0
  24. package/dist/cjs/commands/build.js +2 -0
  25. package/dist/cjs/commands/dev.js +15 -6
  26. package/dist/cjs/commands/serve.js +4 -0
  27. package/dist/cjs/config/default.js +2 -0
  28. package/dist/cjs/config/initialize/inits.js +4 -0
  29. package/dist/cjs/config/legacy/createOutputConfig.js +2 -0
  30. package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
  31. package/dist/cjs/index.js +5 -0
  32. package/dist/cjs/schema/index.js +8 -0
  33. package/dist/cjs/utils/config.js +4 -0
  34. package/dist/cjs/utils/createServer.js +4 -0
  35. package/dist/cjs/utils/generateWatchFiles.js +4 -0
  36. package/dist/cjs/utils/routes.js +4 -0
  37. package/dist/esm/analyze/generateCode.js +27 -41
  38. package/dist/esm/analyze/getBundleEntry.js +2 -2
  39. package/dist/esm/analyze/getClientRoutes/getRoutes.js +1 -1
  40. package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
  41. package/dist/esm/analyze/index.js +6 -2
  42. package/dist/esm/analyze/nestedRoutes.js +1 -1
  43. package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  44. package/dist/esm/builder/builder-webpack/index.js +7 -11
  45. package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -0
  46. package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
  47. package/dist/esm/builder/shared/createCopyPattern.js +4 -0
  48. package/dist/esm/commands/build.js +2 -0
  49. package/dist/esm/commands/dev.js +9 -3
  50. package/dist/esm/config/default.js +2 -0
  51. package/dist/esm/config/legacy/createOutputConfig.js +2 -0
  52. package/dist/esm/config/legacy/createToolsConfig.js +4 -1
  53. package/dist/esm/index.js +2 -1
  54. package/dist/esm/schema/index.js +7 -0
  55. package/dist/esm-node/analyze/generateCode.js +15 -26
  56. package/dist/esm-node/analyze/getBundleEntry.js +3 -2
  57. package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +1 -1
  58. package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
  59. package/dist/esm-node/analyze/index.js +7 -1
  60. package/dist/esm-node/analyze/nestedRoutes.js +1 -1
  61. package/dist/esm-node/analyze/templates.js +1 -1
  62. package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  63. package/dist/esm-node/builder/builder-webpack/index.js +6 -12
  64. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +1 -0
  65. package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
  66. package/dist/esm-node/builder/shared/createCopyPattern.js +4 -0
  67. package/dist/esm-node/commands/build.js +2 -0
  68. package/dist/esm-node/commands/dev.js +15 -6
  69. package/dist/esm-node/config/default.js +2 -0
  70. package/dist/esm-node/config/legacy/createOutputConfig.js +2 -0
  71. package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
  72. package/dist/esm-node/index.js +1 -0
  73. package/dist/esm-node/schema/index.js +4 -0
  74. package/dist/types/analyze/templates.d.ts +2 -2
  75. package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
  76. package/lib/types.d.ts +1 -1
  77. package/package.json +26 -26
  78. package/dist/js/modern/analyze/constants.js +0 -56
  79. package/dist/js/modern/analyze/generateCode.js +0 -247
  80. package/dist/js/modern/analyze/getBundleEntry.js +0 -71
  81. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
  82. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
  83. package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
  84. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
  85. package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
  86. package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
  87. package/dist/js/modern/analyze/getServerRoutes.js +0 -178
  88. package/dist/js/modern/analyze/index.js +0 -333
  89. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
  90. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
  91. package/dist/js/modern/analyze/nestedRoutes.js +0 -186
  92. package/dist/js/modern/analyze/templates.js +0 -328
  93. package/dist/js/modern/analyze/utils.js +0 -141
  94. package/dist/js/modern/builder/builder-rspack/index.js +0 -8
  95. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
  96. package/dist/js/modern/builder/builder-webpack/index.js +0 -93
  97. package/dist/js/modern/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -116
  98. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
  99. package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
  100. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
  101. package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -21
  102. package/dist/js/modern/builder/generator/index.js +0 -53
  103. package/dist/js/modern/builder/index.js +0 -39
  104. package/dist/js/modern/builder/shared/builderPlugins/adapterModern.js +0 -219
  105. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
  106. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
  107. package/dist/js/modern/builder/shared/createCopyPattern.js +0 -46
  108. package/dist/js/modern/builder/shared/index.js +0 -3
  109. package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +0 -7
  110. package/dist/js/modern/builder/shared/types.js +0 -0
  111. package/dist/js/modern/commands/build.js +0 -91
  112. package/dist/js/modern/commands/deploy.js +0 -28
  113. package/dist/js/modern/commands/dev.js +0 -109
  114. package/dist/js/modern/commands/index.js +0 -3
  115. package/dist/js/modern/commands/inspect.js +0 -38
  116. package/dist/js/modern/commands/serve.js +0 -54
  117. package/dist/js/modern/config/default.js +0 -175
  118. package/dist/js/modern/config/index.js +0 -3
  119. package/dist/js/modern/config/initialize/index.js +0 -12
  120. package/dist/js/modern/config/initialize/inits.js +0 -154
  121. package/dist/js/modern/config/legacy/createHtmlConfig.js +0 -35
  122. package/dist/js/modern/config/legacy/createOutputConfig.js +0 -68
  123. package/dist/js/modern/config/legacy/createSourceConfig.js +0 -39
  124. package/dist/js/modern/config/legacy/createToolsConfig.js +0 -42
  125. package/dist/js/modern/config/legacy/index.js +0 -51
  126. package/dist/js/modern/defineConfig.js +0 -27
  127. package/dist/js/modern/exports/server.js +0 -4
  128. package/dist/js/modern/hooks.js +0 -35
  129. package/dist/js/modern/index.js +0 -221
  130. package/dist/js/modern/initialize/index.js +0 -132
  131. package/dist/js/modern/locale/en.js +0 -36
  132. package/dist/js/modern/locale/index.js +0 -9
  133. package/dist/js/modern/locale/zh.js +0 -36
  134. package/dist/js/modern/schema/Schema.js +0 -40
  135. package/dist/js/modern/schema/index.js +0 -88
  136. package/dist/js/modern/schema/legacy.js +0 -148
  137. package/dist/js/modern/types/config/deploy.js +0 -0
  138. package/dist/js/modern/types/config/dev.js +0 -0
  139. package/dist/js/modern/types/config/experiments.js +0 -0
  140. package/dist/js/modern/types/config/html.js +0 -0
  141. package/dist/js/modern/types/config/index.js +0 -1
  142. package/dist/js/modern/types/config/output.js +0 -0
  143. package/dist/js/modern/types/config/performance.js +0 -0
  144. package/dist/js/modern/types/config/security.js +0 -0
  145. package/dist/js/modern/types/config/source.js +0 -0
  146. package/dist/js/modern/types/config/tools.js +0 -0
  147. package/dist/js/modern/types/hooks.js +0 -0
  148. package/dist/js/modern/types/index.js +0 -3
  149. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  150. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  151. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  152. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  153. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  154. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  155. package/dist/js/modern/types/utils.js +0 -0
  156. package/dist/js/modern/utils/config.js +0 -128
  157. package/dist/js/modern/utils/createServer.js +0 -75
  158. package/dist/js/modern/utils/env.js +0 -15
  159. package/dist/js/modern/utils/generateWatchFiles.js +0 -55
  160. package/dist/js/modern/utils/getSelectedEntries.js +0 -58
  161. package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
  162. package/dist/js/modern/utils/language.js +0 -8
  163. package/dist/js/modern/utils/printInstructions.js +0 -31
  164. package/dist/js/modern/utils/restart.js +0 -44
  165. package/dist/js/modern/utils/routes.js +0 -30
  166. package/dist/js/modern/utils/types.js +0 -0
  167. package/dist/js/node/analyze/constants.js +0 -100
  168. package/dist/js/node/analyze/generateCode.js +0 -271
  169. package/dist/js/node/analyze/getBundleEntry.js +0 -95
  170. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
  171. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
  172. package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
  173. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
  174. package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
  175. package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
  176. package/dist/js/node/analyze/getServerRoutes.js +0 -196
  177. package/dist/js/node/analyze/index.js +0 -340
  178. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
  179. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
  180. package/dist/js/node/analyze/nestedRoutes.js +0 -213
  181. package/dist/js/node/analyze/templates.js +0 -359
  182. package/dist/js/node/analyze/utils.js +0 -172
  183. package/dist/js/node/builder/builder-rspack/index.js +0 -31
  184. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  185. package/dist/js/node/builder/builder-webpack/index.js +0 -118
  186. package/dist/js/node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -140
  187. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
  188. package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
  189. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
  190. package/dist/js/node/builder/generator/getBuilderTargets.js +0 -39
  191. package/dist/js/node/builder/generator/index.js +0 -82
  192. package/dist/js/node/builder/index.js +0 -68
  193. package/dist/js/node/builder/shared/builderPlugins/adapterModern.js +0 -245
  194. package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -50
  195. package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -57
  196. package/dist/js/node/builder/shared/createCopyPattern.js +0 -75
  197. package/dist/js/node/builder/shared/index.js +0 -19
  198. package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +0 -28
  199. package/dist/js/node/builder/shared/types.js +0 -15
  200. package/dist/js/node/commands/build.js +0 -112
  201. package/dist/js/node/commands/deploy.js +0 -51
  202. package/dist/js/node/commands/dev.js +0 -126
  203. package/dist/js/node/commands/index.js +0 -19
  204. package/dist/js/node/commands/inspect.js +0 -61
  205. package/dist/js/node/commands/serve.js +0 -83
  206. package/dist/js/node/config/default.js +0 -197
  207. package/dist/js/node/config/index.js +0 -19
  208. package/dist/js/node/config/initialize/index.js +0 -35
  209. package/dist/js/node/config/initialize/inits.js +0 -177
  210. package/dist/js/node/config/legacy/createHtmlConfig.js +0 -58
  211. package/dist/js/node/config/legacy/createOutputConfig.js +0 -91
  212. package/dist/js/node/config/legacy/createSourceConfig.js +0 -62
  213. package/dist/js/node/config/legacy/createToolsConfig.js +0 -65
  214. package/dist/js/node/config/legacy/index.js +0 -75
  215. package/dist/js/node/defineConfig.js +0 -49
  216. package/dist/js/node/exports/server.js +0 -27
  217. package/dist/js/node/hooks.js +0 -54
  218. package/dist/js/node/index.js +0 -245
  219. package/dist/js/node/initialize/index.js +0 -141
  220. package/dist/js/node/locale/en.js +0 -59
  221. package/dist/js/node/locale/index.js +0 -33
  222. package/dist/js/node/locale/zh.js +0 -59
  223. package/dist/js/node/schema/Schema.js +0 -63
  224. package/dist/js/node/schema/index.js +0 -118
  225. package/dist/js/node/schema/legacy.js +0 -169
  226. package/dist/js/node/types/config/deploy.js +0 -15
  227. package/dist/js/node/types/config/dev.js +0 -15
  228. package/dist/js/node/types/config/experiments.js +0 -15
  229. package/dist/js/node/types/config/html.js +0 -15
  230. package/dist/js/node/types/config/index.js +0 -17
  231. package/dist/js/node/types/config/output.js +0 -15
  232. package/dist/js/node/types/config/performance.js +0 -15
  233. package/dist/js/node/types/config/security.js +0 -15
  234. package/dist/js/node/types/config/source.js +0 -15
  235. package/dist/js/node/types/config/tools.js +0 -15
  236. package/dist/js/node/types/hooks.js +0 -15
  237. package/dist/js/node/types/index.js +0 -19
  238. package/dist/js/node/types/legacyConfig/deploy.js +0 -15
  239. package/dist/js/node/types/legacyConfig/dev.js +0 -15
  240. package/dist/js/node/types/legacyConfig/index.js +0 -15
  241. package/dist/js/node/types/legacyConfig/output.js +0 -15
  242. package/dist/js/node/types/legacyConfig/source.js +0 -15
  243. package/dist/js/node/types/legacyConfig/tools.js +0 -15
  244. package/dist/js/node/types/utils.js +0 -15
  245. package/dist/js/node/utils/config.js +0 -153
  246. package/dist/js/node/utils/createServer.js +0 -106
  247. package/dist/js/node/utils/env.js +0 -38
  248. package/dist/js/node/utils/generateWatchFiles.js +0 -85
  249. package/dist/js/node/utils/getSelectedEntries.js +0 -81
  250. package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
  251. package/dist/js/node/utils/language.js +0 -31
  252. package/dist/js/node/utils/printInstructions.js +0 -54
  253. package/dist/js/node/utils/restart.js +0 -67
  254. package/dist/js/node/utils/routes.js +0 -59
  255. package/dist/js/node/utils/types.js +0 -15
  256. package/dist/js/treeshaking/analyze/constants.js +0 -42
  257. package/dist/js/treeshaking/analyze/generateCode.js +0 -485
  258. package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
  259. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
  260. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
  261. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
  262. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
  263. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
  264. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
  265. package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -224
  266. package/dist/js/treeshaking/analyze/index.js +0 -702
  267. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
  268. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
  269. package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -409
  270. package/dist/js/treeshaking/analyze/templates.js +0 -465
  271. package/dist/js/treeshaking/analyze/utils.js +0 -374
  272. package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
  273. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  274. package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
  275. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -346
  276. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
  277. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
  278. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
  279. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -16
  280. package/dist/js/treeshaking/builder/generator/index.js +0 -199
  281. package/dist/js/treeshaking/builder/index.js +0 -175
  282. package/dist/js/treeshaking/builder/shared/builderPlugins/adapterModern.js +0 -300
  283. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -110
  284. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -72
  285. package/dist/js/treeshaking/builder/shared/createCopyPattern.js +0 -40
  286. package/dist/js/treeshaking/builder/shared/index.js +0 -3
  287. package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +0 -5
  288. package/dist/js/treeshaking/builder/shared/types.js +0 -1
  289. package/dist/js/treeshaking/commands/build.js +0 -291
  290. package/dist/js/treeshaking/commands/deploy.js +0 -154
  291. package/dist/js/treeshaking/commands/dev.js +0 -301
  292. package/dist/js/treeshaking/commands/index.js +0 -3
  293. package/dist/js/treeshaking/commands/inspect.js +0 -149
  294. package/dist/js/treeshaking/commands/serve.js +0 -199
  295. package/dist/js/treeshaking/config/default.js +0 -210
  296. package/dist/js/treeshaking/config/index.js +0 -3
  297. package/dist/js/treeshaking/config/initialize/index.js +0 -10
  298. package/dist/js/treeshaking/config/initialize/inits.js +0 -211
  299. package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
  300. package/dist/js/treeshaking/config/legacy/createOutputConfig.js +0 -41
  301. package/dist/js/treeshaking/config/legacy/createSourceConfig.js +0 -42
  302. package/dist/js/treeshaking/config/legacy/createToolsConfig.js +0 -23
  303. package/dist/js/treeshaking/config/legacy/index.js +0 -38
  304. package/dist/js/treeshaking/defineConfig.js +0 -61
  305. package/dist/js/treeshaking/exports/server.js +0 -2
  306. package/dist/js/treeshaking/hooks.js +0 -29
  307. package/dist/js/treeshaking/index.js +0 -713
  308. package/dist/js/treeshaking/initialize/index.js +0 -284
  309. package/dist/js/treeshaking/locale/en.js +0 -38
  310. package/dist/js/treeshaking/locale/index.js +0 -9
  311. package/dist/js/treeshaking/locale/zh.js +0 -38
  312. package/dist/js/treeshaking/schema/Schema.js +0 -273
  313. package/dist/js/treeshaking/schema/index.js +0 -181
  314. package/dist/js/treeshaking/schema/legacy.js +0 -337
  315. package/dist/js/treeshaking/types/config/deploy.js +0 -1
  316. package/dist/js/treeshaking/types/config/dev.js +0 -1
  317. package/dist/js/treeshaking/types/config/experiments.js +0 -1
  318. package/dist/js/treeshaking/types/config/html.js +0 -1
  319. package/dist/js/treeshaking/types/config/index.js +0 -1
  320. package/dist/js/treeshaking/types/config/output.js +0 -1
  321. package/dist/js/treeshaking/types/config/performance.js +0 -1
  322. package/dist/js/treeshaking/types/config/security.js +0 -1
  323. package/dist/js/treeshaking/types/config/source.js +0 -1
  324. package/dist/js/treeshaking/types/config/tools.js +0 -1
  325. package/dist/js/treeshaking/types/hooks.js +0 -1
  326. package/dist/js/treeshaking/types/index.js +0 -3
  327. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
  328. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
  329. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
  330. package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
  331. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
  332. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
  333. package/dist/js/treeshaking/types/utils.js +0 -1
  334. package/dist/js/treeshaking/utils/config.js +0 -302
  335. package/dist/js/treeshaking/utils/createServer.js +0 -258
  336. package/dist/js/treeshaking/utils/env.js +0 -13
  337. package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
  338. package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
  339. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
  340. package/dist/js/treeshaking/utils/language.js +0 -6
  341. package/dist/js/treeshaking/utils/printInstructions.js +0 -152
  342. package/dist/js/treeshaking/utils/restart.js +0 -187
  343. package/dist/js/treeshaking/utils/routes.js +0 -153
  344. package/dist/js/treeshaking/utils/types.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,107 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dcad887024: feat: support deferred data for streaming ssr
8
+ feat: 流式渲染支持 deferred data
9
+ - 84bfb439b8: feat: support custom apiDir, lambdaDir and style of writing for bff
10
+ feat: 支持定制 api 目录,lambda 目录,bff 的写法
11
+
12
+ ### Patch Changes
13
+
14
+ - 0644f90567: feat: support optional params in file-based route
15
+ feat: 约定式路由支持可选参数
16
+ - 6547de8dd4: fix: use api.useResolvedConfigContext instead useResolvedConfigContext from @modern-js/core
17
+ fix: 使用 api.useResolvedConfigContext 代替从 @modern-js/core 中导出的 useResolvedConfigContext
18
+ - 1eea234fdd: chore: make test files naming consistent
19
+
20
+ chore: 统一测试文件命名为小驼峰格式
21
+
22
+ - Updated dependencies [206c806efa]
23
+ - Updated dependencies [a729b0d366]
24
+ - Updated dependencies [dfece9dc1c]
25
+ - Updated dependencies [6378e26bf9]
26
+ - Updated dependencies [0f15fc597c]
27
+ - Updated dependencies [3a942a2472]
28
+ - Updated dependencies [5f899af53a]
29
+ - Updated dependencies [dcad887024]
30
+ - Updated dependencies [a4672f7c16]
31
+ - Updated dependencies [1b913372b4]
32
+ - Updated dependencies [ebe0d2dd6e]
33
+ - Updated dependencies [7fff9020e1]
34
+ - Updated dependencies [1eea234fdd]
35
+ - Updated dependencies [84bfb439b8]
36
+ - @modern-js/builder-rspack-provider@2.7.0
37
+ - @modern-js/builder-shared@2.7.0
38
+ - @modern-js/builder-webpack-provider@2.7.0
39
+ - @modern-js/core@2.7.0
40
+ - @modern-js/builder@2.7.0
41
+ - @modern-js/server@2.7.0
42
+ - @modern-js/utils@2.7.0
43
+ - @modern-js/plugin-data-loader@2.7.0
44
+ - @modern-js/types@2.7.0
45
+ - @modern-js/plugin-i18n@2.7.0
46
+ - @modern-js/plugin-lint@2.7.0
47
+ - @modern-js/prod-server@2.7.0
48
+ - @modern-js/node-bundle-require@2.7.0
49
+ - @modern-js/builder-plugin-esbuild@2.7.0
50
+ - @modern-js/builder-plugin-node-polyfill@2.7.0
51
+ - @modern-js/new-action@2.7.0
52
+ - @modern-js/upgrade@2.7.0
53
+ - @modern-js/plugin@2.7.0
54
+
55
+ ## 2.6.0
56
+
57
+ ### Patch Changes
58
+
59
+ - 88f7b34: fix(app-tools): incorrect tools.esbuild config
60
+
61
+ fix(app-tools): 修复 tools.esbuild 格式与文档不一致的问题
62
+
63
+ - e1f799e: fix: use 0.0.0.0 instead of localhost as the default dev host
64
+ fix: 使用 0.0.0.0 代替 localhost 作为默认的 dev host
65
+ - 7915ab3: fix: should not assign nestedRoutesEntry to entrypoint if use v5 router
66
+ fix: 使用 v5 路由的时候,不应该在 entrypoint 上挂载 nestedRoutesEntry 属性
67
+ - 08cb975: feat: optimize worker build
68
+
69
+ feat: 优化 worker 构建
70
+
71
+ - Updated dependencies [671477d]
72
+ - Updated dependencies [b92d6db]
73
+ - Updated dependencies [36164a2]
74
+ - Updated dependencies [d638438]
75
+ - Updated dependencies [ba6db6e]
76
+ - Updated dependencies [ba6db6e]
77
+ - Updated dependencies [e1f799e]
78
+ - Updated dependencies [107f674]
79
+ - Updated dependencies [7915ab3]
80
+ - Updated dependencies [03d7f7d]
81
+ - Updated dependencies [1c76d0e]
82
+ - Updated dependencies [fae9d1b]
83
+ - Updated dependencies [49fa0b1]
84
+ - Updated dependencies [0fe658a]
85
+ - Updated dependencies [62930b9]
86
+ - @modern-js/builder-webpack-provider@2.6.0
87
+ - @modern-js/builder-shared@2.6.0
88
+ - @modern-js/prod-server@2.6.0
89
+ - @modern-js/plugin-data-loader@2.6.0
90
+ - @modern-js/server@2.6.0
91
+ - @modern-js/utils@2.6.0
92
+ - @modern-js/builder@2.6.0
93
+ - @modern-js/types@2.6.0
94
+ - @modern-js/builder-rspack-provider@2.6.0
95
+ - @modern-js/builder-plugin-esbuild@2.6.0
96
+ - @modern-js/builder-plugin-node-polyfill@2.6.0
97
+ - @modern-js/core@2.6.0
98
+ - @modern-js/plugin-i18n@2.6.0
99
+ - @modern-js/plugin-lint@2.6.0
100
+ - @modern-js/new-action@2.6.0
101
+ - @modern-js/node-bundle-require@2.6.0
102
+ - @modern-js/upgrade@2.6.0
103
+ - @modern-js/plugin@2.6.0
104
+
3
105
  ## 2.5.0
4
106
 
5
107
  ### Patch Changes
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -29,7 +33,6 @@ __export(generateCode_exports, {
29
33
  module.exports = __toCommonJS(generateCode_exports);
30
34
  var import_path = __toESM(require("path"));
31
35
  var import_utils = require("@modern-js/utils");
32
- var import_core = require("@modern-js/core");
33
36
  var templates = __toESM(require("./templates"));
34
37
  var import_getClientRoutes = require("./getClientRoutes");
35
38
  var import_constants = require("./constants");
@@ -83,7 +86,6 @@ ${initialize || ""}`
83
86
  ).join("\n");
84
87
  };
85
88
  const generateCode = async (appContext, config, entrypoints, api) => {
86
- var _a, _b, _c;
87
89
  const {
88
90
  internalDirectory,
89
91
  srcDirectory,
@@ -92,7 +94,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
92
94
  packageName
93
95
  } = appContext;
94
96
  const hookRunners = api.useHookRunners();
95
- const isV5 = typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
97
+ const isV5 = (0, import_utils.isRouterV5)(config);
96
98
  const { mountId } = config.html;
97
99
  const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
98
100
  await Promise.all(entrypoints.map(generateEntryCode));
@@ -111,30 +113,25 @@ const generateCode = async (appContext, config, entrypoints, api) => {
111
113
  internalDirAlias
112
114
  });
113
115
  }
114
- if (entrypoint.nestedRoutesEntry) {
115
- if (!isV5) {
116
- nestedRoute = await (0, import_nestedRoutes.walk)(
117
- entrypoint.nestedRoutesEntry,
118
- entrypoint.nestedRoutesEntry,
119
- {
120
- name: internalSrcAlias,
121
- basename: srcDirectory
122
- },
123
- entrypoint.entryName
124
- );
125
- if (nestedRoute) {
126
- initialRoutes.unshift(nestedRoute);
127
- }
128
- } else {
129
- import_utils.logger.error("Nested routes is not supported in legacy mode.");
130
- process.exit(1);
116
+ if (!isV5 && entrypoint.nestedRoutesEntry) {
117
+ nestedRoute = await (0, import_nestedRoutes.walk)(
118
+ entrypoint.nestedRoutesEntry,
119
+ entrypoint.nestedRoutesEntry,
120
+ {
121
+ name: internalSrcAlias,
122
+ basename: srcDirectory
123
+ },
124
+ entrypoint.entryName
125
+ );
126
+ if (nestedRoute) {
127
+ initialRoutes.unshift(nestedRoute);
131
128
  }
132
129
  }
133
130
  const { routes } = await hookRunners.modifyFileSystemRoutes({
134
131
  entrypoint,
135
132
  routes: initialRoutes
136
133
  });
137
- const config2 = (0, import_core.useResolvedConfigContext)();
134
+ const config2 = api.useResolvedConfigContext();
138
135
  const ssr = (0, import_utils.getEntryOptions)(
139
136
  entryName,
140
137
  config2.server.ssr,
@@ -144,8 +141,6 @@ const generateCode = async (appContext, config, entrypoints, api) => {
144
141
  let mode;
145
142
  if (ssr) {
146
143
  mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
147
- } else {
148
- mode = false;
149
144
  }
150
145
  if (mode === "stream") {
151
146
  const hasPageRoute = routes.some(
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -78,7 +82,7 @@ const getBundleEntry = (appContext, config) => {
78
82
  customBootstrap: value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
79
83
  fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
80
84
  };
81
- if (entrypoint.fileSystemRoutes) {
85
+ if (entrypoint.fileSystemRoutes && (0, import_utils.isRouterV5)(config)) {
82
86
  entrypoint.nestedRoutesEntry = entrypoint.entry;
83
87
  }
84
88
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -93,7 +97,7 @@ const recursiveReadDir = ({
93
97
  }
94
98
  }
95
99
  const route = {
96
- path: `${basePath}${dynamicRouteMatched ? `:${dynamicRouteMatched[1]}${dynamicRouteMatched[2]}` : filename}`,
100
+ path: `${basePath}${dynamicRouteMatched ? `:${dynamicRouteMatched[1].replace(/\$$/, "?")}${dynamicRouteMatched[2]}` : filename}`,
97
101
  _component: alias,
98
102
  component: componentName,
99
103
  parent,
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -93,7 +97,7 @@ const recursiveReadDirLegacy = ({
93
97
  }
94
98
  }
95
99
  const route = {
96
- path: `${basePath}${dynamicRouteMatched ? `:${dynamicRouteMatched[1]}${dynamicRouteMatched[2]}` : filename}`,
100
+ path: `${basePath}${dynamicRouteMatched ? `:${dynamicRouteMatched[1].replace(/\$$/, "?")}${dynamicRouteMatched[2]}` : filename}`,
97
101
  _component: alias,
98
102
  component: componentName,
99
103
  exact: true,
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -29,6 +33,7 @@ module.exports = __toCommonJS(analyze_exports);
29
33
  var path = __toESM(require("path"));
30
34
  var import_utils = require("@modern-js/utils");
31
35
  var import_lodash = require("@modern-js/utils/lodash");
36
+ var import_builder_shared = require("@modern-js/builder-shared");
32
37
  var import_printInstructions = require("../utils/printInstructions");
33
38
  var import_routes = require("../utils/routes");
34
39
  var import_config = require("../utils/config");
@@ -201,11 +206,15 @@ var analyze_default = ({
201
206
  packageName
202
207
  );
203
208
  if (entrypoint.nestedRoutesEntry && ssr && name === "server") {
209
+ const serverLoaderRuntime = require.resolve("@modern-js/plugin-data-loader/runtime");
204
210
  const serverLoadersFile = (0, import_utils2.getServerLoadersFile)(
205
211
  internalDirectory,
206
212
  entryName
207
213
  );
208
- chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
214
+ const combinedModule = (0, import_builder_shared.createVirtualModule)(
215
+ `export * from "${serverLoaderRuntime}"; export * from "${serverLoadersFile}"`
216
+ );
217
+ chain.entry(`${entryName}-server-loaders`).add(combinedModule);
209
218
  }
210
219
  });
211
220
  }
@@ -219,6 +228,7 @@ var analyze_default = ({
219
228
  resolved: config
220
229
  };
221
230
  },
231
+ // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
222
232
  async modifyEntryImports({ entrypoint, imports }) {
223
233
  const appContext = api.useAppContext();
224
234
  const { srcDirectory, internalSrcAlias } = appContext;
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -75,7 +79,7 @@ const walk = async (dirname, rootDir, alias, entryName) => {
75
79
  }
76
80
  routePath = replaceDynamicPath(routePath);
77
81
  const route = {
78
- path: routePath,
82
+ path: routePath == null ? void 0 : routePath.replace(/\$$/, "?"),
79
83
  children: [],
80
84
  isRoot
81
85
  };
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -101,7 +105,7 @@ const html = (partials) => `
101
105
 
102
106
  <script>
103
107
  window.__assetPrefix__ = '<%= assetPrefix %>';
104
- <\/script>
108
+ </script>
105
109
  ${partials.head.join("\n")}
106
110
 
107
111
  <!--<?- chunksMap.css ?>-->
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,13 +17,13 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var compatModern_exports = {};
19
19
  __export(compatModern_exports, {
20
- PluginCompatModern: () => PluginCompatModern
20
+ builderPluginCompatModern: () => builderPluginCompatModern
21
21
  });
22
22
  module.exports = __toCommonJS(compatModern_exports);
23
23
  var import_path = require("path");
24
24
  var import_shared = require("../../shared");
25
25
  var import_webpackPlugins = require("../webpackPlugins");
26
- const PluginCompatModern = (options) => ({
26
+ const builderPluginCompatModern = (options) => ({
27
27
  name: "builder-plugin-compat-modern",
28
28
  setup(api) {
29
29
  const { normalizedConfig: modernConfig, appContext } = options;
@@ -60,5 +60,5 @@ const PluginCompatModern = (options) => ({
60
60
  });
61
61
  // Annotate the CommonJS export names for ESM import in node:
62
62
  0 && (module.exports = {
63
- PluginCompatModern
63
+ builderPluginCompatModern
64
64
  });
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -27,7 +31,6 @@ __export(builder_webpack_exports, {
27
31
  });
28
32
  module.exports = __toCommonJS(builder_webpack_exports);
29
33
  var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
30
- var import_utils = require("@modern-js/utils");
31
34
  var import_shared = require("../shared");
32
35
  var import_generator = require("../generator");
33
36
  var import_compatModern = require("./builderPlugins/compatModern");
@@ -57,20 +60,15 @@ function modifyOutputConfig(config, appContext) {
57
60
  async function applyBuilderPlugins(builder, options) {
58
61
  const { normalizedConfig } = options;
59
62
  if (!normalizedConfig.output.disableNodePolyfill) {
60
- const { PluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
61
- builder.addPlugins([PluginNodePolyfill()]);
63
+ const { builderPluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
64
+ builder.addPlugins([builderPluginNodePolyfill()]);
62
65
  }
63
66
  if (normalizedConfig.tools.esbuild) {
64
67
  const { esbuild: esbuildOptions } = normalizedConfig.tools;
65
- const { PluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
66
- builder.addPlugins([
67
- PluginEsbuild({
68
- loader: false,
69
- minimize: (0, import_utils.applyOptionsChain)({}, esbuildOptions)
70
- })
71
- ]);
68
+ const { builderPluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
69
+ builder.addPlugins([builderPluginEsbuild(esbuildOptions)]);
72
70
  }
73
- builder.addPlugins([(0, import_compatModern.PluginCompatModern)(options)]);
71
+ builder.addPlugins([(0, import_compatModern.builderPluginCompatModern)(options)]);
74
72
  }
75
73
  // Annotate the CommonJS export names for ESM import in node:
76
74
  0 && (module.exports = {
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -37,6 +37,7 @@ function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderCon
37
37
  html: htmlConfig,
38
38
  output: {
39
39
  ...resolveConfig.output,
40
+ // We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
40
41
  cleanDistPath: false
41
42
  }
42
43
  };
@@ -27,7 +27,7 @@ function getBuilderTargets(normalizedConfig) {
27
27
  if (useNodeTarget) {
28
28
  targets.push("node");
29
29
  }
30
- const useWorkerTarget = (0, import_utils.isProd)() ? (0, import_utils.isServiceWorker)(normalizedConfig) : false;
30
+ const useWorkerTarget = (0, import_utils.isServiceWorker)(normalizedConfig);
31
31
  if (useWorkerTarget) {
32
32
  targets.push("service-worker");
33
33
  }
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
17
17
  return to;
18
18
  };
19
19
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
25
  mod
22
26
  ));
@@ -37,6 +41,9 @@ function createCopyPattern(appContext, config, patternsType, chain) {
37
41
  const publicDir = import_path.default.posix.join(configDir.replace(/\\/g, "/"), "public");
38
42
  const minifiedJsRexExp = /\.min\.js/;
39
43
  const info = (file) => ({
44
+ // If the file name ends with `.min.js`, we assume it's a compressed file.
45
+ // So we don't want copy-webpack-plugin to minify it.
46
+ // ref: https://github.com/webpack-contrib/copy-webpack-plugin#info
40
47
  minimized: minifiedJsRexExp.test(file.sourceFilename)
41
48
  });
42
49
  if (patternsType === "public") {
@@ -49,6 +56,7 @@ function createCopyPattern(appContext, config, patternsType, chain) {
49
56
  to: "public",
50
57
  context: publicDir,
51
58
  noErrorOnMissing: true,
59
+ // eslint-disable-next-line node/prefer-global/buffer
52
60
  transform: (content, absoluteFrom) => {
53
61
  if (!/\.html?$/.test(absoluteFrom)) {
54
62
  return content;
@@ -35,6 +35,7 @@ const build = async (api, options) => {
35
35
  if (apiOnly) {
36
36
  const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
37
37
  await hookRunners.beforeBuild({
38
+ // "null" bundlerConfigs
38
39
  bundlerConfigs: void 0
39
40
  });
40
41
  await (0, import_config.buildServerConfig)({
@@ -44,6 +45,7 @@ const build = async (api, options) => {
44
45
  });
45
46
  await (0, import_routes.generateRoutes)(appContext);
46
47
  await hookRunners.afterBuild({
48
+ // "null" stats
47
49
  stats: void 0
48
50
  });
49
51
  return;
@@ -21,13 +21,14 @@ __export(dev_exports, {
21
21
  });
22
22
  module.exports = __toCommonJS(dev_exports);
23
23
  var import_core = require("@modern-js/core");
24
+ var import_utils = require("@modern-js/utils");
24
25
  var import_printInstructions = require("../utils/printInstructions");
25
26
  var import_createServer = require("../utils/createServer");
26
27
  var import_routes = require("../utils/routes");
27
28
  var import_config = require("../utils/config");
28
29
  var import_getServerInternalPlugins = require("../utils/getServerInternalPlugins");
29
30
  const dev = async (api, options) => {
30
- var _a;
31
+ var _a, _b;
31
32
  if (options.analyze) {
32
33
  process.env.BUNDLE_ANALYZE = "true";
33
34
  }
@@ -59,6 +60,7 @@ const dev = async (api, options) => {
59
60
  dev: {
60
61
  port,
61
62
  https: normalizedConfig.dev.https,
63
+ host: normalizedConfig.dev.host,
62
64
  ...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
63
65
  },
64
66
  appContext: {
@@ -77,12 +79,19 @@ const dev = async (api, options) => {
77
79
  ...serverOptions,
78
80
  compiler: null
79
81
  });
80
- app.listen(port, async (err) => {
81
- if (err) {
82
- throw err;
82
+ const host = ((_b = normalizedConfig.dev) == null ? void 0 : _b.host) || import_utils.DEFAULT_DEV_HOST;
83
+ app.listen(
84
+ {
85
+ port,
86
+ host
87
+ },
88
+ async (err) => {
89
+ if (err) {
90
+ throw err;
91
+ }
92
+ (0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
83
93
  }
84
- (0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
85
- });
94
+ );
86
95
  } else {
87
96
  const { server } = await appContext.builder.startDevServer({
88
97
  printURLs: false,