@modern-js/app-tools 2.58.1 → 2.58.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. package/dist/cjs/builder/builder-rspack/adapterCopy.js +1 -1
  2. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
  3. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  4. package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -1
  5. package/dist/cjs/builder/generator/index.js +2 -2
  6. package/dist/cjs/builder/index.js +2 -2
  7. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +8 -13
  8. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +2 -5
  9. package/dist/cjs/commands/build.js +21 -2
  10. package/dist/cjs/commands/dev.js +15 -5
  11. package/dist/cjs/commands/index.js +9 -9
  12. package/dist/cjs/commands/serve.js +4 -3
  13. package/dist/cjs/config/initialize/inits.js +4 -4
  14. package/dist/cjs/config/legacy/index.js +3 -3
  15. package/dist/cjs/esm/esbuild-loader.mjs +20 -0
  16. package/dist/cjs/esm/register-esm.mjs +66 -0
  17. package/dist/cjs/esm/ts-node-loader.mjs +21 -0
  18. package/dist/cjs/esm/utils.mjs +43 -0
  19. package/dist/cjs/index.js +8 -8
  20. package/dist/cjs/locale/index.js +1 -1
  21. package/dist/cjs/plugins/analyze/getServerRoutes.js +2 -2
  22. package/dist/cjs/plugins/analyze/index.js +9 -9
  23. package/dist/cjs/plugins/analyze/utils.js +1 -1
  24. package/dist/cjs/plugins/deploy/dependencies/index.js +2 -1
  25. package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -2
  26. package/dist/cjs/plugins/deploy/index.js +2 -2
  27. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
  28. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  29. package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
  30. package/dist/cjs/plugins/deploy/platforms/netlify.js +15 -6
  31. package/dist/cjs/plugins/deploy/platforms/node.js +14 -5
  32. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
  33. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  34. package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
  35. package/dist/cjs/plugins/deploy/platforms/vercel.js +15 -6
  36. package/dist/cjs/plugins/serverBuild.js +2 -2
  37. package/dist/cjs/utils/config.js +1 -1
  38. package/dist/cjs/utils/createServer.js +1 -1
  39. package/dist/cjs/utils/loadPlugins.js +1 -1
  40. package/dist/cjs/utils/register.js +50 -23
  41. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
  42. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  43. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
  44. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  45. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
  46. package/dist/types/builder/generator/index.d.ts +3 -3
  47. package/dist/types/builder/index.d.ts +1 -1
  48. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  49. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  50. package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +1 -1
  51. package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +1 -1
  52. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -1
  53. package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
  54. package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -1
  55. package/dist/types/builder/shared/types.d.ts +1 -1
  56. package/dist/types/commands/build.d.ts +2 -2
  57. package/dist/types/commands/dev.d.ts +3 -3
  58. package/dist/types/commands/index.d.ts +3 -3
  59. package/dist/types/commands/inspect.d.ts +1 -1
  60. package/dist/types/config/default.d.ts +1 -1
  61. package/dist/types/config/initialize/inits.d.ts +1 -1
  62. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  63. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  64. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  65. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  66. package/dist/types/esm/esbuild-loader.d.mts +6 -0
  67. package/dist/types/esm/register-esm.d.mts +5 -0
  68. package/dist/types/esm/ts-node-loader.d.mts +6 -0
  69. package/dist/types/esm/utils.d.mts +6 -0
  70. package/dist/types/exports/server.d.ts +1 -1
  71. package/dist/types/hooks.d.ts +1 -1
  72. package/dist/types/index.d.ts +2 -2
  73. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  74. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  75. package/dist/types/plugins/analyze/index.d.ts +1 -1
  76. package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -1
  77. package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
  78. package/dist/types/plugins/deploy/index.d.ts +2 -2
  79. package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
  80. package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
  81. package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
  82. package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
  83. package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
  84. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  85. package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
  86. package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
  87. package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
  88. package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
  89. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  90. package/dist/types/plugins/initialize/index.d.ts +1 -1
  91. package/dist/types/plugins/serverBuild.d.ts +1 -1
  92. package/dist/types/types/config/index.d.ts +8 -8
  93. package/dist/types/types/config/output.d.ts +1 -1
  94. package/dist/types/types/config/tools.d.ts +3 -3
  95. package/dist/types/types/hooks.d.ts +3 -3
  96. package/dist/types/types/index.d.ts +3 -3
  97. package/dist/types/types/legacyConfig/index.d.ts +3 -3
  98. package/dist/types/types/legacyConfig/tools.d.ts +1 -1
  99. package/dist/types/utils/createServer.d.ts +1 -1
  100. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  101. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  102. package/dist/types/utils/loadPlugins.d.ts +3 -3
  103. package/dist/types/utils/printInstructions.d.ts +1 -1
  104. package/dist/types/utils/register.d.ts +2 -2
  105. package/dist/types/utils/restart.d.ts +2 -2
  106. package/lib/types.d.ts +15 -0
  107. package/package.json +20 -20
  108. package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
  109. package/dist/esm/builder/builder-rspack/index.js +0 -34
  110. package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
  111. package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
  112. package/dist/esm/builder/builder-webpack/index.js +0 -52
  113. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
  114. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
  115. package/dist/esm/builder/generator/index.js +0 -94
  116. package/dist/esm/builder/index.js +0 -45
  117. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
  118. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  119. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
  120. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
  121. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  122. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  123. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  124. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -317
  125. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  126. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  127. package/dist/esm/builder/shared/index.js +0 -3
  128. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  129. package/dist/esm/builder/shared/types.js +0 -0
  130. package/dist/esm/commands/build.js +0 -117
  131. package/dist/esm/commands/deploy.js +0 -48
  132. package/dist/esm/commands/dev.js +0 -169
  133. package/dist/esm/commands/index.js +0 -411
  134. package/dist/esm/commands/inspect.js +0 -28
  135. package/dist/esm/commands/serve.js +0 -93
  136. package/dist/esm/config/default.js +0 -190
  137. package/dist/esm/config/index.js +0 -3
  138. package/dist/esm/config/initialize/index.js +0 -9
  139. package/dist/esm/config/initialize/inits.js +0 -85
  140. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  141. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  142. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  143. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  144. package/dist/esm/config/legacy/index.js +0 -43
  145. package/dist/esm/defineConfig.js +0 -16
  146. package/dist/esm/exports/server.js +0 -4
  147. package/dist/esm/hooks.js +0 -34
  148. package/dist/esm/index.js +0 -239
  149. package/dist/esm/locale/en.js +0 -43
  150. package/dist/esm/locale/index.js +0 -12
  151. package/dist/esm/locale/zh.js +0 -43
  152. package/dist/esm/plugins/analyze/constants.js +0 -14
  153. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
  154. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
  155. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
  156. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
  157. package/dist/esm/plugins/analyze/index.js +0 -380
  158. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  159. package/dist/esm/plugins/analyze/templates.js +0 -6
  160. package/dist/esm/plugins/analyze/utils.js +0 -101
  161. package/dist/esm/plugins/deploy/dependencies/index.js +0 -614
  162. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -394
  163. package/dist/esm/plugins/deploy/exports.js +0 -4
  164. package/dist/esm/plugins/deploy/index.js +0 -135
  165. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
  166. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
  167. package/dist/esm/plugins/deploy/platforms/node.js +0 -133
  168. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
  169. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  170. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
  171. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
  172. package/dist/esm/plugins/deploy/utils.js +0 -47
  173. package/dist/esm/plugins/initialize/index.js +0 -119
  174. package/dist/esm/plugins/serverBuild.js +0 -87
  175. package/dist/esm/types/config/deploy.js +0 -0
  176. package/dist/esm/types/config/dev.js +0 -0
  177. package/dist/esm/types/config/experiments.js +0 -0
  178. package/dist/esm/types/config/html.js +0 -0
  179. package/dist/esm/types/config/index.js +0 -1
  180. package/dist/esm/types/config/output.js +0 -0
  181. package/dist/esm/types/config/performance.js +0 -0
  182. package/dist/esm/types/config/security.js +0 -0
  183. package/dist/esm/types/config/source.js +0 -0
  184. package/dist/esm/types/config/testing.js +0 -0
  185. package/dist/esm/types/config/tools.js +0 -0
  186. package/dist/esm/types/hooks.js +0 -0
  187. package/dist/esm/types/index.js +0 -3
  188. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  189. package/dist/esm/types/legacyConfig/dev.js +0 -0
  190. package/dist/esm/types/legacyConfig/index.js +0 -0
  191. package/dist/esm/types/legacyConfig/output.js +0 -0
  192. package/dist/esm/types/legacyConfig/source.js +0 -0
  193. package/dist/esm/types/legacyConfig/testing.js +0 -0
  194. package/dist/esm/types/legacyConfig/tools.js +0 -0
  195. package/dist/esm/types/utils.js +0 -0
  196. package/dist/esm/utils/config.js +0 -122
  197. package/dist/esm/utils/createServer.js +0 -58
  198. package/dist/esm/utils/env.js +0 -16
  199. package/dist/esm/utils/generateWatchFiles.js +0 -71
  200. package/dist/esm/utils/getSelectedEntries.js +0 -67
  201. package/dist/esm/utils/loadPlugins.js +0 -69
  202. package/dist/esm/utils/printInstructions.js +0 -32
  203. package/dist/esm/utils/register.js +0 -129
  204. package/dist/esm/utils/restart.js +0 -67
  205. package/dist/esm/utils/routes.js +0 -42
  206. package/dist/esm/utils/types.js +0 -0
  207. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
  208. package/dist/esm-node/builder/builder-rspack/index.js +0 -12
  209. package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
  210. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
  211. package/dist/esm-node/builder/builder-webpack/index.js +0 -20
  212. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
  213. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
  214. package/dist/esm-node/builder/generator/index.js +0 -37
  215. package/dist/esm-node/builder/index.js +0 -11
  216. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
  217. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  218. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
  219. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
  220. package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
  221. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  222. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  223. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -231
  224. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
  225. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  226. package/dist/esm-node/builder/shared/index.js +0 -3
  227. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  228. package/dist/esm-node/builder/shared/types.js +0 -0
  229. package/dist/esm-node/commands/build.js +0 -55
  230. package/dist/esm-node/commands/deploy.js +0 -12
  231. package/dist/esm-node/commands/dev.js +0 -95
  232. package/dist/esm-node/commands/index.js +0 -92
  233. package/dist/esm-node/commands/inspect.js +0 -15
  234. package/dist/esm-node/commands/serve.js +0 -51
  235. package/dist/esm-node/config/default.js +0 -197
  236. package/dist/esm-node/config/index.js +0 -3
  237. package/dist/esm-node/config/initialize/index.js +0 -9
  238. package/dist/esm-node/config/initialize/inits.js +0 -79
  239. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  240. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  241. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  242. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  243. package/dist/esm-node/config/legacy/index.js +0 -43
  244. package/dist/esm-node/defineConfig.js +0 -13
  245. package/dist/esm-node/exports/server.js +0 -4
  246. package/dist/esm-node/hooks.js +0 -34
  247. package/dist/esm-node/index.js +0 -124
  248. package/dist/esm-node/locale/en.js +0 -43
  249. package/dist/esm-node/locale/index.js +0 -12
  250. package/dist/esm-node/locale/zh.js +0 -43
  251. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  252. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
  253. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
  254. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
  255. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
  256. package/dist/esm-node/plugins/analyze/index.js +0 -166
  257. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  258. package/dist/esm-node/plugins/analyze/templates.js +0 -24
  259. package/dist/esm-node/plugins/analyze/utils.js +0 -68
  260. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -201
  261. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -126
  262. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  263. package/dist/esm-node/plugins/deploy/index.js +0 -44
  264. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
  265. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
  266. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
  267. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
  268. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  269. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
  270. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
  271. package/dist/esm-node/plugins/deploy/utils.js +0 -44
  272. package/dist/esm-node/plugins/initialize/index.js +0 -84
  273. package/dist/esm-node/plugins/serverBuild.js +0 -58
  274. package/dist/esm-node/types/config/deploy.js +0 -0
  275. package/dist/esm-node/types/config/dev.js +0 -0
  276. package/dist/esm-node/types/config/experiments.js +0 -0
  277. package/dist/esm-node/types/config/html.js +0 -0
  278. package/dist/esm-node/types/config/index.js +0 -1
  279. package/dist/esm-node/types/config/output.js +0 -0
  280. package/dist/esm-node/types/config/performance.js +0 -0
  281. package/dist/esm-node/types/config/security.js +0 -0
  282. package/dist/esm-node/types/config/source.js +0 -0
  283. package/dist/esm-node/types/config/testing.js +0 -0
  284. package/dist/esm-node/types/config/tools.js +0 -0
  285. package/dist/esm-node/types/hooks.js +0 -0
  286. package/dist/esm-node/types/index.js +0 -3
  287. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  288. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  289. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  290. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  291. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  292. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  293. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  294. package/dist/esm-node/types/utils.js +0 -0
  295. package/dist/esm-node/utils/config.js +0 -49
  296. package/dist/esm-node/utils/createServer.js +0 -26
  297. package/dist/esm-node/utils/env.js +0 -16
  298. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  299. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  300. package/dist/esm-node/utils/loadPlugins.js +0 -22
  301. package/dist/esm-node/utils/printInstructions.js +0 -11
  302. package/dist/esm-node/utils/register.js +0 -69
  303. package/dist/esm-node/utils/restart.js +0 -22
  304. package/dist/esm-node/utils/routes.js +0 -21
  305. package/dist/esm-node/utils/types.js +0 -0
  306. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
  307. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  308. /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
  309. /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,32 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { prettyInstructions, logger } from "@modern-js/utils";
4
- var printInstructions = function() {
5
- var _ref = _async_to_generator(function(hookRunners, appContext, config) {
6
- var message, instructions;
7
- return _ts_generator(this, function(_state) {
8
- switch (_state.label) {
9
- case 0:
10
- message = prettyInstructions(appContext, config);
11
- return [
12
- 4,
13
- hookRunners.beforePrintInstructions({
14
- instructions: message
15
- })
16
- ];
17
- case 1:
18
- instructions = _state.sent().instructions;
19
- logger.log(instructions);
20
- return [
21
- 2
22
- ];
23
- }
24
- });
25
- });
26
- return function printInstructions2(hookRunners, appContext, config) {
27
- return _ref.apply(this, arguments);
28
- };
29
- }();
30
- export {
31
- printInstructions
32
- };
@@ -1,129 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _define_property } from "@swc/helpers/_/_define_property";
3
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
5
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
- import path from "node:path";
7
- import { fs, getAliasConfig, readTsConfigByFile } from "@modern-js/utils";
8
- var registerCompiler = function() {
9
- var _ref = _async_to_generator(function() {
10
- var appDir, distDir, alias, TS_CONFIG_FILENAME, tsconfigPath, isTsProject, aliasConfig, _aliasConfig_paths, paths, _aliasConfig_absoluteBaseUrl, absoluteBaseUrl, tsPaths, tsConfig, tsNode, tsNodeOptions, error, esbuildRegister, tsConfigPaths, loaderRes;
11
- var _arguments = arguments;
12
- return _ts_generator(this, function(_state) {
13
- switch (_state.label) {
14
- case 0:
15
- appDir = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : process.cwd(), distDir = _arguments.length > 1 ? _arguments[1] : void 0, alias = _arguments.length > 2 ? _arguments[2] : void 0;
16
- TS_CONFIG_FILENAME = "tsconfig.json";
17
- tsconfigPath = path.resolve(appDir, TS_CONFIG_FILENAME);
18
- return [
19
- 4,
20
- fs.pathExists(tsconfigPath)
21
- ];
22
- case 1:
23
- isTsProject = _state.sent();
24
- aliasConfig = getAliasConfig(alias, {
25
- appDirectory: appDir,
26
- tsconfigPath
27
- });
28
- _aliasConfig_paths = aliasConfig.paths, paths = _aliasConfig_paths === void 0 ? {} : _aliasConfig_paths, _aliasConfig_absoluteBaseUrl = aliasConfig.absoluteBaseUrl, absoluteBaseUrl = _aliasConfig_absoluteBaseUrl === void 0 ? "./" : _aliasConfig_absoluteBaseUrl;
29
- tsPaths = Object.keys(paths).reduce(function(o, key) {
30
- var tsPath = paths[key];
31
- if (typeof tsPath === "string" && path.isAbsolute(tsPath)) {
32
- tsPath = path.relative(absoluteBaseUrl, tsPath);
33
- }
34
- if (typeof tsPath === "string") {
35
- tsPath = [
36
- tsPath
37
- ];
38
- }
39
- return _object_spread_props(_object_spread({}, o), _define_property({}, "".concat(key), tsPath));
40
- }, {});
41
- tsConfig = {};
42
- if (isTsProject) {
43
- tsConfig = readTsConfigByFile(tsconfigPath);
44
- }
45
- _state.label = 2;
46
- case 2:
47
- _state.trys.push([
48
- 2,
49
- 4,
50
- ,
51
- 6
52
- ]);
53
- return [
54
- 4,
55
- import("ts-node")
56
- ];
57
- case 3:
58
- tsNode = _state.sent();
59
- tsNodeOptions = tsConfig["ts-node"];
60
- if (isTsProject) {
61
- tsNode.register(_object_spread({
62
- project: tsconfigPath,
63
- scope: true,
64
- // for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
65
- files: true,
66
- transpileOnly: true,
67
- ignore: [
68
- "(?:^|/)node_modules/",
69
- "(?:^|/)".concat(path.relative(appDir, distDir), "/")
70
- ]
71
- }, tsNodeOptions));
72
- }
73
- return [
74
- 3,
75
- 6
76
- ];
77
- case 4:
78
- error = _state.sent();
79
- return [
80
- 4,
81
- import("esbuild-register/dist/node")
82
- ];
83
- case 5:
84
- esbuildRegister = _state.sent();
85
- esbuildRegister.register({
86
- tsconfigRaw: isTsProject ? tsConfig : void 0,
87
- hookIgnoreNodeModules: true,
88
- hookMatcher: function(fileName) {
89
- return !fileName.startsWith(distDir);
90
- }
91
- });
92
- return [
93
- 3,
94
- 6
95
- ];
96
- case 6:
97
- return [
98
- 4,
99
- import("@modern-js/utils/tsconfig-paths")
100
- ];
101
- case 7:
102
- tsConfigPaths = _state.sent();
103
- return [
104
- 4,
105
- fs.pathExists(appDir)
106
- ];
107
- case 8:
108
- if (_state.sent()) {
109
- loaderRes = tsConfigPaths.loadConfig(appDir);
110
- if (loaderRes.resultType === "success") {
111
- tsConfigPaths.register({
112
- baseUrl: absoluteBaseUrl || "./",
113
- paths: tsPaths
114
- });
115
- }
116
- }
117
- return [
118
- 2
119
- ];
120
- }
121
- });
122
- });
123
- return function registerCompiler2() {
124
- return _ref.apply(this, arguments);
125
- };
126
- }();
127
- export {
128
- registerCompiler
129
- };
@@ -1,67 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { cli } from "@modern-js/core";
4
- import { chalk, clearConsole, getFullArgv, logger, program } from "@modern-js/utils";
5
- function restart(hooksRunner, filename) {
6
- return _restart.apply(this, arguments);
7
- }
8
- function _restart() {
9
- _restart = _async_to_generator(function(hooksRunner, filename) {
10
- var hasGetError, err;
11
- return _ts_generator(this, function(_state) {
12
- switch (_state.label) {
13
- case 0:
14
- clearConsole();
15
- logger.info("Restart because ".concat(chalk.yellow(filename), " is changed...\n"));
16
- hasGetError = false;
17
- return [
18
- 4,
19
- hooksRunner.beforeRestart()
20
- ];
21
- case 1:
22
- _state.sent();
23
- _state.label = 2;
24
- case 2:
25
- _state.trys.push([
26
- 2,
27
- 4,
28
- 5,
29
- 6
30
- ]);
31
- return [
32
- 4,
33
- cli.init(cli.getPrevInitOptions())
34
- ];
35
- case 3:
36
- _state.sent();
37
- return [
38
- 3,
39
- 6
40
- ];
41
- case 4:
42
- err = _state.sent();
43
- console.error(err);
44
- hasGetError = true;
45
- return [
46
- 3,
47
- 6
48
- ];
49
- case 5:
50
- if (!hasGetError) {
51
- program.parse(getFullArgv());
52
- }
53
- return [
54
- 7
55
- ];
56
- case 6:
57
- return [
58
- 2
59
- ];
60
- }
61
- });
62
- });
63
- return _restart.apply(this, arguments);
64
- }
65
- export {
66
- restart
67
- };
@@ -1,42 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import path from "path";
4
- import { fs, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE } from "@modern-js/utils";
5
- var generateRoutes = function() {
6
- var _ref = _async_to_generator(function(appContext) {
7
- var serverRoutes, distDirectory, output;
8
- return _ts_generator(this, function(_state) {
9
- switch (_state.label) {
10
- case 0:
11
- serverRoutes = appContext.serverRoutes, distDirectory = appContext.distDirectory;
12
- output = JSON.stringify({
13
- routes: serverRoutes
14
- }, null, 2);
15
- return [
16
- 4,
17
- fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output)
18
- ];
19
- case 1:
20
- _state.sent();
21
- return [
22
- 2
23
- ];
24
- }
25
- });
26
- });
27
- return function generateRoutes2(appContext) {
28
- return _ref.apply(this, arguments);
29
- };
30
- }();
31
- var getPathWithoutExt = function(filename) {
32
- var extname = path.extname(filename);
33
- return filename.slice(0, -extname.length);
34
- };
35
- var isMainEntry = function(entryName, mainEntryName) {
36
- return entryName === (mainEntryName || MAIN_ENTRY_NAME);
37
- };
38
- export {
39
- generateRoutes,
40
- getPathWithoutExt,
41
- isMainEntry
42
- };
File without changes
@@ -1,67 +0,0 @@
1
- import path from "path";
2
- import fs from "@modern-js/utils/fs-extra";
3
- import { logger, removeTailSlash } from "@modern-js/utils";
4
- import { createCopyInfo } from "../shared";
5
- const builderPluginAdpaterCopy = (options) => ({
6
- name: "builder-plugin-adapter-rspack-copy",
7
- setup(api) {
8
- let publicPath;
9
- api.modifyBundlerChain((chain, { CHAIN_ID }) => {
10
- chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
11
- var _args_;
12
- return [
13
- {
14
- patterns: [
15
- ...((_args_ = args[0]) === null || _args_ === void 0 ? void 0 : _args_.patterns) || [],
16
- ...createConfigBuiltinCopy(options)
17
- ]
18
- }
19
- ];
20
- });
21
- });
22
- api.modifyRspackConfig((config) => {
23
- var _config_output;
24
- publicPath = (_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.publicPath;
25
- });
26
- api.onDevCompileDone(async () => {
27
- await transformHtmlFiles();
28
- });
29
- api.onAfterBuild(async () => {
30
- await transformHtmlFiles();
31
- });
32
- async function transformHtmlFiles() {
33
- var _normalizedConfig_output_distPath;
34
- const { normalizedConfig } = options;
35
- const publicDir = path.resolve(((_normalizedConfig_output_distPath = normalizedConfig.output.distPath) === null || _normalizedConfig_output_distPath === void 0 ? void 0 : _normalizedConfig_output_distPath.root) || "./dist", "./public");
36
- if (!fs.existsSync(publicDir) || !fs.statSync(publicDir).isDirectory()) {
37
- return;
38
- }
39
- const HTML_REGEXP = /\.html?$/;
40
- const filepaths = (await fs.readdir(publicDir)).map((file) => path.resolve(publicDir, file));
41
- await Promise.all(filepaths.filter((file) => HTML_REGEXP.test(file)).map(async (file) => {
42
- const content = await fs.readFile(file, "utf-8");
43
- if (publicPath && typeof publicPath === "string") {
44
- await fs.writeFile(file, content.replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash(publicPath)));
45
- } else {
46
- logger.warn(`Expect get a string from \`publicPath\`, but receive \`${typeof publicPath}\`.`);
47
- await fs.writeFile(file, content.replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash("/")));
48
- }
49
- }));
50
- }
51
- }
52
- });
53
- function createConfigBuiltinCopy(options) {
54
- const { normalizedConfig, appContext } = options;
55
- const { publicDir } = createCopyInfo(appContext, normalizedConfig);
56
- return [
57
- {
58
- from: "**/*",
59
- to: "public",
60
- context: publicDir,
61
- noErrorOnMissing: true
62
- }
63
- ];
64
- }
65
- export {
66
- builderPluginAdpaterCopy
67
- };
@@ -1,12 +0,0 @@
1
- import { generateBuilder } from "../generator";
2
- import { builderPluginAdpaterCopy } from "./adapterCopy";
3
- async function createRspackBuilderForModern(options) {
4
- const builder = await generateBuilder(options, "rspack");
5
- builder.addPlugins([
6
- builderPluginAdpaterCopy(options)
7
- ]);
8
- return builder;
9
- }
10
- export {
11
- createRspackBuilderForModern
12
- };
@@ -1,26 +0,0 @@
1
- import { createPublicPattern } from "./createCopyPattern";
2
- const builderPluginAdapterModern = (options) => ({
3
- name: "builder-plugin-adapter-modern",
4
- setup(api) {
5
- const { normalizedConfig: modernConfig, appContext } = options;
6
- api.modifyWebpackChain((chain, { CHAIN_ID }) => {
7
- if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
8
- const defaultCopyPattern = createPublicPattern(appContext, modernConfig, chain);
9
- chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
10
- var _args_;
11
- return [
12
- {
13
- patterns: [
14
- ...((_args_ = args[0]) === null || _args_ === void 0 ? void 0 : _args_.patterns) || [],
15
- defaultCopyPattern
16
- ]
17
- }
18
- ];
19
- });
20
- }
21
- });
22
- }
23
- });
24
- export {
25
- builderPluginAdapterModern
26
- };
@@ -1,42 +0,0 @@
1
- import { removeTailSlash } from "@modern-js/utils";
2
- import { createCopyInfo } from "../shared";
3
- const minifiedJsRexExp = /\.min\.js/;
4
- const info = (file) => ({
5
- // If the file name ends with `.min.js`, we assume it's a compressed file.
6
- // So we don't want copy-webpack-plugin to minify it.
7
- // ref: https://github.com/webpack-contrib/copy-webpack-plugin#info
8
- minimized: minifiedJsRexExp.test(file.sourceFilename)
9
- });
10
- function createPublicPattern(appContext, config, chain) {
11
- const { publicDir } = createCopyInfo(appContext, config);
12
- return {
13
- info,
14
- from: "**/*",
15
- to: "public",
16
- context: publicDir,
17
- noErrorOnMissing: true,
18
- // eslint-disable-next-line node/prefer-global/buffer
19
- transform: (content, absoluteFrom) => {
20
- if (!/\.html?$/.test(absoluteFrom)) {
21
- return content;
22
- }
23
- return content.toString("utf8").replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash(chain.output.get("publicPath")));
24
- }
25
- };
26
- }
27
- function createUploadPattern(appContext, config) {
28
- const { uploadDir } = createCopyInfo(appContext, config);
29
- return {
30
- // rspack copy info structure is inconsistent with webpack, it only used in webpack mode
31
- // @ts-expect-error
32
- info,
33
- from: "**/*",
34
- to: "upload",
35
- context: uploadDir,
36
- noErrorOnMissing: true
37
- };
38
- }
39
- export {
40
- createPublicPattern,
41
- createUploadPattern
42
- };
@@ -1,20 +0,0 @@
1
- import { generateBuilder } from "../generator";
2
- import { builderPluginAdapterModern } from "./adapterModern";
3
- async function createWebpackBuilderForModern(options) {
4
- const builder = await generateBuilder(options, "webpack");
5
- const { normalizedConfig } = options;
6
- if (normalizedConfig.tools.esbuild) {
7
- const { esbuild: esbuildOptions } = normalizedConfig.tools;
8
- const { pluginEsbuild } = await import("@modern-js/rsbuild-plugin-esbuild");
9
- builder.addPlugins([
10
- pluginEsbuild(esbuildOptions)
11
- ]);
12
- }
13
- builder.addPlugins([
14
- builderPluginAdapterModern(options)
15
- ]);
16
- return builder;
17
- }
18
- export {
19
- createWebpackBuilderForModern
20
- };
@@ -1,44 +0,0 @@
1
- import { createUploadPattern } from "../builder-webpack/createCopyPattern";
2
- function modifyOutputConfig(config, appContext) {
3
- const defaultCopyPattern = createUploadPattern(appContext, config);
4
- const { copy } = config.output;
5
- const copyOptions = Array.isArray(copy) ? copy : copy === null || copy === void 0 ? void 0 : copy.patterns;
6
- const builderCopy = [
7
- ...copyOptions || [],
8
- defaultCopyPattern
9
- ];
10
- config.output = {
11
- ...config.output,
12
- copy: builderCopy
13
- };
14
- }
15
- function createBuilderProviderConfig(resolveConfig, appContext) {
16
- const htmlConfig = {
17
- ...resolveConfig.html
18
- };
19
- if (!htmlConfig.template) {
20
- htmlConfig.templateByEntries = {
21
- ...appContext.htmlTemplates,
22
- ...htmlConfig.templateByEntries
23
- };
24
- }
25
- const config = {
26
- ...resolveConfig,
27
- plugins: [],
28
- dev: {
29
- ...resolveConfig.dev,
30
- port: appContext.port
31
- },
32
- html: htmlConfig,
33
- output: {
34
- ...resolveConfig.output,
35
- // 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
36
- cleanDistPath: false
37
- }
38
- };
39
- modifyOutputConfig(config, appContext);
40
- return config;
41
- }
42
- export {
43
- createBuilderProviderConfig
44
- };
@@ -1,60 +0,0 @@
1
- import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
2
- import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
- function getBuilderEnvironments(normalizedConfig, appContext) {
4
- const entries = {};
5
- const { entrypoints = [], checkedEntries } = appContext;
6
- for (const { entryName, internalEntry, entry } of entrypoints) {
7
- if (checkedEntries && !checkedEntries.includes(entryName)) {
8
- continue;
9
- }
10
- const finalEntry = internalEntry || entry;
11
- if (entryName in entries) {
12
- entries[entryName].push(finalEntry);
13
- } else {
14
- entries[entryName] = [
15
- finalEntry
16
- ];
17
- }
18
- }
19
- const serverEntries = {};
20
- for (const entry in entries) {
21
- const v = entries[entry];
22
- serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx")).map((entry2) => entry2.replace("bootstrap.jsx", "bootstrap.server.jsx"));
23
- }
24
- const environments = {
25
- web: {
26
- output: {
27
- target: "web"
28
- },
29
- source: {
30
- entry: entries
31
- }
32
- }
33
- };
34
- const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
35
- if (useNodeTarget) {
36
- environments.node = {
37
- output: {
38
- target: "node"
39
- },
40
- source: {
41
- entry: serverEntries
42
- }
43
- };
44
- }
45
- const useWorkerTarget = isServiceWorker(normalizedConfig);
46
- if (useWorkerTarget) {
47
- environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
48
- output: {
49
- target: "web-worker"
50
- },
51
- source: {
52
- entry: serverEntries
53
- }
54
- };
55
- }
56
- return environments;
57
- }
58
- export {
59
- getBuilderEnvironments
60
- };
@@ -1,37 +0,0 @@
1
- import { createUniBuilder } from "@modern-js/uni-builder";
2
- import { mergeRsbuildConfig } from "@rsbuild/core";
3
- import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
4
- import { getBuilderEnvironments } from "./getBuilderEnvironments";
5
- async function generateBuilder(options, bundlerType) {
6
- const { normalizedConfig, appContext } = options;
7
- const builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
8
- const environments = getBuilderEnvironments(normalizedConfig, appContext);
9
- builderConfig.environments = builderConfig.environments ? mergeRsbuildConfig(environments, builderConfig.environments) : environments;
10
- const builder = await createUniBuilder({
11
- cwd: appContext.appDirectory,
12
- frameworkConfigPath: appContext.configFile || void 0,
13
- bundlerType,
14
- config: builderConfig
15
- });
16
- await applyBuilderPlugins(builder, options);
17
- return builder;
18
- }
19
- async function applyBuilderPlugins(builder, options) {
20
- const { builderPluginAdapterBasic, builderPluginAdapterHtml, builderPluginAdapterSSR, builderPluginAdapterWorker } = await import("../shared/builderPlugins");
21
- builder.addPlugins([
22
- builderPluginAdapterBasic(),
23
- builderPluginAdapterSSR(options),
24
- builderPluginAdapterHtml(options),
25
- builderPluginAdapterWorker()
26
- ]);
27
- const { normalizedConfig } = options;
28
- if (!normalizedConfig.output.disableNodePolyfill) {
29
- const { pluginNodePolyfill } = await import("@rsbuild/plugin-node-polyfill");
30
- builder.addPlugins([
31
- pluginNodePolyfill()
32
- ]);
33
- }
34
- }
35
- export {
36
- generateBuilder
37
- };
@@ -1,11 +0,0 @@
1
- async function createBuilderGenerator(bundler) {
2
- if (bundler === "rspack") {
3
- const { createRspackBuilderForModern } = await import("./builder-rspack");
4
- return createRspackBuilderForModern;
5
- }
6
- const { createWebpackBuilderForModern } = await import("./builder-webpack");
7
- return createWebpackBuilderForModern;
8
- }
9
- export {
10
- createBuilderGenerator
11
- };
@@ -1,48 +0,0 @@
1
- import path from "path";
2
- import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
- const builderPluginAdapterBasic = () => ({
4
- name: "builder-plugin-adapter-modern-basic",
5
- setup(api) {
6
- api.modifyBundlerChain((chain, { target, CHAIN_ID, environment }) => {
7
- const isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
8
- if (target === "node" || isServiceWorker) {
9
- applyNodeCompat(isServiceWorker, chain);
10
- }
11
- if (target === "web") {
12
- const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
13
- chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
14
- chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
15
- }
16
- chain.resolve.modules.add("node_modules").add(path.join(api.context.rootPath, "node_modules"));
17
- });
18
- }
19
- });
20
- function applyNodeCompat(isServiceWorker, chain) {
21
- const nodeExts = [
22
- ".node.js",
23
- ".node.jsx",
24
- ".node.ts",
25
- ".node.tsx",
26
- ".server.js",
27
- ".server.jsx",
28
- ".server.ts",
29
- ".server.tsx"
30
- ];
31
- const webWorkerExts = [
32
- ".worker.js",
33
- ".worker.jsx",
34
- ".worker.ts",
35
- ".worker.tsx"
36
- ];
37
- for (const ext of nodeExts) {
38
- chain.resolve.extensions.prepend(ext);
39
- }
40
- if (isServiceWorker) {
41
- for (const ext of webWorkerExts) {
42
- chain.resolve.extensions.prepend(ext);
43
- }
44
- }
45
- }
46
- export {
47
- builderPluginAdapterBasic
48
- };