@modern-js/app-tools 2.5.1-alpha.1 → 2.6.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 (336) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/cjs/analyze/generateCode.js +17 -19
  3. package/dist/cjs/analyze/getBundleEntry.js +5 -1
  4. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +4 -0
  5. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +4 -0
  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 +5 -0
  11. package/dist/cjs/analyze/isDefaultExportFunction.js +4 -0
  12. package/dist/cjs/analyze/nestedRoutes.js +4 -0
  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 -12
  26. package/dist/cjs/commands/serve.js +4 -17
  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 +4 -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 +26 -37
  38. package/dist/esm/analyze/getBundleEntry.js +2 -2
  39. package/dist/esm/analyze/index.js +2 -1
  40. package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  41. package/dist/esm/builder/builder-webpack/index.js +7 -11
  42. package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -0
  43. package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
  44. package/dist/esm/builder/shared/createCopyPattern.js +4 -0
  45. package/dist/esm/commands/build.js +2 -0
  46. package/dist/esm/commands/dev.js +9 -9
  47. package/dist/esm/commands/serve.js +1 -6
  48. package/dist/esm/config/default.js +2 -0
  49. package/dist/esm/config/legacy/createOutputConfig.js +2 -0
  50. package/dist/esm/config/legacy/createToolsConfig.js +4 -1
  51. package/dist/esm/index.js +2 -1
  52. package/dist/esm-node/analyze/generateCode.js +14 -20
  53. package/dist/esm-node/analyze/getBundleEntry.js +3 -2
  54. package/dist/esm-node/analyze/index.js +1 -0
  55. package/dist/esm-node/analyze/templates.js +1 -1
  56. package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
  57. package/dist/esm-node/builder/builder-webpack/index.js +6 -12
  58. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +1 -0
  59. package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
  60. package/dist/esm-node/builder/shared/createCopyPattern.js +4 -0
  61. package/dist/esm-node/commands/build.js +2 -0
  62. package/dist/esm-node/commands/dev.js +15 -12
  63. package/dist/esm-node/commands/serve.js +1 -18
  64. package/dist/esm-node/config/default.js +2 -0
  65. package/dist/esm-node/config/legacy/createOutputConfig.js +2 -0
  66. package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
  67. package/dist/esm-node/index.js +1 -0
  68. package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
  69. package/package.json +26 -26
  70. package/dist/js/modern/analyze/constants.js +0 -56
  71. package/dist/js/modern/analyze/generateCode.js +0 -247
  72. package/dist/js/modern/analyze/getBundleEntry.js +0 -71
  73. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
  74. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
  75. package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
  76. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
  77. package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
  78. package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
  79. package/dist/js/modern/analyze/getServerRoutes.js +0 -178
  80. package/dist/js/modern/analyze/index.js +0 -333
  81. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
  82. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
  83. package/dist/js/modern/analyze/nestedRoutes.js +0 -186
  84. package/dist/js/modern/analyze/templates.js +0 -328
  85. package/dist/js/modern/analyze/utils.js +0 -141
  86. package/dist/js/modern/builder/builder-rspack/index.js +0 -8
  87. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
  88. package/dist/js/modern/builder/builder-webpack/index.js +0 -93
  89. package/dist/js/modern/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -116
  90. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
  91. package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
  92. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
  93. package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -21
  94. package/dist/js/modern/builder/generator/index.js +0 -53
  95. package/dist/js/modern/builder/index.js +0 -39
  96. package/dist/js/modern/builder/shared/builderPlugins/adapterModern.js +0 -219
  97. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
  98. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
  99. package/dist/js/modern/builder/shared/createCopyPattern.js +0 -46
  100. package/dist/js/modern/builder/shared/index.js +0 -3
  101. package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +0 -7
  102. package/dist/js/modern/builder/shared/types.js +0 -0
  103. package/dist/js/modern/commands/build.js +0 -91
  104. package/dist/js/modern/commands/deploy.js +0 -28
  105. package/dist/js/modern/commands/dev.js +0 -109
  106. package/dist/js/modern/commands/index.js +0 -3
  107. package/dist/js/modern/commands/inspect.js +0 -38
  108. package/dist/js/modern/commands/serve.js +0 -54
  109. package/dist/js/modern/config/default.js +0 -175
  110. package/dist/js/modern/config/index.js +0 -3
  111. package/dist/js/modern/config/initialize/index.js +0 -12
  112. package/dist/js/modern/config/initialize/inits.js +0 -154
  113. package/dist/js/modern/config/legacy/createHtmlConfig.js +0 -35
  114. package/dist/js/modern/config/legacy/createOutputConfig.js +0 -68
  115. package/dist/js/modern/config/legacy/createSourceConfig.js +0 -39
  116. package/dist/js/modern/config/legacy/createToolsConfig.js +0 -42
  117. package/dist/js/modern/config/legacy/index.js +0 -51
  118. package/dist/js/modern/defineConfig.js +0 -27
  119. package/dist/js/modern/exports/server.js +0 -4
  120. package/dist/js/modern/hooks.js +0 -35
  121. package/dist/js/modern/index.js +0 -221
  122. package/dist/js/modern/initialize/index.js +0 -132
  123. package/dist/js/modern/locale/en.js +0 -36
  124. package/dist/js/modern/locale/index.js +0 -9
  125. package/dist/js/modern/locale/zh.js +0 -36
  126. package/dist/js/modern/schema/Schema.js +0 -40
  127. package/dist/js/modern/schema/index.js +0 -88
  128. package/dist/js/modern/schema/legacy.js +0 -148
  129. package/dist/js/modern/types/config/deploy.js +0 -0
  130. package/dist/js/modern/types/config/dev.js +0 -0
  131. package/dist/js/modern/types/config/experiments.js +0 -0
  132. package/dist/js/modern/types/config/html.js +0 -0
  133. package/dist/js/modern/types/config/index.js +0 -1
  134. package/dist/js/modern/types/config/output.js +0 -0
  135. package/dist/js/modern/types/config/performance.js +0 -0
  136. package/dist/js/modern/types/config/security.js +0 -0
  137. package/dist/js/modern/types/config/source.js +0 -0
  138. package/dist/js/modern/types/config/tools.js +0 -0
  139. package/dist/js/modern/types/hooks.js +0 -0
  140. package/dist/js/modern/types/index.js +0 -3
  141. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  142. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  143. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  144. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  145. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  146. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  147. package/dist/js/modern/types/utils.js +0 -0
  148. package/dist/js/modern/utils/config.js +0 -128
  149. package/dist/js/modern/utils/createServer.js +0 -75
  150. package/dist/js/modern/utils/env.js +0 -15
  151. package/dist/js/modern/utils/generateWatchFiles.js +0 -55
  152. package/dist/js/modern/utils/getSelectedEntries.js +0 -58
  153. package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
  154. package/dist/js/modern/utils/language.js +0 -8
  155. package/dist/js/modern/utils/printInstructions.js +0 -31
  156. package/dist/js/modern/utils/restart.js +0 -44
  157. package/dist/js/modern/utils/routes.js +0 -30
  158. package/dist/js/modern/utils/types.js +0 -0
  159. package/dist/js/node/analyze/constants.js +0 -100
  160. package/dist/js/node/analyze/generateCode.js +0 -271
  161. package/dist/js/node/analyze/getBundleEntry.js +0 -95
  162. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
  163. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
  164. package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
  165. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
  166. package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
  167. package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
  168. package/dist/js/node/analyze/getServerRoutes.js +0 -196
  169. package/dist/js/node/analyze/index.js +0 -340
  170. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
  171. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
  172. package/dist/js/node/analyze/nestedRoutes.js +0 -213
  173. package/dist/js/node/analyze/templates.js +0 -359
  174. package/dist/js/node/analyze/utils.js +0 -172
  175. package/dist/js/node/builder/builder-rspack/index.js +0 -31
  176. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  177. package/dist/js/node/builder/builder-webpack/index.js +0 -118
  178. package/dist/js/node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -140
  179. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
  180. package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
  181. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
  182. package/dist/js/node/builder/generator/getBuilderTargets.js +0 -39
  183. package/dist/js/node/builder/generator/index.js +0 -82
  184. package/dist/js/node/builder/index.js +0 -68
  185. package/dist/js/node/builder/shared/builderPlugins/adapterModern.js +0 -245
  186. package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -50
  187. package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -57
  188. package/dist/js/node/builder/shared/createCopyPattern.js +0 -75
  189. package/dist/js/node/builder/shared/index.js +0 -19
  190. package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +0 -28
  191. package/dist/js/node/builder/shared/types.js +0 -15
  192. package/dist/js/node/commands/build.js +0 -112
  193. package/dist/js/node/commands/deploy.js +0 -51
  194. package/dist/js/node/commands/dev.js +0 -126
  195. package/dist/js/node/commands/index.js +0 -19
  196. package/dist/js/node/commands/inspect.js +0 -61
  197. package/dist/js/node/commands/serve.js +0 -83
  198. package/dist/js/node/config/default.js +0 -197
  199. package/dist/js/node/config/index.js +0 -19
  200. package/dist/js/node/config/initialize/index.js +0 -35
  201. package/dist/js/node/config/initialize/inits.js +0 -177
  202. package/dist/js/node/config/legacy/createHtmlConfig.js +0 -58
  203. package/dist/js/node/config/legacy/createOutputConfig.js +0 -91
  204. package/dist/js/node/config/legacy/createSourceConfig.js +0 -62
  205. package/dist/js/node/config/legacy/createToolsConfig.js +0 -65
  206. package/dist/js/node/config/legacy/index.js +0 -75
  207. package/dist/js/node/defineConfig.js +0 -49
  208. package/dist/js/node/exports/server.js +0 -27
  209. package/dist/js/node/hooks.js +0 -54
  210. package/dist/js/node/index.js +0 -245
  211. package/dist/js/node/initialize/index.js +0 -141
  212. package/dist/js/node/locale/en.js +0 -59
  213. package/dist/js/node/locale/index.js +0 -33
  214. package/dist/js/node/locale/zh.js +0 -59
  215. package/dist/js/node/schema/Schema.js +0 -63
  216. package/dist/js/node/schema/index.js +0 -118
  217. package/dist/js/node/schema/legacy.js +0 -169
  218. package/dist/js/node/types/config/deploy.js +0 -15
  219. package/dist/js/node/types/config/dev.js +0 -15
  220. package/dist/js/node/types/config/experiments.js +0 -15
  221. package/dist/js/node/types/config/html.js +0 -15
  222. package/dist/js/node/types/config/index.js +0 -17
  223. package/dist/js/node/types/config/output.js +0 -15
  224. package/dist/js/node/types/config/performance.js +0 -15
  225. package/dist/js/node/types/config/security.js +0 -15
  226. package/dist/js/node/types/config/source.js +0 -15
  227. package/dist/js/node/types/config/tools.js +0 -15
  228. package/dist/js/node/types/hooks.js +0 -15
  229. package/dist/js/node/types/index.js +0 -19
  230. package/dist/js/node/types/legacyConfig/deploy.js +0 -15
  231. package/dist/js/node/types/legacyConfig/dev.js +0 -15
  232. package/dist/js/node/types/legacyConfig/index.js +0 -15
  233. package/dist/js/node/types/legacyConfig/output.js +0 -15
  234. package/dist/js/node/types/legacyConfig/source.js +0 -15
  235. package/dist/js/node/types/legacyConfig/tools.js +0 -15
  236. package/dist/js/node/types/utils.js +0 -15
  237. package/dist/js/node/utils/config.js +0 -153
  238. package/dist/js/node/utils/createServer.js +0 -106
  239. package/dist/js/node/utils/env.js +0 -38
  240. package/dist/js/node/utils/generateWatchFiles.js +0 -85
  241. package/dist/js/node/utils/getSelectedEntries.js +0 -81
  242. package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
  243. package/dist/js/node/utils/language.js +0 -31
  244. package/dist/js/node/utils/printInstructions.js +0 -54
  245. package/dist/js/node/utils/restart.js +0 -67
  246. package/dist/js/node/utils/routes.js +0 -59
  247. package/dist/js/node/utils/types.js +0 -15
  248. package/dist/js/treeshaking/analyze/constants.js +0 -42
  249. package/dist/js/treeshaking/analyze/generateCode.js +0 -485
  250. package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
  251. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
  252. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
  253. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
  254. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
  255. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
  256. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
  257. package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -224
  258. package/dist/js/treeshaking/analyze/index.js +0 -702
  259. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
  260. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
  261. package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -409
  262. package/dist/js/treeshaking/analyze/templates.js +0 -465
  263. package/dist/js/treeshaking/analyze/utils.js +0 -374
  264. package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
  265. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  266. package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
  267. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -346
  268. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
  269. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
  270. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
  271. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -16
  272. package/dist/js/treeshaking/builder/generator/index.js +0 -199
  273. package/dist/js/treeshaking/builder/index.js +0 -175
  274. package/dist/js/treeshaking/builder/shared/builderPlugins/adapterModern.js +0 -300
  275. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -110
  276. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -72
  277. package/dist/js/treeshaking/builder/shared/createCopyPattern.js +0 -40
  278. package/dist/js/treeshaking/builder/shared/index.js +0 -3
  279. package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +0 -5
  280. package/dist/js/treeshaking/builder/shared/types.js +0 -1
  281. package/dist/js/treeshaking/commands/build.js +0 -291
  282. package/dist/js/treeshaking/commands/deploy.js +0 -154
  283. package/dist/js/treeshaking/commands/dev.js +0 -301
  284. package/dist/js/treeshaking/commands/index.js +0 -3
  285. package/dist/js/treeshaking/commands/inspect.js +0 -149
  286. package/dist/js/treeshaking/commands/serve.js +0 -199
  287. package/dist/js/treeshaking/config/default.js +0 -210
  288. package/dist/js/treeshaking/config/index.js +0 -3
  289. package/dist/js/treeshaking/config/initialize/index.js +0 -10
  290. package/dist/js/treeshaking/config/initialize/inits.js +0 -211
  291. package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
  292. package/dist/js/treeshaking/config/legacy/createOutputConfig.js +0 -41
  293. package/dist/js/treeshaking/config/legacy/createSourceConfig.js +0 -42
  294. package/dist/js/treeshaking/config/legacy/createToolsConfig.js +0 -23
  295. package/dist/js/treeshaking/config/legacy/index.js +0 -38
  296. package/dist/js/treeshaking/defineConfig.js +0 -61
  297. package/dist/js/treeshaking/exports/server.js +0 -2
  298. package/dist/js/treeshaking/hooks.js +0 -29
  299. package/dist/js/treeshaking/index.js +0 -713
  300. package/dist/js/treeshaking/initialize/index.js +0 -284
  301. package/dist/js/treeshaking/locale/en.js +0 -38
  302. package/dist/js/treeshaking/locale/index.js +0 -9
  303. package/dist/js/treeshaking/locale/zh.js +0 -38
  304. package/dist/js/treeshaking/schema/Schema.js +0 -273
  305. package/dist/js/treeshaking/schema/index.js +0 -181
  306. package/dist/js/treeshaking/schema/legacy.js +0 -337
  307. package/dist/js/treeshaking/types/config/deploy.js +0 -1
  308. package/dist/js/treeshaking/types/config/dev.js +0 -1
  309. package/dist/js/treeshaking/types/config/experiments.js +0 -1
  310. package/dist/js/treeshaking/types/config/html.js +0 -1
  311. package/dist/js/treeshaking/types/config/index.js +0 -1
  312. package/dist/js/treeshaking/types/config/output.js +0 -1
  313. package/dist/js/treeshaking/types/config/performance.js +0 -1
  314. package/dist/js/treeshaking/types/config/security.js +0 -1
  315. package/dist/js/treeshaking/types/config/source.js +0 -1
  316. package/dist/js/treeshaking/types/config/tools.js +0 -1
  317. package/dist/js/treeshaking/types/hooks.js +0 -1
  318. package/dist/js/treeshaking/types/index.js +0 -3
  319. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
  320. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
  321. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
  322. package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
  323. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
  324. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
  325. package/dist/js/treeshaking/types/utils.js +0 -1
  326. package/dist/js/treeshaking/utils/config.js +0 -302
  327. package/dist/js/treeshaking/utils/createServer.js +0 -258
  328. package/dist/js/treeshaking/utils/env.js +0 -13
  329. package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
  330. package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
  331. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
  332. package/dist/js/treeshaking/utils/language.js +0 -6
  333. package/dist/js/treeshaking/utils/printInstructions.js +0 -152
  334. package/dist/js/treeshaking/utils/restart.js +0 -187
  335. package/dist/js/treeshaking/utils/routes.js +0 -153
  336. package/dist/js/treeshaking/utils/types.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.6.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 88f7b34: fix(app-tools): incorrect tools.esbuild config
8
+
9
+ fix(app-tools): 修复 tools.esbuild 格式与文档不一致的问题
10
+
11
+ - e1f799e: fix: use 0.0.0.0 instead of localhost as the default dev host
12
+ fix: 使用 0.0.0.0 代替 localhost 作为默认的 dev host
13
+ - 7915ab3: fix: should not assign nestedRoutesEntry to entrypoint if use v5 router
14
+ fix: 使用 v5 路由的时候,不应该在 entrypoint 上挂载 nestedRoutesEntry 属性
15
+ - 08cb975: feat: optimize worker build
16
+
17
+ feat: 优化 worker 构建
18
+
19
+ - Updated dependencies [671477d]
20
+ - Updated dependencies [b92d6db]
21
+ - Updated dependencies [36164a2]
22
+ - Updated dependencies [d638438]
23
+ - Updated dependencies [ba6db6e]
24
+ - Updated dependencies [ba6db6e]
25
+ - Updated dependencies [e1f799e]
26
+ - Updated dependencies [107f674]
27
+ - Updated dependencies [7915ab3]
28
+ - Updated dependencies [03d7f7d]
29
+ - Updated dependencies [1c76d0e]
30
+ - Updated dependencies [fae9d1b]
31
+ - Updated dependencies [49fa0b1]
32
+ - Updated dependencies [0fe658a]
33
+ - Updated dependencies [62930b9]
34
+ - @modern-js/builder-webpack-provider@2.6.0
35
+ - @modern-js/builder-shared@2.6.0
36
+ - @modern-js/prod-server@2.6.0
37
+ - @modern-js/plugin-data-loader@2.6.0
38
+ - @modern-js/server@2.6.0
39
+ - @modern-js/utils@2.6.0
40
+ - @modern-js/builder@2.6.0
41
+ - @modern-js/types@2.6.0
42
+ - @modern-js/builder-rspack-provider@2.6.0
43
+ - @modern-js/builder-plugin-esbuild@2.6.0
44
+ - @modern-js/builder-plugin-node-polyfill@2.6.0
45
+ - @modern-js/core@2.6.0
46
+ - @modern-js/plugin-i18n@2.6.0
47
+ - @modern-js/plugin-lint@2.6.0
48
+ - @modern-js/new-action@2.6.0
49
+ - @modern-js/node-bundle-require@2.6.0
50
+ - @modern-js/upgrade@2.6.0
51
+ - @modern-js/plugin@2.6.0
52
+
3
53
  ## 2.5.0
4
54
 
5
55
  ### 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
  ));
@@ -83,7 +87,6 @@ ${initialize || ""}`
83
87
  ).join("\n");
84
88
  };
85
89
  const generateCode = async (appContext, config, entrypoints, api) => {
86
- var _a, _b, _c;
87
90
  const {
88
91
  internalDirectory,
89
92
  srcDirectory,
@@ -92,7 +95,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
92
95
  packageName
93
96
  } = appContext;
94
97
  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";
98
+ const isV5 = (0, import_utils.isRouterV5)(config);
96
99
  const { mountId } = config.html;
97
100
  const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
98
101
  await Promise.all(entrypoints.map(generateEntryCode));
@@ -111,23 +114,18 @@ const generateCode = async (appContext, config, entrypoints, api) => {
111
114
  internalDirAlias
112
115
  });
113
116
  }
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);
117
+ if (!isV5 && entrypoint.nestedRoutesEntry) {
118
+ nestedRoute = await (0, import_nestedRoutes.walk)(
119
+ entrypoint.nestedRoutesEntry,
120
+ entrypoint.nestedRoutesEntry,
121
+ {
122
+ name: internalSrcAlias,
123
+ basename: srcDirectory
124
+ },
125
+ entrypoint.entryName
126
+ );
127
+ if (nestedRoute) {
128
+ initialRoutes.unshift(nestedRoute);
131
129
  }
132
130
  }
133
131
  const { routes } = await hookRunners.modifyFileSystemRoutes({
@@ -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
  ));
@@ -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
  ));
@@ -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
  ));
@@ -219,6 +223,7 @@ var analyze_default = ({
219
223
  resolved: config
220
224
  };
221
225
  },
226
+ // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
222
227
  async modifyEntryImports({ entrypoint, imports }) {
223
228
  const appContext = api.useAppContext();
224
229
  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
  ));
@@ -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,14 +60,9 @@ 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
- appContext: {
65
- appDirectory: appContext.appDirectory,
66
- sharedDirectory: appContext.sharedDirectory,
67
- apiDirectory: appContext.apiDirectory,
68
- lambdaDirectory: appContext.lambdaDirectory
69
- },
70
66
  pwd: appDirectory,
71
67
  config: normalizedConfig,
72
68
  serverConfigFile,
@@ -77,12 +73,19 @@ const dev = async (api, options) => {
77
73
  ...serverOptions,
78
74
  compiler: null
79
75
  });
80
- app.listen(port, async (err) => {
81
- if (err) {
82
- throw err;
76
+ const host = ((_b = normalizedConfig.dev) == null ? void 0 : _b.host) || import_utils.DEFAULT_DEV_HOST;
77
+ app.listen(
78
+ {
79
+ port,
80
+ host
81
+ },
82
+ async (err) => {
83
+ if (err) {
84
+ throw err;
85
+ }
86
+ (0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
83
87
  }
84
- (0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
85
- });
88
+ );
86
89
  } else {
87
90
  const { server } = await appContext.builder.startDevServer({
88
91
  printURLs: false,
@@ -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
  ));
@@ -46,23 +50,6 @@ const start = async (api) => {
46
50
  const app = await (0, import_prod_server.default)({
47
51
  pwd: appDirectory,
48
52
  config: userConfig,
49
- appContext: {
50
- sharedDirectory: (0, import_utils.getTargetDir)(
51
- appContext.sharedDirectory,
52
- appContext.appDirectory,
53
- appContext.distDirectory
54
- ),
55
- apiDirectory: (0, import_utils.getTargetDir)(
56
- appContext.apiDirectory,
57
- appContext.appDirectory,
58
- appContext.distDirectory
59
- ),
60
- lambdaDirectory: (0, import_utils.getTargetDir)(
61
- appContext.lambdaDirectory,
62
- appContext.appDirectory,
63
- appContext.distDirectory
64
- )
65
- },
66
53
  serverConfigFile,
67
54
  internalPlugins: (0, import_createServer.injectDataLoaderPlugin)(serverInternalPlugins),
68
55
  apiOnly
@@ -26,6 +26,8 @@ function createDefaultConfig(appContext, bundler) {
26
26
  const defaultBuilderConfig = (0, import_builder_webpack_provider.createDefaultConfig)();
27
27
  const dev = {
28
28
  ...defaultBuilderConfig.dev,
29
+ // `dev.port` should not have a default value
30
+ // because we will use `server.port` by default
29
31
  port: void 0
30
32
  };
31
33
  const output = {
@@ -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
  ));
@@ -55,6 +55,7 @@ function createOutputConfig(config) {
55
55
  css: cssPath,
56
56
  js: jsPath,
57
57
  html: htmlPath,
58
+ // modern.js v1 output all media files to `dist/media` by default
58
59
  svg: mediaPath || "media",
59
60
  image: mediaPath || "media",
60
61
  font: mediaPath || "media",
@@ -80,6 +81,7 @@ function createOutputConfig(config) {
80
81
  disableFilenameHash: disableAssetsCache,
81
82
  enableLatestDecorators,
82
83
  ssg,
84
+ // set `true`, only in legacy config
83
85
  enableAssetFallback: true,
84
86
  enableAssetManifest: true,
85
87
  disableNodePolyfill
@@ -56,7 +56,10 @@ function createToolsConfig(config) {
56
56
  devServer,
57
57
  tailwindcss,
58
58
  jest,
59
- esbuild
59
+ esbuild: {
60
+ loader: false,
61
+ minimize: esbuild
62
+ }
60
63
  };
61
64
  }
62
65
  // Annotate the CommonJS export names for ESM import in node:
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  };
19
19
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
20
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
25
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
26
  mod
23
27
  ));
@@ -174,6 +178,7 @@ var src_default = (options = {
174
178
  const config = api.useResolvedConfigContext();
175
179
  return (0, import_generateWatchFiles.generateWatchFiles)(appContext, config.source.configDir);
176
180
  },
181
+ // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
177
182
  async fileChange(e) {
178
183
  const { filename, eventType } = e;
179
184
  const appContext = api.useAppContext();