@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
@@ -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
  ));
@@ -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();
@@ -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
  ));
@@ -60,6 +64,10 @@ const bff = {
60
64
  prefix: {
61
65
  type: "string"
62
66
  },
67
+ httpMethodDecider: {
68
+ type: "string",
69
+ enum: ["functionName", "inputParams"]
70
+ },
63
71
  proxy: {
64
72
  type: "object",
65
73
  additionalProperties: {
@@ -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
  ));
@@ -148,8 +148,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
148
148
  }
149
149
  };
150
150
  import path from "path";
151
- import { fs, getEntryOptions, logger } from "@modern-js/utils";
152
- import { useResolvedConfigContext } from "@modern-js/core";
151
+ import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
153
152
  import * as templates from "./templates";
154
153
  import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
155
154
  import { FILE_SYSTEM_ROUTES_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_BOOTSTRAP_FILE_NAME } from "./constants";
@@ -240,7 +239,7 @@ var createImportStatements = function(statements) {
240
239
  };
241
240
  var generateCode = function() {
242
241
  var _ref = _asyncToGenerator(function(appContext, config, entrypoints, api) {
243
- var _config_runtime, _config_runtime1, _config_runtime_router, internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
242
+ var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
244
243
  function generateEntryCode(entrypoint) {
245
244
  return _generateEntryCode.apply(this, arguments);
246
245
  }
@@ -253,11 +252,11 @@ var generateCode = function() {
253
252
  entryName = entrypoint.entryName, isAutoMount = entrypoint.isAutoMount, customBootstrap = entrypoint.customBootstrap, fileSystemRoutes = entrypoint.fileSystemRoutes;
254
253
  if (!isAutoMount) return [
255
254
  3,
256
- 17
255
+ 16
257
256
  ];
258
257
  if (!fileSystemRoutes) return [
259
258
  3,
260
- 10
259
+ 9
261
260
  ];
262
261
  initialRoutes = [];
263
262
  nestedRoute = null;
@@ -270,11 +269,7 @@ var generateCode = function() {
270
269
  internalDirAlias: internalDirAlias
271
270
  });
272
271
  }
273
- if (!entrypoint.nestedRoutesEntry) return [
274
- 3,
275
- 3
276
- ];
277
- if (!!isV5) return [
272
+ if (!(!isV5 && entrypoint.nestedRoutesEntry)) return [
278
273
  3,
279
274
  2
280
275
  ];
@@ -290,15 +285,8 @@ var generateCode = function() {
290
285
  if (nestedRoute) {
291
286
  initialRoutes.unshift(nestedRoute);
292
287
  }
293
- return [
294
- 3,
295
- 3
296
- ];
288
+ _state.label = 2;
297
289
  case 2:
298
- logger.error("Nested routes is not supported in legacy mode.");
299
- process.exit(1);
300
- _state.label = 3;
301
- case 3:
302
290
  return [
303
291
  4,
304
292
  hookRunners.modifyFileSystemRoutes({
@@ -306,14 +294,12 @@ var generateCode = function() {
306
294
  routes: initialRoutes
307
295
  })
308
296
  ];
309
- case 4:
297
+ case 3:
310
298
  routes = _state.sent().routes;
311
- config2 = useResolvedConfigContext();
299
+ config2 = api.useResolvedConfigContext();
312
300
  ssr = getEntryOptions(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
313
301
  if (ssr) {
314
302
  mode = typeof ssr === "object" ? ssr.mode || "string" : "string";
315
- } else {
316
- mode = false;
317
303
  }
318
304
  if (mode === "stream") {
319
305
  hasPageRoute = routes.some(function(route) {
@@ -338,18 +324,18 @@ var generateCode = function() {
338
324
  internalDirectory: internalDirectory
339
325
  })
340
326
  ];
341
- case 5:
327
+ case 4:
342
328
  return [
343
329
  4,
344
330
  _.apply(hookRunners, [
345
331
  (_tmp.code = _state.sent(), _tmp)
346
332
  ])
347
333
  ];
348
- case 6:
334
+ case 5:
349
335
  _ref = _state.sent(), code2 = _ref.code;
350
336
  if (!(entrypoint.nestedRoutesEntry && mode)) return [
351
337
  3,
352
- 9
338
+ 8
353
339
  ];
354
340
  routesServerFile = getServerLoadersFile(internalDirectory, entryName);
355
341
  code3 = templates.routesForServer({
@@ -359,19 +345,19 @@ var generateCode = function() {
359
345
  4,
360
346
  fs.ensureFile(routesServerFile)
361
347
  ];
362
- case 7:
348
+ case 6:
363
349
  _state.sent();
364
350
  return [
365
351
  4,
366
352
  fs.writeFile(routesServerFile, code3)
367
353
  ];
368
- case 8:
354
+ case 7:
369
355
  _state.sent();
356
+ _state.label = 8;
357
+ case 8:
358
+ fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
370
359
  _state.label = 9;
371
360
  case 9:
372
- fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
373
- _state.label = 10;
374
- case 10:
375
361
  return [
376
362
  4,
377
363
  hookRunners.modifyEntryImports({
@@ -385,7 +371,7 @@ var generateCode = function() {
385
371
  })
386
372
  })
387
373
  ];
388
- case 11:
374
+ case 10:
389
375
  _ref1 = _state.sent(), importStatements = _ref1.imports;
390
376
  return [
391
377
  4,
@@ -394,7 +380,7 @@ var generateCode = function() {
394
380
  plugins: []
395
381
  })
396
382
  ];
397
- case 12:
383
+ case 11:
398
384
  plugins = _state.sent().plugins;
399
385
  return [
400
386
  4,
@@ -407,7 +393,7 @@ var generateCode = function() {
407
393
  })
408
394
  })
409
395
  ];
410
- case 13:
396
+ case 12:
411
397
  _ref2 = _state.sent(), renderFunction = _ref2.code;
412
398
  return [
413
399
  4,
@@ -416,7 +402,7 @@ var generateCode = function() {
416
402
  exportStatement: "export default AppWrapper;"
417
403
  })
418
404
  ];
419
- case 14:
405
+ case 13:
420
406
  exportStatement = _state.sent().exportStatement;
421
407
  code = templates.index({
422
408
  mountId: mountId,
@@ -428,7 +414,7 @@ var generateCode = function() {
428
414
  entrypoint.entry = entryFile;
429
415
  if (!config.source.enableAsyncEntry) return [
430
416
  3,
431
- 16
417
+ 15
432
418
  ];
433
419
  return [
434
420
  4,
@@ -437,19 +423,19 @@ var generateCode = function() {
437
423
  code: "import('./".concat(ENTRY_BOOTSTRAP_FILE_NAME, "');")
438
424
  })
439
425
  ];
440
- case 15:
426
+ case 14:
441
427
  _ref3 = _state.sent(), asyncEntryCode = _ref3.code;
442
428
  fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
443
429
  bootstrapFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_BOOTSTRAP_FILE_NAME));
444
430
  fs.outputFileSync(bootstrapFile, code, "utf8");
445
431
  return [
446
432
  3,
447
- 17
433
+ 16
448
434
  ];
449
- case 16:
435
+ case 15:
450
436
  fs.outputFileSync(entryFile, code, "utf8");
451
- _state.label = 17;
452
- case 17:
437
+ _state.label = 16;
438
+ case 16:
453
439
  return [
454
440
  2
455
441
  ];
@@ -463,7 +449,7 @@ var generateCode = function() {
463
449
  case 0:
464
450
  internalDirectory = appContext.internalDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
465
451
  hookRunners = api.useHookRunners();
466
- isV5 = typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
452
+ isV5 = isRouterV5(config);
467
453
  mountId = config.html.mountId;
468
454
  getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
469
455
  return [
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME } from "@modern-js/utils";
2
+ import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, isRouterV5 } from "@modern-js/utils";
3
3
  import { getFileSystemEntry } from "./getFileSystemEntry";
4
4
  import { JS_EXTENSIONS } from "./constants";
5
5
  var ensureExtensions = function(file) {
@@ -43,7 +43,7 @@ var getBundleEntry = function(appContext, config) {
43
43
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
44
44
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
45
45
  };
46
- if (entrypoint.fileSystemRoutes) {
46
+ if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
47
47
  entrypoint.nestedRoutesEntry = entrypoint.entry;
48
48
  }
49
49
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -111,7 +111,7 @@ var recursiveReadDir = function(param) {
111
111
  }
112
112
  }
113
113
  var route1 = {
114
- path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1]).concat(dynamicRouteMatched[2]) : filename),
114
+ path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1].replace(/\$$/, "?")).concat(dynamicRouteMatched[2]) : filename),
115
115
  _component: alias1,
116
116
  component: componentName1,
117
117
  parent: parent,
@@ -111,7 +111,7 @@ var recursiveReadDirLegacy = function(param) {
111
111
  }
112
112
  }
113
113
  var route1 = {
114
- path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1]).concat(dynamicRouteMatched[2]) : filename),
114
+ path: "".concat(basePath).concat(dynamicRouteMatched ? ":".concat(dynamicRouteMatched[1].replace(/\$$/, "?")).concat(dynamicRouteMatched[2]) : filename),
115
115
  _component: alias1,
116
116
  component: componentName1,
117
117
  exact: true,
@@ -223,6 +223,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
223
223
  import * as path from "path";
224
224
  import { createDebugger, findExists, fs, getEntryOptions, isApiOnly, minimist, getCommand, isDevCommand } from "@modern-js/utils";
225
225
  import { cloneDeep } from "@modern-js/utils/lodash";
226
+ import { createVirtualModule } from "@modern-js/builder-shared";
226
227
  import { printInstructions } from "../utils/printInstructions";
227
228
  import { generateRoutes } from "../utils/routes";
228
229
  import { emitResolvedConfig } from "../utils/config";
@@ -554,8 +555,10 @@ var analyze_default = function(param) {
554
555
  var entryName = entrypoint.entryName;
555
556
  var ssr = getEntryOptions(entryName, resolvedConfig.server.ssr, resolvedConfig.server.ssrByEntries, packageName);
556
557
  if (entrypoint.nestedRoutesEntry && ssr && name === "server") {
558
+ var serverLoaderRuntime = require.resolve("@modern-js/plugin-data-loader/runtime");
557
559
  var serverLoadersFile = getServerLoadersFile(internalDirectory, entryName);
558
- chain.entry("".concat(entryName, "-server-loaders")).add(serverLoadersFile);
560
+ var combinedModule = createVirtualModule('export * from "'.concat(serverLoaderRuntime, '"; export * from "').concat(serverLoadersFile, '"'));
561
+ chain.entry("".concat(entryName, "-server-loaders")).add(combinedModule);
559
562
  }
560
563
  });
561
564
  }
@@ -570,7 +573,8 @@ var analyze_default = function(param) {
570
573
  resolved: config
571
574
  };
572
575
  },
573
- modifyEntryImports: function modifyEntryImports(param) {
576
+ modifyEntryImports: // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
577
+ function modifyEntryImports(param) {
574
578
  var entrypoint = param.entrypoint, imports = param.imports;
575
579
  return _asyncToGenerator(function() {
576
580
  var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, _ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
@@ -236,7 +236,7 @@ var walk = function() {
236
236
  }
237
237
  routePath = replaceDynamicPath(routePath);
238
238
  route = {
239
- path: routePath,
239
+ path: routePath === null || routePath === void 0 ? void 0 : routePath.replace(/\$$/, "?"),
240
240
  children: [],
241
241
  isRoot: isRoot
242
242
  };
@@ -26,7 +26,7 @@ function _unsupportedIterableToArray(o, minLen) {
26
26
  import { join } from "path";
27
27
  import { createCopyPattern } from "../../shared";
28
28
  import { RouterPlugin } from "../webpackPlugins";
29
- var PluginCompatModern = function(options) {
29
+ var builderPluginCompatModern = function(options) {
30
30
  return {
31
31
  name: "builder-plugin-compat-modern",
32
32
  setup: function setup(api) {
@@ -61,4 +61,4 @@ var PluginCompatModern = function(options) {
61
61
  }
62
62
  };
63
63
  };
64
- export { PluginCompatModern };
64
+ export { builderPluginCompatModern };
@@ -200,10 +200,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
200
200
  }
201
201
  };
202
202
  import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
203
- import { applyOptionsChain } from "@modern-js/utils";
204
203
  import { createCopyPattern } from "../shared";
205
204
  import { generateBuilder } from "../generator";
206
- import { PluginCompatModern } from "./builderPlugins/compatModern";
205
+ import { builderPluginCompatModern } from "./builderPlugins/compatModern";
207
206
  function createWebpackBuilderForModern(options) {
208
207
  return generateBuilder(options, builderWebpackProvider, {
209
208
  modifyBuilderConfig: function modifyBuilderConfig(config) {
@@ -248,7 +247,7 @@ function applyBuilderPlugins(builder, options) {
248
247
  }
249
248
  function _applyBuilderPlugins() {
250
249
  _applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
251
- var normalizedConfig, PluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, PluginEsbuild;
250
+ var normalizedConfig, builderPluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, builderPluginEsbuild;
252
251
  return __generator(this, function(_state) {
253
252
  switch(_state.label){
254
253
  case 0:
@@ -262,9 +261,9 @@ function _applyBuilderPlugins() {
262
261
  import("@modern-js/builder-plugin-node-polyfill")
263
262
  ];
264
263
  case 1:
265
- PluginNodePolyfill = _state.sent().PluginNodePolyfill;
264
+ builderPluginNodePolyfill = _state.sent().builderPluginNodePolyfill;
266
265
  builder.addPlugins([
267
- PluginNodePolyfill()
266
+ builderPluginNodePolyfill()
268
267
  ]);
269
268
  _state.label = 2;
270
269
  case 2:
@@ -278,17 +277,14 @@ function _applyBuilderPlugins() {
278
277
  import("@modern-js/builder-plugin-esbuild")
279
278
  ];
280
279
  case 3:
281
- PluginEsbuild = _state.sent().PluginEsbuild;
280
+ builderPluginEsbuild = _state.sent().builderPluginEsbuild;
282
281
  builder.addPlugins([
283
- PluginEsbuild({
284
- loader: false,
285
- minimize: applyOptionsChain({}, esbuildOptions)
286
- })
282
+ builderPluginEsbuild(esbuildOptions)
287
283
  ]);
288
284
  _state.label = 4;
289
285
  case 4:
290
286
  builder.addPlugins([
291
- PluginCompatModern(options)
287
+ builderPluginCompatModern(options)
292
288
  ]);
293
289
  return [
294
290
  2
@@ -61,6 +61,7 @@ function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderCon
61
61
  }),
62
62
  html: htmlConfig,
63
63
  output: _objectSpreadProps(_objectSpread({}, resolveConfig.output), {
64
+ // 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
64
65
  cleanDistPath: false
65
66
  })
66
67
  });
@@ -7,7 +7,7 @@ function getBuilderTargets(normalizedConfig) {
7
7
  if (useNodeTarget) {
8
8
  targets.push("node");
9
9
  }
10
- var useWorkerTarget = isProd() ? isServiceWorker(normalizedConfig) : false;
10
+ var useWorkerTarget = isServiceWorker(normalizedConfig);
11
11
  if (useWorkerTarget) {
12
12
  targets.push("service-worker");
13
13
  }
@@ -7,6 +7,9 @@ function createCopyPattern(appContext, config, patternsType, chain) {
7
7
  var minifiedJsRexExp = /\.min\.js/;
8
8
  var info = function(file) {
9
9
  return {
10
+ // If the file name ends with `.min.js`, we assume it's a compressed file.
11
+ // So we don't want copy-webpack-plugin to minify it.
12
+ // ref: https://github.com/webpack-contrib/copy-webpack-plugin#info
10
13
  minimized: minifiedJsRexExp.test(file.sourceFilename)
11
14
  };
12
15
  };
@@ -20,6 +23,7 @@ function createCopyPattern(appContext, config, patternsType, chain) {
20
23
  to: "public",
21
24
  context: publicDir,
22
25
  noErrorOnMissing: true,
26
+ // eslint-disable-next-line node/prefer-global/buffer
23
27
  transform: function(content, absoluteFrom) {
24
28
  if (!/\.html?$/.test(absoluteFrom)) {
25
29
  return content;
@@ -199,6 +199,7 @@ var build = function() {
199
199
  return [
200
200
  4,
201
201
  hookRunners.beforeBuild({
202
+ // "null" bundlerConfigs
202
203
  bundlerConfigs: void 0
203
204
  })
204
205
  ];
@@ -223,6 +224,7 @@ var build = function() {
223
224
  return [
224
225
  4,
225
226
  hookRunners.afterBuild({
227
+ // "null" stats
226
228
  stats: void 0
227
229
  })
228
230
  ];
@@ -175,6 +175,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
175
175
  }
176
176
  };
177
177
  import { ResolvedConfigContext } from "@modern-js/core";
178
+ import { DEFAULT_DEV_HOST } from "@modern-js/utils";
178
179
  import { printInstructions } from "../utils/printInstructions";
179
180
  import { setServer, createServer, injectDataLoaderPlugin } from "../utils/createServer";
180
181
  import { generateRoutes } from "../utils/routes";
@@ -182,7 +183,7 @@ import { buildServerConfig } from "../utils/config";
182
183
  import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
183
184
  var dev = function() {
184
185
  var _ref = _asyncToGenerator(function(api, options) {
185
- var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, app, server;
186
+ var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, _normalizedConfig_dev, app, host, server;
186
187
  return __generator(this, function(_state) {
187
188
  switch(_state.label){
188
189
  case 0:
@@ -236,7 +237,8 @@ var dev = function() {
236
237
  serverOptions = {
237
238
  dev: _objectSpread({
238
239
  port: port,
239
- https: normalizedConfig.dev.https
240
+ https: normalizedConfig.dev.https,
241
+ host: normalizedConfig.dev.host
240
242
  }, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
241
243
  appContext: {
242
244
  appDirectory: appContext.appDirectory,
@@ -261,7 +263,11 @@ var dev = function() {
261
263
  ];
262
264
  case 5:
263
265
  app = _state.sent();
264
- app.listen(port, function() {
266
+ host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
267
+ app.listen({
268
+ port: port,
269
+ host: host
270
+ }, function() {
265
271
  var _ref = _asyncToGenerator(function(err) {
266
272
  return __generator(this, function(_state) {
267
273
  if (err) {
@@ -54,6 +54,8 @@ import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/bu
54
54
  function createDefaultConfig(appContext, bundler) {
55
55
  var defaultBuilderConfig = createDefaultBuilderConfig();
56
56
  var dev = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.dev), {
57
+ // `dev.port` should not have a default value
58
+ // because we will use `server.port` by default
57
59
  port: void 0
58
60
  });
59
61
  var output = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.output), {
@@ -8,6 +8,7 @@ function createOutputConfig(config) {
8
8
  css: cssPath,
9
9
  js: jsPath,
10
10
  html: htmlPath,
11
+ // modern.js v1 output all media files to `dist/media` by default
11
12
  svg: mediaPath || "media",
12
13
  image: mediaPath || "media",
13
14
  font: mediaPath || "media",
@@ -33,6 +34,7 @@ function createOutputConfig(config) {
33
34
  disableFilenameHash: disableAssetsCache,
34
35
  enableLatestDecorators: enableLatestDecorators,
35
36
  ssg: ssg,
37
+ // set `true`, only in legacy config
36
38
  enableAssetFallback: true,
37
39
  enableAssetManifest: true,
38
40
  disableNodePolyfill: disableNodePolyfill
@@ -17,7 +17,10 @@ function createToolsConfig(config) {
17
17
  devServer: devServer,
18
18
  tailwindcss: tailwindcss,
19
19
  jest: jest,
20
- esbuild: esbuild
20
+ esbuild: {
21
+ loader: false,
22
+ minimize: esbuild
23
+ }
21
24
  };
22
25
  }
23
26
  export { createToolsConfig };