@modern-js/app-tools 2.58.1-alpha.6 → 2.58.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
  2. package/dist/cjs/builder/builder-webpack/index.js +1 -1
  3. package/dist/cjs/builder/generator/index.js +2 -2
  4. package/dist/cjs/builder/index.js +2 -2
  5. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +13 -4
  6. package/dist/cjs/commands/build.js +19 -0
  7. package/dist/cjs/commands/dev.js +9 -0
  8. package/dist/cjs/commands/index.js +8 -8
  9. package/dist/cjs/commands/inspect.js +1 -1
  10. package/dist/cjs/config/initialize/inits.js +4 -4
  11. package/dist/cjs/esm/esbuild-loader.mjs +20 -0
  12. package/dist/cjs/esm/register-esm.mjs +67 -0
  13. package/dist/cjs/esm/ts-node-loader.mjs +21 -0
  14. package/dist/cjs/esm/utils.mjs +43 -0
  15. package/dist/cjs/index.js +1 -1
  16. package/dist/cjs/plugins/analyze/index.js +3 -3
  17. package/dist/cjs/plugins/deploy/dependencies/index.js +2 -15
  18. package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -78
  19. package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
  20. package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
  21. package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
  22. package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
  23. package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
  24. package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
  25. package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
  26. package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
  27. package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
  28. package/dist/cjs/utils/config.js +1 -1
  29. package/dist/cjs/utils/loadPlugins.js +1 -1
  30. package/dist/cjs/utils/register.js +50 -23
  31. package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
  32. package/dist/types/builder/builder-rspack/index.d.ts +1 -1
  33. package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
  34. package/dist/types/builder/builder-webpack/index.d.ts +1 -1
  35. package/dist/types/builder/generator/index.d.ts +2 -2
  36. package/dist/types/builder/index.d.ts +1 -1
  37. package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
  38. package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
  39. package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
  40. package/dist/types/commands/build.d.ts +1 -1
  41. package/dist/types/commands/dev.d.ts +3 -3
  42. package/dist/types/commands/index.d.ts +3 -3
  43. package/dist/types/config/default.d.ts +1 -1
  44. package/dist/types/config/initialize/inits.d.ts +1 -1
  45. package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
  46. package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
  47. package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
  48. package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
  49. package/dist/types/esm/esbuild-loader.d.mts +6 -0
  50. package/dist/types/esm/register-esm.d.mts +5 -0
  51. package/dist/types/esm/ts-node-loader.d.mts +6 -0
  52. package/dist/types/esm/utils.d.mts +6 -0
  53. package/dist/types/exports/server.d.ts +1 -1
  54. package/dist/types/hooks.d.ts +1 -1
  55. package/dist/types/index.d.ts +2 -2
  56. package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
  57. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
  58. package/dist/types/plugins/analyze/index.d.ts +1 -1
  59. package/dist/types/plugins/deploy/dependencies/index.d.ts +3 -5
  60. package/dist/types/plugins/deploy/dependencies/utils.d.ts +2 -9
  61. package/dist/types/plugins/deploy/index.d.ts +2 -2
  62. package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
  63. package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
  64. package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
  65. package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
  66. package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
  67. package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
  68. package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
  69. package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
  70. package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
  71. package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
  72. package/dist/types/plugins/deploy/utils.d.ts +1 -1
  73. package/dist/types/plugins/serverBuild.d.ts +1 -1
  74. package/dist/types/types/hooks.d.ts +1 -1
  75. package/dist/types/types/index.d.ts +1 -1
  76. package/dist/types/utils/createServer.d.ts +1 -1
  77. package/dist/types/utils/generateWatchFiles.d.ts +1 -1
  78. package/dist/types/utils/getSelectedEntries.d.ts +1 -1
  79. package/dist/types/utils/loadPlugins.d.ts +3 -3
  80. package/dist/types/utils/register.d.ts +2 -2
  81. package/dist/types/utils/restart.d.ts +2 -2
  82. package/lib/types.d.ts +15 -0
  83. package/package.json +20 -21
  84. package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
  85. package/dist/esm/builder/builder-rspack/index.js +0 -34
  86. package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
  87. package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
  88. package/dist/esm/builder/builder-webpack/index.js +0 -52
  89. package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
  90. package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
  91. package/dist/esm/builder/generator/index.js +0 -94
  92. package/dist/esm/builder/index.js +0 -45
  93. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
  94. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
  95. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
  96. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
  97. package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
  98. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
  99. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
  100. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -288
  101. package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
  102. package/dist/esm/builder/shared/createCopyInfo.js +0 -14
  103. package/dist/esm/builder/shared/index.js +0 -3
  104. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
  105. package/dist/esm/builder/shared/types.js +0 -0
  106. package/dist/esm/commands/build.js +0 -117
  107. package/dist/esm/commands/deploy.js +0 -48
  108. package/dist/esm/commands/dev.js +0 -169
  109. package/dist/esm/commands/index.js +0 -411
  110. package/dist/esm/commands/inspect.js +0 -28
  111. package/dist/esm/commands/serve.js +0 -93
  112. package/dist/esm/config/default.js +0 -190
  113. package/dist/esm/config/index.js +0 -3
  114. package/dist/esm/config/initialize/index.js +0 -9
  115. package/dist/esm/config/initialize/inits.js +0 -85
  116. package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
  117. package/dist/esm/config/legacy/createOutputConfig.js +0 -45
  118. package/dist/esm/config/legacy/createSourceConfig.js +0 -46
  119. package/dist/esm/config/legacy/createToolsConfig.js +0 -28
  120. package/dist/esm/config/legacy/index.js +0 -43
  121. package/dist/esm/defineConfig.js +0 -16
  122. package/dist/esm/exports/server.js +0 -4
  123. package/dist/esm/hooks.js +0 -34
  124. package/dist/esm/index.js +0 -239
  125. package/dist/esm/locale/en.js +0 -43
  126. package/dist/esm/locale/index.js +0 -12
  127. package/dist/esm/locale/zh.js +0 -43
  128. package/dist/esm/plugins/analyze/constants.js +0 -14
  129. package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
  130. package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
  131. package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
  132. package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
  133. package/dist/esm/plugins/analyze/index.js +0 -380
  134. package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
  135. package/dist/esm/plugins/analyze/templates.js +0 -6
  136. package/dist/esm/plugins/analyze/utils.js +0 -101
  137. package/dist/esm/plugins/deploy/dependencies/index.js +0 -629
  138. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -643
  139. package/dist/esm/plugins/deploy/exports.js +0 -4
  140. package/dist/esm/plugins/deploy/index.js +0 -135
  141. package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
  142. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
  143. package/dist/esm/plugins/deploy/platforms/node.js +0 -133
  144. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
  145. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  146. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
  147. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
  148. package/dist/esm/plugins/deploy/utils.js +0 -47
  149. package/dist/esm/plugins/initialize/index.js +0 -119
  150. package/dist/esm/plugins/serverBuild.js +0 -87
  151. package/dist/esm/types/config/deploy.js +0 -0
  152. package/dist/esm/types/config/dev.js +0 -0
  153. package/dist/esm/types/config/experiments.js +0 -0
  154. package/dist/esm/types/config/html.js +0 -0
  155. package/dist/esm/types/config/index.js +0 -1
  156. package/dist/esm/types/config/output.js +0 -0
  157. package/dist/esm/types/config/performance.js +0 -0
  158. package/dist/esm/types/config/security.js +0 -0
  159. package/dist/esm/types/config/source.js +0 -0
  160. package/dist/esm/types/config/testing.js +0 -0
  161. package/dist/esm/types/config/tools.js +0 -0
  162. package/dist/esm/types/hooks.js +0 -0
  163. package/dist/esm/types/index.js +0 -3
  164. package/dist/esm/types/legacyConfig/deploy.js +0 -0
  165. package/dist/esm/types/legacyConfig/dev.js +0 -0
  166. package/dist/esm/types/legacyConfig/index.js +0 -0
  167. package/dist/esm/types/legacyConfig/output.js +0 -0
  168. package/dist/esm/types/legacyConfig/source.js +0 -0
  169. package/dist/esm/types/legacyConfig/testing.js +0 -0
  170. package/dist/esm/types/legacyConfig/tools.js +0 -0
  171. package/dist/esm/types/utils.js +0 -0
  172. package/dist/esm/utils/config.js +0 -122
  173. package/dist/esm/utils/createServer.js +0 -58
  174. package/dist/esm/utils/env.js +0 -16
  175. package/dist/esm/utils/generateWatchFiles.js +0 -71
  176. package/dist/esm/utils/getSelectedEntries.js +0 -67
  177. package/dist/esm/utils/loadPlugins.js +0 -69
  178. package/dist/esm/utils/printInstructions.js +0 -32
  179. package/dist/esm/utils/register.js +0 -129
  180. package/dist/esm/utils/restart.js +0 -67
  181. package/dist/esm/utils/routes.js +0 -42
  182. package/dist/esm/utils/types.js +0 -0
  183. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
  184. package/dist/esm-node/builder/builder-rspack/index.js +0 -12
  185. package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
  186. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
  187. package/dist/esm-node/builder/builder-webpack/index.js +0 -20
  188. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
  189. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
  190. package/dist/esm-node/builder/generator/index.js +0 -37
  191. package/dist/esm-node/builder/index.js +0 -11
  192. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
  193. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
  194. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
  195. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
  196. package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
  197. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
  198. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
  199. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -219
  200. package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
  201. package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
  202. package/dist/esm-node/builder/shared/index.js +0 -3
  203. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
  204. package/dist/esm-node/builder/shared/types.js +0 -0
  205. package/dist/esm-node/commands/build.js +0 -55
  206. package/dist/esm-node/commands/deploy.js +0 -12
  207. package/dist/esm-node/commands/dev.js +0 -95
  208. package/dist/esm-node/commands/index.js +0 -92
  209. package/dist/esm-node/commands/inspect.js +0 -15
  210. package/dist/esm-node/commands/serve.js +0 -51
  211. package/dist/esm-node/config/default.js +0 -197
  212. package/dist/esm-node/config/index.js +0 -3
  213. package/dist/esm-node/config/initialize/index.js +0 -9
  214. package/dist/esm-node/config/initialize/inits.js +0 -79
  215. package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
  216. package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
  217. package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
  218. package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
  219. package/dist/esm-node/config/legacy/index.js +0 -43
  220. package/dist/esm-node/defineConfig.js +0 -13
  221. package/dist/esm-node/exports/server.js +0 -4
  222. package/dist/esm-node/hooks.js +0 -34
  223. package/dist/esm-node/index.js +0 -124
  224. package/dist/esm-node/locale/en.js +0 -43
  225. package/dist/esm-node/locale/index.js +0 -12
  226. package/dist/esm-node/locale/zh.js +0 -43
  227. package/dist/esm-node/plugins/analyze/constants.js +0 -14
  228. package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
  229. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
  230. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
  231. package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
  232. package/dist/esm-node/plugins/analyze/index.js +0 -166
  233. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
  234. package/dist/esm-node/plugins/analyze/templates.js +0 -24
  235. package/dist/esm-node/plugins/analyze/utils.js +0 -68
  236. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -215
  237. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -202
  238. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  239. package/dist/esm-node/plugins/deploy/index.js +0 -44
  240. package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
  241. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
  242. package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
  243. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
  244. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  245. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
  246. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
  247. package/dist/esm-node/plugins/deploy/utils.js +0 -44
  248. package/dist/esm-node/plugins/initialize/index.js +0 -84
  249. package/dist/esm-node/plugins/serverBuild.js +0 -58
  250. package/dist/esm-node/types/config/deploy.js +0 -0
  251. package/dist/esm-node/types/config/dev.js +0 -0
  252. package/dist/esm-node/types/config/experiments.js +0 -0
  253. package/dist/esm-node/types/config/html.js +0 -0
  254. package/dist/esm-node/types/config/index.js +0 -1
  255. package/dist/esm-node/types/config/output.js +0 -0
  256. package/dist/esm-node/types/config/performance.js +0 -0
  257. package/dist/esm-node/types/config/security.js +0 -0
  258. package/dist/esm-node/types/config/source.js +0 -0
  259. package/dist/esm-node/types/config/testing.js +0 -0
  260. package/dist/esm-node/types/config/tools.js +0 -0
  261. package/dist/esm-node/types/hooks.js +0 -0
  262. package/dist/esm-node/types/index.js +0 -3
  263. package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
  264. package/dist/esm-node/types/legacyConfig/dev.js +0 -0
  265. package/dist/esm-node/types/legacyConfig/index.js +0 -0
  266. package/dist/esm-node/types/legacyConfig/output.js +0 -0
  267. package/dist/esm-node/types/legacyConfig/source.js +0 -0
  268. package/dist/esm-node/types/legacyConfig/testing.js +0 -0
  269. package/dist/esm-node/types/legacyConfig/tools.js +0 -0
  270. package/dist/esm-node/types/utils.js +0 -0
  271. package/dist/esm-node/utils/config.js +0 -49
  272. package/dist/esm-node/utils/createServer.js +0 -26
  273. package/dist/esm-node/utils/env.js +0 -16
  274. package/dist/esm-node/utils/generateWatchFiles.js +0 -30
  275. package/dist/esm-node/utils/getSelectedEntries.js +0 -34
  276. package/dist/esm-node/utils/loadPlugins.js +0 -22
  277. package/dist/esm-node/utils/printInstructions.js +0 -11
  278. package/dist/esm-node/utils/register.js +0 -69
  279. package/dist/esm-node/utils/restart.js +0 -22
  280. package/dist/esm-node/utils/routes.js +0 -21
  281. package/dist/esm-node/utils/types.js +0 -0
  282. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
  283. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  284. /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
  285. /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,133 +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 "node:path";
4
- import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, chalk } from "@modern-js/utils";
5
- import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
6
- import { handleDependencies } from "../dependencies";
7
- var createNodePreset = function(appContext, config) {
8
- var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverPlugins = appContext.serverPlugins;
9
- var plugins = serverPlugins.map(function(plugin) {
10
- return plugin.name;
11
- });
12
- var outputDirectory = path.join(appDirectory, ".output");
13
- var staticDirectory = path.join(outputDirectory, "static");
14
- var entryFilePath = path.join(outputDirectory, "index.js");
15
- return {
16
- prepare: function prepare() {
17
- return _async_to_generator(function() {
18
- return _ts_generator(this, function(_state) {
19
- switch (_state.label) {
20
- case 0:
21
- return [
22
- 4,
23
- fse.remove(outputDirectory)
24
- ];
25
- case 1:
26
- _state.sent();
27
- return [
28
- 2
29
- ];
30
- }
31
- });
32
- })();
33
- },
34
- writeOutput: function writeOutput() {
35
- return _async_to_generator(function() {
36
- return _ts_generator(this, function(_state) {
37
- switch (_state.label) {
38
- case 0:
39
- return [
40
- 4,
41
- fse.copy(distDirectory, outputDirectory)
42
- ];
43
- case 1:
44
- _state.sent();
45
- return [
46
- 2
47
- ];
48
- }
49
- });
50
- })();
51
- },
52
- genEntry: function genEntry() {
53
- return _async_to_generator(function() {
54
- var _config_bff, serverConfig, pluginImportCode, dynamicProdOptions, pluginsCode, entryCode, serverAppContext;
55
- return _ts_generator(this, function(_state) {
56
- switch (_state.label) {
57
- case 0:
58
- serverConfig = {
59
- server: {
60
- port: 8080
61
- },
62
- bff: {
63
- prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
64
- },
65
- output: {
66
- path: "."
67
- }
68
- };
69
- pluginImportCode = genPluginImportsCode(plugins || []);
70
- dynamicProdOptions = {
71
- config: serverConfig,
72
- serverConfigFile: DEFAULT_SERVER_CONFIG
73
- };
74
- pluginsCode = "[".concat(plugins.map(function(plugin, index) {
75
- return "plugin_".concat(index, "()");
76
- }).join(","), "]");
77
- return [
78
- 4,
79
- fse.readFile(path.join(__dirname, "./nodeEntry.js"))
80
- ];
81
- case 1:
82
- entryCode = _state.sent().toString();
83
- serverAppContext = serverAppContenxtTemplate(appContext);
84
- entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
85
- return [
86
- 4,
87
- fse.writeFile(entryFilePath, entryCode)
88
- ];
89
- case 2:
90
- _state.sent();
91
- return [
92
- 2
93
- ];
94
- }
95
- });
96
- })();
97
- },
98
- end: function end() {
99
- return _async_to_generator(function() {
100
- var filter;
101
- return _ts_generator(this, function(_state) {
102
- switch (_state.label) {
103
- case 0:
104
- console.log("Static directory:", chalk.blue(path.relative(appDirectory, staticDirectory)));
105
- console.log("You can preview this build by", chalk.blue("node .output/index"));
106
- filter = function(filePath) {
107
- return !filePath.startsWith(staticDirectory);
108
- };
109
- return [
110
- 4,
111
- handleDependencies({
112
- appDir: appDirectory,
113
- serverRootDir: outputDirectory,
114
- includeEntries: [
115
- require.resolve("@modern-js/prod-server")
116
- ],
117
- entryFilter: filter
118
- })
119
- ];
120
- case 1:
121
- _state.sent();
122
- return [
123
- 2
124
- ];
125
- }
126
- });
127
- })();
128
- }
129
- };
130
- };
131
- export {
132
- createNodePreset
133
- };
@@ -1,108 +0,0 @@
1
- var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
2
- var _object_spread = require("@swc/helpers/_/_object_spread");
3
- var _ts_generator = require("@swc/helpers/_/_ts_generator");
4
- var fs = require("node:fs/promises");
5
- var path = require("node:path");
6
- var createProdServer = require("@modern-js/prod-server").createProdServer;
7
- p_genPluginImportsCode;
8
- if (!process.env.NODE_ENV) {
9
- process.env.NODE_ENV = "production";
10
- }
11
- function loadRoutes(routeFilepath) {
12
- return _loadRoutes.apply(this, arguments);
13
- }
14
- function _loadRoutes() {
15
- _loadRoutes = _async_to_generator._(function(routeFilepath) {
16
- var content, routeSpec, error;
17
- return _ts_generator._(this, function(_state) {
18
- switch (_state.label) {
19
- case 0:
20
- _state.trys.push([
21
- 0,
22
- 3,
23
- ,
24
- 4
25
- ]);
26
- return [
27
- 4,
28
- fs.access(routeFilepath)
29
- ];
30
- case 1:
31
- _state.sent();
32
- return [
33
- 4,
34
- fs.readFile(routeFilepath, "utf-8")
35
- ];
36
- case 2:
37
- content = _state.sent();
38
- routeSpec = JSON.parse(content);
39
- return [
40
- 2,
41
- routeSpec.routes || []
42
- ];
43
- case 3:
44
- error = _state.sent();
45
- console.warn("route.json not found or invalid, continuing with empty routes.");
46
- return [
47
- 2,
48
- []
49
- ];
50
- case 4:
51
- return [
52
- 2
53
- ];
54
- }
55
- });
56
- });
57
- return _loadRoutes.apply(this, arguments);
58
- }
59
- function main() {
60
- return _main.apply(this, arguments);
61
- }
62
- function _main() {
63
- _main = _async_to_generator._(function() {
64
- var routeFilepath, routes, dynamicProdOptions, prodServerOptions, app, port;
65
- return _ts_generator._(this, function(_state) {
66
- switch (_state.label) {
67
- case 0:
68
- routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
69
- return [
70
- 4,
71
- loadRoutes(routeFilepath)
72
- ];
73
- case 1:
74
- routes = _state.sent();
75
- dynamicProdOptions = p_dynamicProdOptions;
76
- prodServerOptions = _object_spread._({
77
- pwd: __dirname,
78
- routes,
79
- disableCustomHook: true,
80
- appContext: {
81
- sharedDirectory: p_sharedDirectory,
82
- apiDirectory: p_apiDirectory,
83
- lambdaDirectory: p_lambdaDirectory
84
- },
85
- plugins: p_plugins
86
- }, dynamicProdOptions);
87
- return [
88
- 4,
89
- createProdServer(prodServerOptions)
90
- ];
91
- case 2:
92
- app = _state.sent();
93
- port = process.env.PORT || 8080;
94
- app.listen({
95
- host: "::",
96
- port
97
- }, function() {
98
- console.log("\x1B[32mServer is listening on http://[::]:".concat(port), "\x1B[0m");
99
- });
100
- return [
101
- 2
102
- ];
103
- }
104
- });
105
- });
106
- return _main.apply(this, arguments);
107
- }
108
- main();
File without changes
@@ -1,233 +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 "node:path";
4
- import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
5
- import { isMainEntry } from "../../../utils/routes";
6
- import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
7
- import { handleDependencies } from "../dependencies";
8
- var createVercelPreset = function(appContext, modernConfig, needModernServer) {
9
- var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, entrypoints = appContext.entrypoints, serverPlugins = appContext.serverPlugins;
10
- var plugins = serverPlugins.map(function(plugin) {
11
- return plugin.name;
12
- });
13
- var vercelOutput = path.join(appDirectory, ".vercel");
14
- var outputDirectory = path.join(vercelOutput, "output");
15
- var funcsDirectory = path.join(outputDirectory, "functions", "index.func");
16
- var entryFilePath = path.join(funcsDirectory, "index.js");
17
- return {
18
- prepare: function prepare() {
19
- return _async_to_generator(function() {
20
- return _ts_generator(this, function(_state) {
21
- switch (_state.label) {
22
- case 0:
23
- return [
24
- 4,
25
- fse.remove(vercelOutput)
26
- ];
27
- case 1:
28
- _state.sent();
29
- return [
30
- 2
31
- ];
32
- }
33
- });
34
- })();
35
- },
36
- writeOutput: function writeOutput() {
37
- return _async_to_generator(function() {
38
- var config, mainEntryName, staticDirectory, destHtmlDirectory, outputHtmlDirectory;
39
- return _ts_generator(this, function(_state) {
40
- switch (_state.label) {
41
- case 0:
42
- config = {
43
- version: 3,
44
- routes: [
45
- {
46
- src: "/static/(.*)",
47
- headers: {
48
- "cache-control": "s-maxage=31536000, immutable"
49
- },
50
- continue: true
51
- },
52
- {
53
- handle: "filesystem"
54
- }
55
- ]
56
- };
57
- if (!needModernServer) {
58
- mainEntryName = modernConfig.source.mainEntryName;
59
- entrypoints.forEach(function(entry) {
60
- var isMain = isMainEntry(entry.entryName, mainEntryName);
61
- config.routes.push({
62
- src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
63
- headers: {
64
- "cache-control": "s-maxage=0"
65
- },
66
- dest: "/html/".concat(entry.entryName, "/index.html")
67
- });
68
- });
69
- } else {
70
- config.routes.push({
71
- src: "/(.*)",
72
- dest: "/index"
73
- });
74
- }
75
- return [
76
- 4,
77
- fse.ensureDir(outputDirectory)
78
- ];
79
- case 1:
80
- _state.sent();
81
- return [
82
- 4,
83
- fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
84
- spaces: 2
85
- })
86
- ];
87
- case 2:
88
- _state.sent();
89
- staticDirectory = path.join(outputDirectory, "static/static");
90
- return [
91
- 4,
92
- fse.copy(path.join(distDirectory, "static"), staticDirectory)
93
- ];
94
- case 3:
95
- _state.sent();
96
- if (!!needModernServer)
97
- return [
98
- 3,
99
- 5
100
- ];
101
- destHtmlDirectory = path.join(distDirectory, "html");
102
- outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
103
- return [
104
- 4,
105
- fse.copy(destHtmlDirectory, outputHtmlDirectory)
106
- ];
107
- case 4:
108
- _state.sent();
109
- return [
110
- 3,
111
- 9
112
- ];
113
- case 5:
114
- return [
115
- 4,
116
- fse.ensureDir(funcsDirectory)
117
- ];
118
- case 6:
119
- _state.sent();
120
- return [
121
- 4,
122
- fse.copy(distDirectory, funcsDirectory, {
123
- filter: function(src) {
124
- var distStaticDirectory = path.join(distDirectory, "static");
125
- return !src.includes(distStaticDirectory);
126
- }
127
- })
128
- ];
129
- case 7:
130
- _state.sent();
131
- return [
132
- 4,
133
- fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
134
- runtime: "nodejs16.x",
135
- handler: "index.js",
136
- launcherType: "Nodejs",
137
- shouldAddHelpers: false,
138
- supportsResponseStreaming: true
139
- })
140
- ];
141
- case 8:
142
- _state.sent();
143
- _state.label = 9;
144
- case 9:
145
- return [
146
- 2
147
- ];
148
- }
149
- });
150
- })();
151
- },
152
- genEntry: function genEntry() {
153
- return _async_to_generator(function() {
154
- var _modernConfig_bff, serverConfig, pluginImportCode, dynamicProdOptions, pluginsCode, serverAppContext, entryCode;
155
- return _ts_generator(this, function(_state) {
156
- switch (_state.label) {
157
- case 0:
158
- if (!needModernServer) {
159
- return [
160
- 2
161
- ];
162
- }
163
- serverConfig = {
164
- bff: {
165
- prefix: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_bff = modernConfig.bff) === null || _modernConfig_bff === void 0 ? void 0 : _modernConfig_bff.prefix
166
- },
167
- output: {
168
- path: "."
169
- }
170
- };
171
- pluginImportCode = genPluginImportsCode(plugins || []);
172
- dynamicProdOptions = {
173
- config: serverConfig,
174
- serverConfigFile: DEFAULT_SERVER_CONFIG
175
- };
176
- pluginsCode = "[".concat(plugins.map(function(plugin, index) {
177
- return "plugin_".concat(index, "()");
178
- }).join(","), "]");
179
- serverAppContext = serverAppContenxtTemplate(appContext);
180
- return [
181
- 4,
182
- fse.readFile(path.join(__dirname, "./vercelEntry.js"))
183
- ];
184
- case 1:
185
- entryCode = _state.sent().toString();
186
- entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
187
- return [
188
- 4,
189
- fse.writeFile(entryFilePath, entryCode)
190
- ];
191
- case 2:
192
- _state.sent();
193
- return [
194
- 2
195
- ];
196
- }
197
- });
198
- })();
199
- },
200
- end: function end() {
201
- return _async_to_generator(function() {
202
- return _ts_generator(this, function(_state) {
203
- switch (_state.label) {
204
- case 0:
205
- if (!needModernServer) {
206
- return [
207
- 2
208
- ];
209
- }
210
- return [
211
- 4,
212
- handleDependencies({
213
- appDir: appDirectory,
214
- serverRootDir: funcsDirectory,
215
- includeEntries: [
216
- require.resolve("@modern-js/prod-server")
217
- ]
218
- })
219
- ];
220
- case 1:
221
- _state.sent();
222
- return [
223
- 2
224
- ];
225
- }
226
- });
227
- })();
228
- }
229
- };
230
- };
231
- export {
232
- createVercelPreset
233
- };
@@ -1,203 +0,0 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __commonJS = (cb, mod) => function __require() {
3
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
- };
5
- var require_vercelEntry = __commonJS({
6
- "src/plugins/deploy/platforms/vercelEntry.js"(exports, module) {
7
- var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
8
- var _object_spread = require("@swc/helpers/_/_object_spread");
9
- var _ts_generator = require("@swc/helpers/_/_ts_generator");
10
- var fs = require("node:fs/promises");
11
- var path = require("node:path");
12
- var createProdServer = require("@modern-js/prod-server").createProdServer;
13
- p_genPluginImportsCode;
14
- if (!process.env.NODE_ENV) {
15
- process.env.NODE_ENV = "production";
16
- }
17
- var requestHandler = null;
18
- var handlerCreationPromise = null;
19
- function loadRoutes(routeFilepath) {
20
- return _loadRoutes.apply(this, arguments);
21
- }
22
- function _loadRoutes() {
23
- _loadRoutes = _async_to_generator._(function(routeFilepath) {
24
- var content, routeSpec, error;
25
- return _ts_generator._(this, function(_state) {
26
- switch (_state.label) {
27
- case 0:
28
- _state.trys.push([
29
- 0,
30
- 3,
31
- ,
32
- 4
33
- ]);
34
- return [
35
- 4,
36
- fs.access(routeFilepath)
37
- ];
38
- case 1:
39
- _state.sent();
40
- return [
41
- 4,
42
- fs.readFile(routeFilepath, "utf-8")
43
- ];
44
- case 2:
45
- content = _state.sent();
46
- routeSpec = JSON.parse(content);
47
- return [
48
- 2,
49
- routeSpec.routes || []
50
- ];
51
- case 3:
52
- error = _state.sent();
53
- console.warn("route.json not found or invalid, continuing with empty routes.");
54
- return [
55
- 2,
56
- []
57
- ];
58
- case 4:
59
- return [
60
- 2
61
- ];
62
- }
63
- });
64
- });
65
- return _loadRoutes.apply(this, arguments);
66
- }
67
- function initServer() {
68
- return _initServer.apply(this, arguments);
69
- }
70
- function _initServer() {
71
- _initServer = _async_to_generator._(function() {
72
- var routeFilepath, routes, dynamicProdOptions, prodServerOptions, app;
73
- return _ts_generator._(this, function(_state) {
74
- switch (_state.label) {
75
- case 0:
76
- routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
77
- return [
78
- 4,
79
- loadRoutes(routeFilepath)
80
- ];
81
- case 1:
82
- routes = _state.sent();
83
- dynamicProdOptions = p_dynamicProdOptions;
84
- prodServerOptions = _object_spread._({
85
- pwd: __dirname,
86
- routes,
87
- disableCustomHook: true,
88
- appContext: {
89
- sharedDirectory: p_sharedDirectory,
90
- apiDirectory: p_apiDirectory,
91
- lambdaDirectory: p_lambdaDirectory
92
- },
93
- plugins: p_plugins
94
- }, dynamicProdOptions);
95
- return [
96
- 4,
97
- createProdServer(prodServerOptions)
98
- ];
99
- case 2:
100
- app = _state.sent();
101
- return [
102
- 2,
103
- app.getRequestListener()
104
- ];
105
- }
106
- });
107
- });
108
- return _initServer.apply(this, arguments);
109
- }
110
- function createHandler() {
111
- return _createHandler.apply(this, arguments);
112
- }
113
- function _createHandler() {
114
- _createHandler = _async_to_generator._(function() {
115
- return _ts_generator._(this, function(_state) {
116
- switch (_state.label) {
117
- case 0:
118
- if (!handlerCreationPromise) {
119
- handlerCreationPromise = _async_to_generator._(function() {
120
- var error;
121
- return _ts_generator._(this, function(_state2) {
122
- switch (_state2.label) {
123
- case 0:
124
- _state2.trys.push([
125
- 0,
126
- 2,
127
- ,
128
- 3
129
- ]);
130
- return [
131
- 4,
132
- initServer()
133
- ];
134
- case 1:
135
- requestHandler = _state2.sent();
136
- return [
137
- 3,
138
- 3
139
- ];
140
- case 2:
141
- error = _state2.sent();
142
- console.error("Error creating server:", error);
143
- process.exit(1);
144
- return [
145
- 3,
146
- 3
147
- ];
148
- case 3:
149
- return [
150
- 2
151
- ];
152
- }
153
- });
154
- })();
155
- }
156
- return [
157
- 4,
158
- handlerCreationPromise
159
- ];
160
- case 1:
161
- _state.sent();
162
- return [
163
- 2,
164
- requestHandler
165
- ];
166
- }
167
- });
168
- });
169
- return _createHandler.apply(this, arguments);
170
- }
171
- createHandler();
172
- module.exports = function() {
173
- var _ref = _async_to_generator._(function(req, res) {
174
- return _ts_generator._(this, function(_state) {
175
- switch (_state.label) {
176
- case 0:
177
- if (!!requestHandler)
178
- return [
179
- 3,
180
- 2
181
- ];
182
- return [
183
- 4,
184
- createHandler()
185
- ];
186
- case 1:
187
- _state.sent();
188
- _state.label = 2;
189
- case 2:
190
- return [
191
- 2,
192
- requestHandler(req, res)
193
- ];
194
- }
195
- });
196
- });
197
- return function(req, res) {
198
- return _ref.apply(this, arguments);
199
- };
200
- }();
201
- }
202
- });
203
- export default require_vercelEntry();