@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
@@ -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
  ));
@@ -148,7 +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";
151
+ import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
152
152
  import { useResolvedConfigContext } from "@modern-js/core";
153
153
  import * as templates from "./templates";
154
154
  import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
@@ -240,7 +240,7 @@ var createImportStatements = function(statements) {
240
240
  };
241
241
  var generateCode = function() {
242
242
  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;
243
+ var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
244
244
  function generateEntryCode(entrypoint) {
245
245
  return _generateEntryCode.apply(this, arguments);
246
246
  }
@@ -253,11 +253,11 @@ var generateCode = function() {
253
253
  entryName = entrypoint.entryName, isAutoMount = entrypoint.isAutoMount, customBootstrap = entrypoint.customBootstrap, fileSystemRoutes = entrypoint.fileSystemRoutes;
254
254
  if (!isAutoMount) return [
255
255
  3,
256
- 17
256
+ 16
257
257
  ];
258
258
  if (!fileSystemRoutes) return [
259
259
  3,
260
- 10
260
+ 9
261
261
  ];
262
262
  initialRoutes = [];
263
263
  nestedRoute = null;
@@ -270,11 +270,7 @@ var generateCode = function() {
270
270
  internalDirAlias: internalDirAlias
271
271
  });
272
272
  }
273
- if (!entrypoint.nestedRoutesEntry) return [
274
- 3,
275
- 3
276
- ];
277
- if (!!isV5) return [
273
+ if (!(!isV5 && entrypoint.nestedRoutesEntry)) return [
278
274
  3,
279
275
  2
280
276
  ];
@@ -290,15 +286,8 @@ var generateCode = function() {
290
286
  if (nestedRoute) {
291
287
  initialRoutes.unshift(nestedRoute);
292
288
  }
293
- return [
294
- 3,
295
- 3
296
- ];
289
+ _state.label = 2;
297
290
  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
291
  return [
303
292
  4,
304
293
  hookRunners.modifyFileSystemRoutes({
@@ -306,7 +295,7 @@ var generateCode = function() {
306
295
  routes: initialRoutes
307
296
  })
308
297
  ];
309
- case 4:
298
+ case 3:
310
299
  routes = _state.sent().routes;
311
300
  config2 = useResolvedConfigContext();
312
301
  ssr = getEntryOptions(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
@@ -338,18 +327,18 @@ var generateCode = function() {
338
327
  internalDirectory: internalDirectory
339
328
  })
340
329
  ];
341
- case 5:
330
+ case 4:
342
331
  return [
343
332
  4,
344
333
  _.apply(hookRunners, [
345
334
  (_tmp.code = _state.sent(), _tmp)
346
335
  ])
347
336
  ];
348
- case 6:
337
+ case 5:
349
338
  _ref = _state.sent(), code2 = _ref.code;
350
339
  if (!(entrypoint.nestedRoutesEntry && mode)) return [
351
340
  3,
352
- 9
341
+ 8
353
342
  ];
354
343
  routesServerFile = getServerLoadersFile(internalDirectory, entryName);
355
344
  code3 = templates.routesForServer({
@@ -359,19 +348,19 @@ var generateCode = function() {
359
348
  4,
360
349
  fs.ensureFile(routesServerFile)
361
350
  ];
362
- case 7:
351
+ case 6:
363
352
  _state.sent();
364
353
  return [
365
354
  4,
366
355
  fs.writeFile(routesServerFile, code3)
367
356
  ];
368
- case 8:
357
+ case 7:
369
358
  _state.sent();
359
+ _state.label = 8;
360
+ case 8:
361
+ fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
370
362
  _state.label = 9;
371
363
  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
364
  return [
376
365
  4,
377
366
  hookRunners.modifyEntryImports({
@@ -385,7 +374,7 @@ var generateCode = function() {
385
374
  })
386
375
  })
387
376
  ];
388
- case 11:
377
+ case 10:
389
378
  _ref1 = _state.sent(), importStatements = _ref1.imports;
390
379
  return [
391
380
  4,
@@ -394,7 +383,7 @@ var generateCode = function() {
394
383
  plugins: []
395
384
  })
396
385
  ];
397
- case 12:
386
+ case 11:
398
387
  plugins = _state.sent().plugins;
399
388
  return [
400
389
  4,
@@ -407,7 +396,7 @@ var generateCode = function() {
407
396
  })
408
397
  })
409
398
  ];
410
- case 13:
399
+ case 12:
411
400
  _ref2 = _state.sent(), renderFunction = _ref2.code;
412
401
  return [
413
402
  4,
@@ -416,7 +405,7 @@ var generateCode = function() {
416
405
  exportStatement: "export default AppWrapper;"
417
406
  })
418
407
  ];
419
- case 14:
408
+ case 13:
420
409
  exportStatement = _state.sent().exportStatement;
421
410
  code = templates.index({
422
411
  mountId: mountId,
@@ -428,7 +417,7 @@ var generateCode = function() {
428
417
  entrypoint.entry = entryFile;
429
418
  if (!config.source.enableAsyncEntry) return [
430
419
  3,
431
- 16
420
+ 15
432
421
  ];
433
422
  return [
434
423
  4,
@@ -437,19 +426,19 @@ var generateCode = function() {
437
426
  code: "import('./".concat(ENTRY_BOOTSTRAP_FILE_NAME, "');")
438
427
  })
439
428
  ];
440
- case 15:
429
+ case 14:
441
430
  _ref3 = _state.sent(), asyncEntryCode = _ref3.code;
442
431
  fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
443
432
  bootstrapFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_BOOTSTRAP_FILE_NAME));
444
433
  fs.outputFileSync(bootstrapFile, code, "utf8");
445
434
  return [
446
435
  3,
447
- 17
436
+ 16
448
437
  ];
449
- case 16:
438
+ case 15:
450
439
  fs.outputFileSync(entryFile, code, "utf8");
451
- _state.label = 17;
452
- case 17:
440
+ _state.label = 16;
441
+ case 16:
453
442
  return [
454
443
  2
455
444
  ];
@@ -463,7 +452,7 @@ var generateCode = function() {
463
452
  case 0:
464
453
  internalDirectory = appContext.internalDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
465
454
  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";
455
+ isV5 = isRouterV5(config);
467
456
  mountId = config.html.mountId;
468
457
  getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
469
458
  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)) {
@@ -570,7 +570,8 @@ var analyze_default = function(param) {
570
570
  resolved: config
571
571
  };
572
572
  },
573
- modifyEntryImports: function modifyEntryImports(param) {
573
+ modifyEntryImports: // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
574
+ function modifyEntryImports(param) {
574
575
  var entrypoint = param.entrypoint, imports = param.imports;
575
576
  return _asyncToGenerator(function() {
576
577
  var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, _ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
@@ -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,14 +237,9 @@ 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
- appContext: {
242
- appDirectory: appContext.appDirectory,
243
- sharedDirectory: appContext.sharedDirectory,
244
- apiDirectory: appContext.apiDirectory,
245
- lambdaDirectory: appContext.lambdaDirectory
246
- },
247
243
  pwd: appDirectory,
248
244
  config: normalizedConfig,
249
245
  serverConfigFile: serverConfigFile,
@@ -261,7 +257,11 @@ var dev = function() {
261
257
  ];
262
258
  case 5:
263
259
  app = _state.sent();
264
- app.listen(port, function() {
260
+ host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
261
+ app.listen({
262
+ port: port,
263
+ host: host
264
+ }, function() {
265
265
  var _ref = _asyncToGenerator(function(err) {
266
266
  return __generator(this, function(_state) {
267
267
  if (err) {
@@ -122,7 +122,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
122
122
  };
123
123
  }
124
124
  };
125
- import { logger, chalk, isApiOnly, getTargetDir } from "@modern-js/utils";
125
+ import { logger, chalk, isApiOnly } from "@modern-js/utils";
126
126
  import server from "@modern-js/prod-server";
127
127
  import { printInstructions } from "../utils/printInstructions";
128
128
  import { injectDataLoaderPlugin } from "../utils/createServer";
@@ -155,11 +155,6 @@ var start = function() {
155
155
  server({
156
156
  pwd: appDirectory,
157
157
  config: userConfig,
158
- appContext: {
159
- sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
160
- apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
161
- lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
162
- },
163
158
  serverConfigFile: serverConfigFile,
164
159
  internalPlugins: injectDataLoaderPlugin(serverInternalPlugins),
165
160
  apiOnly: apiOnly
@@ -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 };
package/dist/esm/index.js CHANGED
@@ -653,7 +653,8 @@ var src_default = function() {
653
653
  });
654
654
  })();
655
655
  },
656
- fileChange: function fileChange(e) {
656
+ fileChange: // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
657
+ function fileChange(e) {
657
658
  return _asyncToGenerator(function() {
658
659
  var filename, eventType, appContext, appDirectory, srcDirectory, absolutePath, closeServer;
659
660
  return __generator(this, function(_state) {
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { fs, getEntryOptions, logger } from "@modern-js/utils";
2
+ import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
3
3
  import {
4
4
  useResolvedConfigContext
5
5
  } from "@modern-js/core";
@@ -60,7 +60,6 @@ ${initialize || ""}`
60
60
  ).join("\n");
61
61
  };
62
62
  const generateCode = async (appContext, config, entrypoints, api) => {
63
- var _a, _b, _c;
64
63
  const {
65
64
  internalDirectory,
66
65
  srcDirectory,
@@ -69,7 +68,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
69
68
  packageName
70
69
  } = appContext;
71
70
  const hookRunners = api.useHookRunners();
72
- 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";
71
+ const isV5 = isRouterV5(config);
73
72
  const { mountId } = config.html;
74
73
  const getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
75
74
  await Promise.all(entrypoints.map(generateEntryCode));
@@ -88,23 +87,18 @@ const generateCode = async (appContext, config, entrypoints, api) => {
88
87
  internalDirAlias
89
88
  });
90
89
  }
91
- if (entrypoint.nestedRoutesEntry) {
92
- if (!isV5) {
93
- nestedRoute = await walk(
94
- entrypoint.nestedRoutesEntry,
95
- entrypoint.nestedRoutesEntry,
96
- {
97
- name: internalSrcAlias,
98
- basename: srcDirectory
99
- },
100
- entrypoint.entryName
101
- );
102
- if (nestedRoute) {
103
- initialRoutes.unshift(nestedRoute);
104
- }
105
- } else {
106
- logger.error("Nested routes is not supported in legacy mode.");
107
- process.exit(1);
90
+ if (!isV5 && entrypoint.nestedRoutesEntry) {
91
+ nestedRoute = await walk(
92
+ entrypoint.nestedRoutesEntry,
93
+ entrypoint.nestedRoutesEntry,
94
+ {
95
+ name: internalSrcAlias,
96
+ basename: srcDirectory
97
+ },
98
+ entrypoint.entryName
99
+ );
100
+ if (nestedRoute) {
101
+ initialRoutes.unshift(nestedRoute);
108
102
  }
109
103
  }
110
104
  const { routes } = await hookRunners.modifyFileSystemRoutes({
@@ -3,7 +3,8 @@ import {
3
3
  ensureAbsolutePath,
4
4
  fs,
5
5
  findExists,
6
- MAIN_ENTRY_NAME
6
+ MAIN_ENTRY_NAME,
7
+ isRouterV5
7
8
  } from "@modern-js/utils";
8
9
  import { getFileSystemEntry } from "./getFileSystemEntry";
9
10
  import { JS_EXTENSIONS } from "./constants";
@@ -55,7 +56,7 @@ const getBundleEntry = (appContext, config) => {
55
56
  customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
56
57
  fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
57
58
  };
58
- if (entrypoint.fileSystemRoutes) {
59
+ if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
59
60
  entrypoint.nestedRoutesEntry = entrypoint.entry;
60
61
  }
61
62
  if (!ifAlreadyExists(defaults, entrypoint)) {
@@ -209,6 +209,7 @@ var analyze_default = ({
209
209
  resolved: config
210
210
  };
211
211
  },
212
+ // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
212
213
  async modifyEntryImports({ entrypoint, imports }) {
213
214
  const appContext = api.useAppContext();
214
215
  const { srcDirectory, internalSrcAlias } = appContext;
@@ -69,7 +69,7 @@ const html = (partials) => `
69
69
 
70
70
  <script>
71
71
  window.__assetPrefix__ = '<%= assetPrefix %>';
72
- <\/script>
72
+ </script>
73
73
  ${partials.head.join("\n")}
74
74
 
75
75
  <!--<?- chunksMap.css ?>-->
@@ -1,7 +1,7 @@
1
1
  import { join } from "path";
2
2
  import { createCopyPattern } from "../../shared";
3
3
  import { RouterPlugin } from "../webpackPlugins";
4
- const PluginCompatModern = (options) => ({
4
+ const builderPluginCompatModern = (options) => ({
5
5
  name: "builder-plugin-compat-modern",
6
6
  setup(api) {
7
7
  const { normalizedConfig: modernConfig, appContext } = options;
@@ -37,5 +37,5 @@ const PluginCompatModern = (options) => ({
37
37
  }
38
38
  });
39
39
  export {
40
- PluginCompatModern
40
+ builderPluginCompatModern
41
41
  };