@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
@@ -1,300 +0,0 @@
1
- function _defineProperty(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _objectSpread(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i] != null ? arguments[i] : {};
17
- var ownKeys = Object.keys(source);
18
- if (typeof Object.getOwnPropertySymbols === "function") {
19
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
- }));
22
- }
23
- ownKeys.forEach(function(key) {
24
- _defineProperty(target, key, source[key]);
25
- });
26
- }
27
- return target;
28
- }
29
- function ownKeys(object, enumerableOnly) {
30
- var keys = Object.keys(object);
31
- if (Object.getOwnPropertySymbols) {
32
- var symbols = Object.getOwnPropertySymbols(object);
33
- if (enumerableOnly) {
34
- symbols = symbols.filter(function(sym) {
35
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
- });
37
- }
38
- keys.push.apply(keys, symbols);
39
- }
40
- return keys;
41
- }
42
- function _objectSpreadProps(target, source) {
43
- source = source != null ? source : {};
44
- if (Object.getOwnPropertyDescriptors) {
45
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
- } else {
47
- ownKeys(Object(source)).forEach(function(key) {
48
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
- });
50
- }
51
- return target;
52
- }
53
- import { mergeBuilderConfig } from "@modern-js/builder-shared";
54
- import { getEntryOptions } from "@modern-js/utils";
55
- import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
56
- import { template as lodashTemplate } from "@modern-js/utils/lodash";
57
- import { HtmlAsyncChunkPlugin } from "../bundlerPlugins/HtmlAsyncChunkPlugin";
58
- import { BottomTemplatePlugin } from "../bundlerPlugins/HtmlBottomTemplate";
59
- var isStreamingSSR = function(userConfig) {
60
- var isStreaming = function(ssr) {
61
- return ssr && typeof ssr === "object" && ssr.mode === "stream";
62
- };
63
- var server = userConfig.server;
64
- if (isStreaming(server.ssr)) {
65
- return true;
66
- }
67
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
68
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
69
- try {
70
- for(var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
71
- var name = _step.value;
72
- if (isStreaming(server.ssrByEntries[name])) {
73
- return true;
74
- }
75
- }
76
- } catch (err) {
77
- _didIteratorError = true;
78
- _iteratorError = err;
79
- } finally{
80
- try {
81
- if (!_iteratorNormalCompletion && _iterator.return != null) {
82
- _iterator.return();
83
- }
84
- } finally{
85
- if (_didIteratorError) {
86
- throw _iteratorError;
87
- }
88
- }
89
- }
90
- }
91
- return false;
92
- };
93
- var builderPluginAdapterModern = function(options) {
94
- return {
95
- name: "builder-plugin-adapter-modern",
96
- setup: function setup(api) {
97
- var isHtmlEnabled = function isHtmlEnabled(config, target) {
98
- var _config_tools;
99
- return ((_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
100
- };
101
- var normalizedConfig = options.normalizedConfig, appContext = options.appContext;
102
- api.modifyBuilderConfig(function(config) {
103
- if (isStreamingSSR(normalizedConfig)) {
104
- return mergeBuilderConfig(config, {
105
- html: {
106
- inject: "body"
107
- }
108
- });
109
- }
110
- return config;
111
- });
112
- api.modifyBundlerChain(function(chain, param) {
113
- var target = param.target, CHAIN_ID = param.CHAIN_ID, isProd = param.isProd;
114
- var builderConfig = api.getNormalizedConfig();
115
- if (target === "node") {
116
- chain.name("server");
117
- } else if (target === "service-worker") {
118
- chain.name("service-worker");
119
- } else if (target === "web-worker") {
120
- chain.name("worker");
121
- } else if (target === "modern-web") {
122
- chain.name("modern");
123
- } else {
124
- chain.name("client");
125
- }
126
- if (target === "node" || target === "service-worker") {
127
- applyNodeCompat(target, chain, normalizedConfig, isProd);
128
- }
129
- if (isHtmlEnabled(builderConfig, target)) {
130
- applyBottomHtmlPlugin({
131
- api: api,
132
- chain: chain,
133
- modernConfig: normalizedConfig,
134
- appContext: appContext,
135
- CHAIN_ID: CHAIN_ID
136
- });
137
- applyAsyncChunkHtmlPlugin({
138
- chain: chain,
139
- modernConfig: normalizedConfig,
140
- CHAIN_ID: CHAIN_ID
141
- });
142
- }
143
- if (target !== "node" && target !== "web-worker" && target !== "service-worker") {
144
- var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
145
- chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
146
- chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
147
- }
148
- });
149
- applyCallbacks(api, options);
150
- }
151
- };
152
- };
153
- function applyCallbacks(api, options) {
154
- options.onAfterBuild && api.onAfterBuild(options.onAfterBuild);
155
- options.onAfterCreateCompiler && api.onAfterCreateCompiler(options.onAfterCreateCompiler);
156
- options.onAfterStartDevServer && api.onAfterStartDevServer(options.onAfterStartDevServer);
157
- options.onBeforeBuild && api.onBeforeBuild(options.onBeforeBuild);
158
- options.onBeforeCreateCompiler && api.onBeforeCreateCompiler(options.onBeforeCreateCompiler);
159
- options.onBeforeStartDevServer && api.onBeforeStartDevServer(options.onBeforeStartDevServer);
160
- options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
161
- options.onExit && api.onExit(options.onExit);
162
- }
163
- function applyBottomHtmlPlugin(param) {
164
- var api = param.api, chain = param.chain, modernConfig = param.modernConfig, appContext = param.appContext, CHAIN_ID = param.CHAIN_ID;
165
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
166
- try {
167
- var _loop = function() {
168
- var entryName = _step.value;
169
- var baseTemplateParams = _objectSpread({
170
- entryName: entryName,
171
- title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
172
- mountId: modernConfig.html.mountId
173
- }, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
174
- chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
175
- return [
176
- _objectSpreadProps(_objectSpread({}, args[0] || {}), {
177
- __internal__: true,
178
- bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
179
- })
180
- ];
181
- });
182
- };
183
- for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
184
- } catch (err) {
185
- _didIteratorError = true;
186
- _iteratorError = err;
187
- } finally{
188
- try {
189
- if (!_iteratorNormalCompletion && _iterator.return != null) {
190
- _iterator.return();
191
- }
192
- } finally{
193
- if (_didIteratorError) {
194
- throw _iteratorError;
195
- }
196
- }
197
- }
198
- chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [
199
- HtmlWebpackPlugin
200
- ]);
201
- }
202
- function applyAsyncChunkHtmlPlugin(param) {
203
- var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID;
204
- if (isStreamingSSR(modernConfig)) {
205
- chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
206
- HtmlWebpackPlugin
207
- ]);
208
- }
209
- }
210
- function applyNodeCompat(target, chain, modernConfig, isProd) {
211
- var filterEntriesBySSRConfig = function filterEntriesBySSRConfig(isProd2, chain2, serverConfig, outputConfig) {
212
- var _outputConfig_ssg;
213
- var entries = chain2.entryPoints.entries();
214
- if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (_outputConfig_ssg = outputConfig.ssg) === null || _outputConfig_ssg === void 0 ? void 0 : _outputConfig_ssg[0]) === "function")) {
215
- return;
216
- }
217
- if (typeof entries === "undefined") {
218
- throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
219
- }
220
- var entryNames = Object.keys(entries);
221
- if (isProd2 && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
222
- return;
223
- }
224
- var ssgEntries = [];
225
- if (isProd2 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
226
- var ssg = outputConfig.ssg;
227
- entryNames.forEach(function(name) {
228
- if (ssg[name]) {
229
- ssgEntries.push(name);
230
- }
231
- });
232
- }
233
- var _ref = serverConfig || {}, ssr = _ref.ssr, ssrByEntries = _ref.ssrByEntries;
234
- entryNames.forEach(function(name) {
235
- if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
236
- chain2.entryPoints.delete(name);
237
- }
238
- });
239
- };
240
- var nodeExts = [
241
- ".node.js",
242
- ".node.jsx",
243
- ".node.ts",
244
- ".node.tsx",
245
- ".server.js",
246
- ".server.ts",
247
- ".server.ts",
248
- ".server.tsx"
249
- ];
250
- var webWorkerExts = [
251
- ".worker.js",
252
- ".worker.jsx",
253
- ".worker.ts",
254
- ".worker.tsx"
255
- ];
256
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
257
- try {
258
- for(var _iterator = nodeExts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
259
- var ext = _step.value;
260
- chain.resolve.extensions.prepend(ext);
261
- }
262
- } catch (err) {
263
- _didIteratorError = true;
264
- _iteratorError = err;
265
- } finally{
266
- try {
267
- if (!_iteratorNormalCompletion && _iterator.return != null) {
268
- _iterator.return();
269
- }
270
- } finally{
271
- if (_didIteratorError) {
272
- throw _iteratorError;
273
- }
274
- }
275
- }
276
- if (target === "service-worker") {
277
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
278
- try {
279
- for(var _iterator1 = webWorkerExts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
280
- var ext1 = _step1.value;
281
- chain.resolve.extensions.prepend(ext1);
282
- }
283
- } catch (err) {
284
- _didIteratorError1 = true;
285
- _iteratorError1 = err;
286
- } finally{
287
- try {
288
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
289
- _iterator1.return();
290
- }
291
- } finally{
292
- if (_didIteratorError1) {
293
- throw _iteratorError1;
294
- }
295
- }
296
- }
297
- }
298
- filterEntriesBySSRConfig(isProd, chain, modernConfig.server, modernConfig.output);
299
- }
300
- export { applyCallbacks, builderPluginAdapterModern };
@@ -1,110 +0,0 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _arrayWithoutHoles(arr) {
7
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
- }
9
- function _classCallCheck(instance, Constructor) {
10
- if (!(instance instanceof Constructor)) {
11
- throw new TypeError("Cannot call a class as a function");
12
- }
13
- }
14
- function _defineProperties(target, props) {
15
- for(var i = 0; i < props.length; i++){
16
- var descriptor = props[i];
17
- descriptor.enumerable = descriptor.enumerable || false;
18
- descriptor.configurable = true;
19
- if ("value" in descriptor) descriptor.writable = true;
20
- Object.defineProperty(target, descriptor.key, descriptor);
21
- }
22
- }
23
- function _createClass(Constructor, protoProps, staticProps) {
24
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
- if (staticProps) _defineProperties(Constructor, staticProps);
26
- return Constructor;
27
- }
28
- function _defineProperty(obj, key, value) {
29
- if (key in obj) {
30
- Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- } else {
37
- obj[key] = value;
38
- }
39
- return obj;
40
- }
41
- function _iterableToArray(iter) {
42
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
43
- }
44
- function _nonIterableSpread() {
45
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
46
- }
47
- function _toConsumableArray(arr) {
48
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
49
- }
50
- function _unsupportedIterableToArray(o, minLen) {
51
- if (!o) return;
52
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
53
- var n = Object.prototype.toString.call(o).slice(8, -1);
54
- if (n === "Object" && o.constructor) n = o.constructor.name;
55
- if (n === "Map" || n === "Set") return Array.from(n);
56
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
57
- }
58
- var HtmlAsyncChunkPlugin = /*#__PURE__*/ function() {
59
- "use strict";
60
- function HtmlAsyncChunkPlugin(htmlWebpackPlugin) {
61
- _classCallCheck(this, HtmlAsyncChunkPlugin);
62
- _defineProperty(this, "name", void 0);
63
- _defineProperty(this, "htmlWebpackPlugin", void 0);
64
- this.name = "HtmlAsyncChunkPlugin";
65
- this.htmlWebpackPlugin = htmlWebpackPlugin;
66
- }
67
- _createClass(HtmlAsyncChunkPlugin, [
68
- {
69
- key: "apply",
70
- value: function apply(compiler) {
71
- var _this = this;
72
- compiler.hooks.compilation.tap(this.name, function(compilation) {
73
- var hooks = _this.htmlWebpackPlugin.getHooks(compilation);
74
- hooks.alterAssetTagGroups.tap(_this.name, function(assets) {
75
- var tags = _toConsumableArray(assets.headTags).concat(_toConsumableArray(assets.bodyTags));
76
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
77
- try {
78
- for(var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
79
- var tag = _step.value;
80
- if (tag.tagName === "script") {
81
- var attributes = tag.attributes;
82
- if (attributes && attributes.defer === true) {
83
- attributes.async = true;
84
- delete attributes.defer;
85
- }
86
- }
87
- }
88
- } catch (err) {
89
- _didIteratorError = true;
90
- _iteratorError = err;
91
- } finally{
92
- try {
93
- if (!_iteratorNormalCompletion && _iterator.return != null) {
94
- _iterator.return();
95
- }
96
- } finally{
97
- if (_didIteratorError) {
98
- throw _iteratorError;
99
- }
100
- }
101
- }
102
- return assets;
103
- });
104
- });
105
- }
106
- }
107
- ]);
108
- return HtmlAsyncChunkPlugin;
109
- }();
110
- export { HtmlAsyncChunkPlugin };
@@ -1,72 +0,0 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
5
- }
6
- function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
14
- }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
19
- }
20
- function _defineProperty(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
32
- }
33
- var BottomTemplatePlugin = /*#__PURE__*/ function() {
34
- "use strict";
35
- function BottomTemplatePlugin(htmlWebpackPlugin) {
36
- _classCallCheck(this, BottomTemplatePlugin);
37
- _defineProperty(this, "htmlWebpackPlugin", void 0);
38
- _defineProperty(this, "bottomTemplateReg", /<!--<\?-\s*bottomTemplate\s*\?>-->/);
39
- _defineProperty(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
40
- _defineProperty(this, "name", void 0);
41
- this.htmlWebpackPlugin = htmlWebpackPlugin;
42
- this.name = "bottom-template";
43
- }
44
- _createClass(BottomTemplatePlugin, [
45
- {
46
- key: "apply",
47
- value: function apply(compiler) {
48
- var _this = this;
49
- compiler.hooks.compilation.tap(this.name, function(compilation) {
50
- _this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
51
- var _data_plugin_options;
52
- if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
53
- return data;
54
- }
55
- if (_this.bottomTemplateReg.test(data.html)) {
56
- data.html = data.html.replace(_this.bottomTemplateReg, "");
57
- var bottomTemplate = data.plugin.options.bottomTemplate;
58
- if (bottomTemplate) {
59
- data.html = data.html.replace(_this.bodyRegExp, function(match) {
60
- return "\n".concat(bottomTemplate, "\n").concat(match);
61
- });
62
- }
63
- }
64
- return data;
65
- });
66
- });
67
- }
68
- }
69
- ]);
70
- return BottomTemplatePlugin;
71
- }();
72
- export { BottomTemplatePlugin };
@@ -1,40 +0,0 @@
1
- import path from "path";
2
- import { removeTailSlash } from "@modern-js/utils";
3
- function createCopyPattern(appContext, config, patternsType, chain) {
4
- var configDir = path.resolve(appContext.appDirectory, config.source.configDir || "./config");
5
- var uploadDir = path.posix.join(configDir.replace(/\\/g, "/"), "upload");
6
- var publicDir = path.posix.join(configDir.replace(/\\/g, "/"), "public");
7
- var minifiedJsRexExp = /\.min\.js/;
8
- var info = function(file) {
9
- return {
10
- minimized: minifiedJsRexExp.test(file.sourceFilename)
11
- };
12
- };
13
- if (patternsType === "public") {
14
- if (!chain) {
15
- throw new Error("expect get a webpackChain, but receive 'undefined'");
16
- }
17
- return {
18
- info: info,
19
- from: "**/*",
20
- to: "public",
21
- context: publicDir,
22
- noErrorOnMissing: true,
23
- transform: function(content, absoluteFrom) {
24
- if (!/\.html?$/.test(absoluteFrom)) {
25
- return content;
26
- }
27
- return content.toString("utf8").replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash(chain.output.get("publicPath")));
28
- }
29
- };
30
- } else {
31
- return {
32
- info: info,
33
- from: "**/*",
34
- to: "upload",
35
- context: uploadDir,
36
- noErrorOnMissing: true
37
- };
38
- }
39
- }
40
- export { createCopyPattern };
@@ -1,3 +0,0 @@
1
- export * from "./createCopyPattern";
2
- export * from "./types";
3
- export * from "./builderPlugins/adapterModern";
@@ -1,5 +0,0 @@
1
- function loader() {
2
- return "module.exports = {}";
3
- }
4
- var serverModuleLoader_default = loader;
5
- export { serverModuleLoader_default as default };
@@ -1 +0,0 @@
1
- "use strict";