@modern-js/app-tools 2.49.3-alpha.10 → 2.49.3-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/cjs/analyze/getServerRoutes.js +3 -4
  2. package/dist/cjs/plugins/deploy/entrys/vercel.js +94 -0
  3. package/dist/cjs/plugins/deploy/index.js +21 -54
  4. package/dist/cjs/utils/routes.js +2 -7
  5. package/dist/esm/analyze/getServerRoutes.js +4 -5
  6. package/dist/esm/plugins/deploy/entrys/vercel.js +40 -0
  7. package/dist/esm/plugins/deploy/index.js +56 -119
  8. package/dist/esm/utils/routes.js +2 -6
  9. package/dist/esm-node/analyze/getServerRoutes.js +4 -5
  10. package/dist/esm-node/plugins/deploy/entrys/vercel.js +70 -0
  11. package/dist/esm-node/plugins/deploy/index.js +21 -54
  12. package/dist/esm-node/utils/routes.js +2 -6
  13. package/dist/types/plugins/deploy/{platforms → entrys}/vercel.d.ts +1 -1
  14. package/dist/types/utils/routes.d.ts +3 -3
  15. package/package.json +7 -7
  16. package/dist/cjs/plugins/deploy/platforms/nodeEntry.js +0 -36
  17. package/dist/cjs/plugins/deploy/platforms/platform.js +0 -16
  18. package/dist/cjs/plugins/deploy/platforms/vercel.js +0 -57
  19. package/dist/cjs/plugins/deploy/platforms/vercelEntry.js +0 -55
  20. package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -99
  21. package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
  22. package/dist/esm/plugins/deploy/platforms/vercel.js +0 -47
  23. package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -197
  24. package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -35
  25. package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
  26. package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -23
  27. package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -63
  28. package/dist/types/plugins/deploy/platforms/nodeEntry.d.ts +0 -1
  29. package/dist/types/plugins/deploy/platforms/platform.d.ts +0 -1
  30. package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
  31. /package/dist/cjs/plugins/deploy/{platforms → entrys}/netlify.js +0 -0
  32. /package/dist/cjs/plugins/deploy/{platforms → entrys}/node.js +0 -0
  33. /package/dist/esm/plugins/deploy/{platforms → entrys}/netlify.js +0 -0
  34. /package/dist/esm/plugins/deploy/{platforms → entrys}/node.js +0 -0
  35. /package/dist/esm-node/plugins/deploy/{platforms → entrys}/netlify.js +0 -0
  36. /package/dist/esm-node/plugins/deploy/{platforms → entrys}/node.js +0 -0
  37. /package/dist/types/plugins/deploy/{platforms → entrys}/netlify.d.ts +0 -0
  38. /package/dist/types/plugins/deploy/{platforms → entrys}/node.d.ts +0 -0
@@ -3,7 +3,6 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "path";
4
4
  import { fs as fse, getInternalPlugins } from "@modern-js/utils";
5
5
  import { provider } from "std-env";
6
- import { isMainEntry } from "../../utils/routes";
7
6
  import { getProjectUsage } from "./utils";
8
7
  import { handleDependencies } from "./dependencies";
9
8
  function deploy_default() {
@@ -18,20 +17,19 @@ function deploy_default() {
18
17
  return {
19
18
  beforeDeploy: function beforeDeploy() {
20
19
  return _async_to_generator(function() {
21
- var appContext, modernConfig, mainEntryName, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, outputDirectory, funcsDirectory, staticDirectory, netlifyOutput, routes, redirectContent, redirectFilePath, vercelOutput, config, destHtmlDirectory, outputHtmlDirectory, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
20
+ var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, configContext, outputDirectory, funcsDirectory, staticDirectory, vercelOutput, config, destHtmlDirectory, outputHtmlDirectory, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
22
21
  return _ts_generator(this, function(_state) {
23
22
  switch (_state.label) {
24
23
  case 0:
25
24
  appContext = api.useAppContext();
26
- modernConfig = api.useResolvedConfigContext();
27
- mainEntryName = modernConfig.source.mainEntryName;
28
25
  appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
29
26
  _getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
30
27
  needModernServer = useSSR || useAPI || useWebServer;
28
+ configContext = api.useResolvedConfigContext();
31
29
  outputDirectory = path.join(appDirectory, ".output");
32
30
  funcsDirectory = outputDirectory;
33
31
  staticDirectory = path.join(outputDirectory, "static");
34
- if (!(deployTarget === "node"))
32
+ if (!(deployTarget === "node" || deployTarget === "netlify"))
35
33
  return [
36
34
  3,
37
35
  3
@@ -50,79 +48,17 @@ function deploy_default() {
50
48
  _state.sent();
51
49
  _state.label = 3;
52
50
  case 3:
53
- if (!(deployTarget === "netlify"))
54
- return [
55
- 3,
56
- 8
57
- ];
58
- netlifyOutput = path.join(appDirectory, ".netlify");
59
- funcsDirectory = path.join(netlifyOutput, "functions");
60
- routes = [];
61
- if (!needModernServer) {
62
- entrypoints.forEach(function(entry) {
63
- var isMain = isMainEntry(entry.entryName, mainEntryName);
64
- routes.push({
65
- src: "/".concat(isMain ? "" : "".concat(entry.entryName, "/"), "*"),
66
- dest: "/html/".concat(entry.entryName, "/index.html"),
67
- status: 200
68
- });
69
- });
70
- } else {
71
- routes.push({
72
- src: "/*",
73
- dest: "/.netlify/functions/index",
74
- status: 200
75
- });
76
- throw new Error("Currently on the Netlify platform, only CSR projects are supporte, Support for SSR and BFF projects will be available later");
77
- }
78
- console.log("routes", routes, needModernServer);
79
- redirectContent = routes.map(function(route) {
80
- return "".concat(route.src, " ").concat(route.dest, " ").concat(route.status);
81
- }).join("\n");
82
- console.log("redirectContent", redirectContent);
83
- return [
84
- 4,
85
- fse.remove(outputDirectory)
86
- ];
87
- case 4:
88
- _state.sent();
89
- return [
90
- 4,
91
- fse.ensureDir(funcsDirectory)
92
- ];
93
- case 5:
94
- _state.sent();
95
- return [
96
- 4,
97
- fse.copy(distDirectory, funcsDirectory, {
98
- filter: function(src) {
99
- var distStaticDirectory = path.join(distDirectory, "static");
100
- return !src.includes(distStaticDirectory);
101
- }
102
- })
103
- ];
104
- case 6:
105
- _state.sent();
106
- redirectFilePath = path.join(distDirectory, "_redirects");
107
- return [
108
- 4,
109
- fse.writeFile(redirectFilePath, redirectContent)
110
- ];
111
- case 7:
112
- _state.sent();
113
- _state.label = 8;
114
- case 8:
115
51
  if (!(deployTarget === "vercel"))
116
52
  return [
117
53
  3,
118
- 18
54
+ 13
119
55
  ];
120
56
  vercelOutput = path.join(appDirectory, ".vercel");
121
57
  return [
122
58
  4,
123
59
  fse.remove(vercelOutput)
124
60
  ];
125
- case 9:
61
+ case 4:
126
62
  _state.sent();
127
63
  outputDirectory = path.join(vercelOutput, "output");
128
64
  config = {
@@ -142,9 +78,8 @@ function deploy_default() {
142
78
  };
143
79
  if (!needModernServer) {
144
80
  entrypoints.forEach(function(entry) {
145
- var isMain = isMainEntry(entry.entryName, mainEntryName);
146
81
  config.routes.push({
147
- src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
82
+ src: "/".concat(entry.entryName, "(?:/.*)?"),
148
83
  headers: {
149
84
  "cache-control": "s-maxage=0"
150
85
  },
@@ -161,7 +96,7 @@ function deploy_default() {
161
96
  4,
162
97
  fse.ensureDir(outputDirectory)
163
98
  ];
164
- case 10:
99
+ case 5:
165
100
  _state.sent();
166
101
  return [
167
102
  4,
@@ -169,19 +104,19 @@ function deploy_default() {
169
104
  spaces: 2
170
105
  })
171
106
  ];
172
- case 11:
107
+ case 6:
173
108
  _state.sent();
174
109
  staticDirectory = path.join(outputDirectory, "static/static");
175
110
  return [
176
111
  4,
177
112
  fse.copy(path.join(distDirectory, "static"), staticDirectory)
178
113
  ];
179
- case 12:
114
+ case 7:
180
115
  _state.sent();
181
116
  if (!!needModernServer)
182
117
  return [
183
118
  3,
184
- 14
119
+ 9
185
120
  ];
186
121
  destHtmlDirectory = path.join(distDirectory, "html");
187
122
  outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
@@ -189,19 +124,19 @@ function deploy_default() {
189
124
  4,
190
125
  fse.copy(destHtmlDirectory, outputHtmlDirectory)
191
126
  ];
192
- case 13:
127
+ case 8:
193
128
  _state.sent();
194
129
  return [
195
130
  3,
196
- 18
131
+ 13
197
132
  ];
198
- case 14:
133
+ case 9:
199
134
  funcsDirectory = path.join(outputDirectory, "functions", "index.func");
200
135
  return [
201
136
  4,
202
137
  fse.ensureDir(funcsDirectory)
203
138
  ];
204
- case 15:
139
+ case 10:
205
140
  _state.sent();
206
141
  return [
207
142
  4,
@@ -212,7 +147,7 @@ function deploy_default() {
212
147
  }
213
148
  })
214
149
  ];
215
- case 16:
150
+ case 11:
216
151
  _state.sent();
217
152
  return [
218
153
  4,
@@ -224,10 +159,17 @@ function deploy_default() {
224
159
  supportsResponseStreaming: true
225
160
  })
226
161
  ];
227
- case 17:
162
+ case 12:
228
163
  _state.sent();
229
- _state.label = 18;
230
- case 18:
164
+ _state.label = 13;
165
+ case 13:
166
+ bff = configContext.bff;
167
+ config1 = {
168
+ output: {
169
+ path: "."
170
+ },
171
+ bff
172
+ };
231
173
  plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
232
174
  serverAppContext = {
233
175
  sharedDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, sharedDirectory), '")'),
@@ -241,93 +183,88 @@ function deploy_default() {
241
183
  case "node":
242
184
  return [
243
185
  3,
244
- 19
186
+ 14
245
187
  ];
246
188
  case "vercel":
247
189
  return [
248
190
  3,
249
- 21
191
+ 16
250
192
  ];
251
193
  case "netlify":
252
194
  return [
253
195
  3,
254
- 24
196
+ 18
255
197
  ];
256
198
  }
257
199
  return [
258
200
  3,
259
- 26
201
+ 20
260
202
  ];
261
- case 19:
203
+ case 14:
262
204
  return [
263
205
  4,
264
- import("./platforms/node")
206
+ import("./entrys/node")
265
207
  ];
266
- case 20:
208
+ case 15:
267
209
  genNodeEntry = _state.sent().genNodeEntry;
268
210
  code = genNodeEntry({
269
211
  plugins,
270
- config: modernConfig,
212
+ config: config1,
271
213
  appContext: serverAppContext
272
214
  });
273
215
  return [
274
216
  3,
275
- 27
217
+ 21
276
218
  ];
277
- case 21:
219
+ case 16:
278
220
  return [
279
221
  4,
280
- import("./platforms/vercel")
222
+ import("./entrys/vercel")
281
223
  ];
282
- case 22:
224
+ case 17:
283
225
  genVercelEntry = _state.sent().genVercelEntry;
284
- return [
285
- 4,
286
- genVercelEntry({
287
- plugins,
288
- config: modernConfig,
289
- appContext: serverAppContext
290
- })
291
- ];
292
- case 23:
293
- code = _state.sent();
226
+ code = genVercelEntry({
227
+ plugins,
228
+ config: config1,
229
+ appContext: serverAppContext
230
+ });
294
231
  return [
295
232
  3,
296
- 27
233
+ 21
297
234
  ];
298
- case 24:
235
+ case 18:
299
236
  return [
300
237
  4,
301
- import("./platforms/netlify")
238
+ import("./entrys/netlify")
302
239
  ];
303
- case 25:
240
+ case 19:
304
241
  genNetlifyEntry = _state.sent().genNetlifyEntry;
305
242
  code = genNetlifyEntry({
306
243
  plugins,
307
- config: modernConfig,
244
+ config: config1,
308
245
  appContext: serverAppContext
309
246
  });
310
247
  return [
311
248
  3,
312
- 27
249
+ 21
313
250
  ];
314
- case 26:
251
+ case 20:
315
252
  {
316
253
  code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
317
254
  }
318
- _state.label = 27;
319
- case 27:
255
+ _state.label = 21;
256
+ case 21:
320
257
  entryFilePath = path.join(funcsDirectory, "index.js");
321
258
  if (!needModernServer)
322
259
  return [
323
260
  3,
324
- 30
261
+ 24
325
262
  ];
326
263
  return [
327
264
  4,
328
265
  fse.writeFile(entryFilePath, code)
329
266
  ];
330
- case 28:
267
+ case 22:
331
268
  _state.sent();
332
269
  return [
333
270
  4,
@@ -335,10 +272,10 @@ function deploy_default() {
335
272
  "@modern-js/prod-server"
336
273
  ])
337
274
  ];
338
- case 29:
275
+ case 23:
339
276
  _state.sent();
340
- _state.label = 30;
341
- case 30:
277
+ _state.label = 24;
278
+ case 24:
342
279
  return [
343
280
  2
344
281
  ];
@@ -1,7 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "path";
4
- import { fs, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE } from "@modern-js/utils";
4
+ import { fs, ROUTE_SPEC_FILE } from "@modern-js/utils";
5
5
  var generateRoutes = function() {
6
6
  var _ref = _async_to_generator(function(appContext) {
7
7
  var serverRoutes, distDirectory, output;
@@ -32,11 +32,7 @@ var getPathWithoutExt = function(filename) {
32
32
  var extname = path.extname(filename);
33
33
  return filename.slice(0, -extname.length);
34
34
  };
35
- var isMainEntry = function(entryName, mainEntryName) {
36
- return entryName === (mainEntryName || MAIN_ENTRY_NAME);
37
- };
38
35
  export {
39
36
  generateRoutes,
40
- getPathWithoutExt,
41
- isMainEntry
37
+ getPathWithoutExt
42
38
  };
@@ -1,7 +1,6 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
- import { urlJoin, isPlainObject, removeLeadingSlash, getEntryOptions, SERVER_BUNDLE_DIRECTORY, removeTailSlash, SERVER_WORKER_BUNDLE_DIRECTORY } from "@modern-js/utils";
4
- import { isMainEntry } from "../utils/routes";
3
+ import { urlJoin, isPlainObject, removeLeadingSlash, getEntryOptions, SERVER_BUNDLE_DIRECTORY, MAIN_ENTRY_NAME, removeTailSlash, SERVER_WORKER_BUNDLE_DIRECTORY } from "@modern-js/utils";
5
4
  import { walkDirectory } from "./utils";
6
5
  const applyBaseUrl = (baseUrl, routes) => {
7
6
  if (baseUrl) {
@@ -74,14 +73,14 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
74
73
  const { packageName } = appContext;
75
74
  const workerSSR = deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr;
76
75
  let htmlRoutes = entrypoints.reduce((previous, { entryName }) => {
77
- const isMain = isMainEntry(entryName, mainEntryName);
78
- const entryOptions = getEntryOptions(entryName, isMain, ssr, ssrByEntries, packageName);
76
+ const isMainEntry = entryName === (mainEntryName || MAIN_ENTRY_NAME);
77
+ const entryOptions = getEntryOptions(entryName, isMainEntry, ssr, ssrByEntries, packageName);
79
78
  const isSSR = Boolean(entryOptions);
80
79
  const isWorker = Boolean(workerSSR);
81
80
  const isStream = typeof entryOptions === "object" && (entryOptions.mode === "stream" || Boolean(entryOptions.preload));
82
81
  const { resHeaders } = (routes === null || routes === void 0 ? void 0 : routes[entryName]) || {};
83
82
  let route = {
84
- urlPath: `/${isMain ? "" : entryName}`,
83
+ urlPath: `/${isMainEntry ? "" : entryName}`,
85
84
  entryName,
86
85
  entryPath: removeLeadingSlash(path.posix.normalize(`${htmlPath}/${entryName}${disableHtmlFolder ? ".html" : "/index.html"}`)),
87
86
  isSPA: true,
@@ -0,0 +1,70 @@
1
+ import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG } from "@modern-js/utils";
2
+ import { genPluginImportsCode, getPluginsCode, severAppContextTemplate } from "../utils";
3
+ function genVercelEntry({ config, plugins, appContext } = {}) {
4
+ const defaultConfig = {
5
+ server: {
6
+ port: 8080
7
+ },
8
+ output: {
9
+ path: "."
10
+ }
11
+ };
12
+ return `
13
+
14
+ const fs = require('node:fs/promises');
15
+ const path = require('node:path');
16
+ const { createProdServer } = require('@modern-js/prod-server');
17
+ ${genPluginImportsCode(plugins || [])}
18
+
19
+ if(!process.env.NODE_ENV){
20
+ process.env.NODE_ENV = 'production';
21
+ }
22
+
23
+ let requestHandler = null;
24
+ async function createHandler() {
25
+ try {
26
+ let routes = [];
27
+ const routeFilepath = path.join(__dirname, "${ROUTE_SPEC_FILE}");
28
+ try {
29
+ await fs.access(routeFilepath);
30
+ const content = await fs.readFile(routeFilepath, "utf-8");
31
+ const routeSpec = JSON.parse(content);
32
+ routes = routeSpec.routes;
33
+ } catch (error) {
34
+ console.warn('route.json not found, continuing with empty routes.');
35
+ }
36
+
37
+ const prodServerOptions = {
38
+ pwd: __dirname,
39
+ routes,
40
+ config: ${JSON.stringify(config || defaultConfig)},
41
+ serverConfigFile: '${DEFAULT_SERVER_CONFIG}',
42
+ plugins: ${getPluginsCode(plugins || [])},
43
+ appContext: ${appContext ? severAppContextTemplate(appContext) : "undefined"},
44
+ disableCustomHook: true
45
+ }
46
+
47
+ const app = await createProdServer(prodServerOptions)
48
+
49
+ requestHandler = app.getRequestListener();
50
+
51
+ return requestHandler;
52
+ } catch(error) {
53
+ console.error(error);
54
+ process.exit(1);
55
+ }
56
+ }
57
+
58
+ createHandler();
59
+
60
+ module.exports = async(req, res) => {
61
+ if(typeof requestHandler !== 'function'){
62
+ await createHandler();
63
+ }
64
+ return requestHandler(req, res);
65
+ }
66
+ `;
67
+ }
68
+ export {
69
+ genVercelEntry
70
+ };
@@ -1,7 +1,6 @@
1
1
  import path from "path";
2
2
  import { fs as fse, getInternalPlugins } from "@modern-js/utils";
3
3
  import { provider } from "std-env";
4
- import { isMainEntry } from "../../utils/routes";
5
4
  import { getProjectUsage } from "./utils";
6
5
  import { handleDependencies } from "./dependencies";
7
6
  var deploy_default = () => ({
@@ -15,60 +14,22 @@ var deploy_default = () => ({
15
14
  return {
16
15
  async beforeDeploy() {
17
16
  const appContext = api.useAppContext();
18
- const modernConfig = api.useResolvedConfigContext();
19
- const { source: { mainEntryName } } = modernConfig;
20
17
  const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
21
18
  const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory);
22
19
  const needModernServer = useSSR || useAPI || useWebServer;
20
+ const configContext = api.useResolvedConfigContext();
23
21
  let outputDirectory = path.join(appDirectory, ".output");
24
22
  let funcsDirectory = outputDirectory;
25
23
  let staticDirectory = path.join(outputDirectory, "static");
26
- if (deployTarget === "node") {
24
+ if (deployTarget === "node" || deployTarget === "netlify") {
27
25
  await fse.remove(outputDirectory);
28
26
  await fse.copy(distDirectory, outputDirectory);
29
27
  }
30
- if (deployTarget === "netlify") {
31
- const netlifyOutput = path.join(appDirectory, ".netlify");
32
- funcsDirectory = path.join(netlifyOutput, "functions");
33
- const routes = [];
34
- if (!needModernServer) {
35
- entrypoints.forEach((entry) => {
36
- const isMain = isMainEntry(entry.entryName, mainEntryName);
37
- routes.push({
38
- src: `/${isMain ? "" : `${entry.entryName}/`}*`,
39
- dest: `/html/${entry.entryName}/index.html`,
40
- status: 200
41
- });
42
- });
43
- } else {
44
- routes.push({
45
- src: `/*`,
46
- dest: `/.netlify/functions/index`,
47
- status: 200
48
- });
49
- throw new Error("Currently on the Netlify platform, only CSR projects are supporte, Support for SSR and BFF projects will be available later");
50
- }
51
- console.log("routes", routes, needModernServer);
52
- const redirectContent = routes.map((route) => {
53
- return `${route.src} ${route.dest} ${route.status}`;
54
- }).join("\n");
55
- console.log("redirectContent", redirectContent);
56
- await fse.remove(outputDirectory);
57
- await fse.ensureDir(funcsDirectory);
58
- await fse.copy(distDirectory, funcsDirectory, {
59
- filter: (src) => {
60
- const distStaticDirectory = path.join(distDirectory, "static");
61
- return !src.includes(distStaticDirectory);
62
- }
63
- });
64
- const redirectFilePath = path.join(distDirectory, "_redirects");
65
- await fse.writeFile(redirectFilePath, redirectContent);
66
- }
67
28
  if (deployTarget === "vercel") {
68
29
  const vercelOutput = path.join(appDirectory, ".vercel");
69
30
  await fse.remove(vercelOutput);
70
31
  outputDirectory = path.join(vercelOutput, "output");
71
- const config = {
32
+ const config2 = {
72
33
  version: 3,
73
34
  routes: [
74
35
  {
@@ -85,9 +46,8 @@ var deploy_default = () => ({
85
46
  };
86
47
  if (!needModernServer) {
87
48
  entrypoints.forEach((entry) => {
88
- const isMain = isMainEntry(entry.entryName, mainEntryName);
89
- config.routes.push({
90
- src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
49
+ config2.routes.push({
50
+ src: `/${entry.entryName}(?:/.*)?`,
91
51
  headers: {
92
52
  "cache-control": "s-maxage=0"
93
53
  },
@@ -95,13 +55,13 @@ var deploy_default = () => ({
95
55
  });
96
56
  });
97
57
  } else {
98
- config.routes.push({
58
+ config2.routes.push({
99
59
  src: "/(.*)",
100
60
  dest: `/index`
101
61
  });
102
62
  }
103
63
  await fse.ensureDir(outputDirectory);
104
- await fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
64
+ await fse.writeJSON(path.join(outputDirectory, "config.json"), config2, {
105
65
  spaces: 2
106
66
  });
107
67
  staticDirectory = path.join(outputDirectory, "static/static");
@@ -128,6 +88,13 @@ var deploy_default = () => ({
128
88
  });
129
89
  }
130
90
  }
91
+ const { bff } = configContext;
92
+ const config = {
93
+ output: {
94
+ path: "."
95
+ },
96
+ bff
97
+ };
131
98
  const plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
132
99
  const serverAppContext = {
133
100
  sharedDirectory: `path.join(__dirname, "${path.relative(appDirectory, sharedDirectory)}")`,
@@ -139,28 +106,28 @@ var deploy_default = () => ({
139
106
  console.log("deployTarget111111111", deployTarget);
140
107
  switch (deployTarget) {
141
108
  case "node": {
142
- const { genNodeEntry } = await import("./platforms/node");
109
+ const { genNodeEntry } = await import("./entrys/node");
143
110
  code = genNodeEntry({
144
111
  plugins,
145
- config: modernConfig,
112
+ config,
146
113
  appContext: serverAppContext
147
114
  });
148
115
  break;
149
116
  }
150
117
  case "vercel": {
151
- const { genVercelEntry } = await import("./platforms/vercel");
152
- code = await genVercelEntry({
118
+ const { genVercelEntry } = await import("./entrys/vercel");
119
+ code = genVercelEntry({
153
120
  plugins,
154
- config: modernConfig,
121
+ config,
155
122
  appContext: serverAppContext
156
123
  });
157
124
  break;
158
125
  }
159
126
  case "netlify": {
160
- const { genNetlifyEntry } = await import("./platforms/netlify");
127
+ const { genNetlifyEntry } = await import("./entrys/netlify");
161
128
  code = genNetlifyEntry({
162
129
  plugins,
163
- config: modernConfig,
130
+ config,
164
131
  appContext: serverAppContext
165
132
  });
166
133
  break;
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { fs, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE } from "@modern-js/utils";
2
+ import { fs, ROUTE_SPEC_FILE } from "@modern-js/utils";
3
3
  const generateRoutes = async (appContext) => {
4
4
  const { serverRoutes, distDirectory } = appContext;
5
5
  const output = JSON.stringify({
@@ -11,11 +11,7 @@ const getPathWithoutExt = (filename) => {
11
11
  const extname = path.extname(filename);
12
12
  return filename.slice(0, -extname.length);
13
13
  };
14
- const isMainEntry = (entryName, mainEntryName) => {
15
- return entryName === (mainEntryName || MAIN_ENTRY_NAME);
16
- };
17
14
  export {
18
15
  generateRoutes,
19
- getPathWithoutExt,
20
- isMainEntry
16
+ getPathWithoutExt
21
17
  };
@@ -2,4 +2,4 @@ export declare function genVercelEntry({ config, plugins, appContext, }?: {
2
2
  config?: Record<string, any>;
3
3
  plugins?: string[];
4
4
  appContext?: Record<string, any>;
5
- }): Promise<string>;
5
+ }): string;
@@ -1,4 +1,4 @@
1
1
  import type { IAppContext } from '@modern-js/core';
2
- export declare const generateRoutes: (appContext: IAppContext) => Promise<void>;
3
- export declare const getPathWithoutExt: (filename: string) => string;
4
- export declare const isMainEntry: (entryName: string, mainEntryName?: string) => boolean;
2
+ declare const generateRoutes: (appContext: IAppContext) => Promise<void>;
3
+ declare const getPathWithoutExt: (filename: string) => string;
4
+ export { generateRoutes, getPathWithoutExt };