@modern-js/app-tools 2.49.3-alpha.16 → 2.49.3-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -202,7 +202,6 @@ const handleDependencies = async (appDir, serverRootDir, include) => {
202
202
  const version = Object.keys(pkg.versions)[0];
203
203
  return (0, import_utils2.writePackage)(pkg, version, serverRootDir);
204
204
  }));
205
- console.log("multiVersionPkgs111111111", multiVersionPkgs);
206
205
  for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
207
206
  const versionEntires = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
208
207
  if (p1.length === 0) {
@@ -26,6 +26,21 @@ var import_utils = require("./utils");
26
26
  var import_node = require("./platforms/node");
27
27
  var import_vercel = require("./platforms/vercel");
28
28
  var import_netlify = require("./platforms/netlify");
29
+ const deployPresets = {
30
+ node: import_node.createNodePreset,
31
+ vercel: import_vercel.createVercelPreset,
32
+ netlify: import_netlify.createNetlifyPreset
33
+ };
34
+ async function getDeployPreset(appContext, modernConfig, deployTarget) {
35
+ const { appDirectory, distDirectory } = appContext;
36
+ const { useSSR, useAPI, useWebServer } = (0, import_utils.getProjectUsage)(appDirectory, distDirectory);
37
+ const needModernServer = useSSR || useAPI || useWebServer;
38
+ const createPreset = deployPresets[deployTarget];
39
+ if (!createPreset) {
40
+ throw new Error(`Unknown deploy target: '${deployTarget}'. MODERNJS_DEPLOY should be 'node', 'vercel', or 'netlify'.`);
41
+ }
42
+ return createPreset(appContext, modernConfig, needModernServer);
43
+ }
29
44
  var deploy_default = () => ({
30
45
  name: "@modern-js/plugin-deploy",
31
46
  pre: [
@@ -37,28 +52,12 @@ var deploy_default = () => ({
37
52
  return {
38
53
  async beforeDeploy() {
39
54
  const appContext = api.useAppContext();
40
- const { appDirectory, distDirectory } = appContext;
41
55
  const modernConfig = api.useResolvedConfigContext();
42
- const { useSSR, useAPI, useWebServer } = (0, import_utils.getProjectUsage)(appDirectory, distDirectory);
43
- const needModernServer = useSSR || useAPI || useWebServer;
44
- let deployPreset;
45
- switch (deployTarget) {
46
- case "node":
47
- deployPreset = (0, import_node.createNodePreset)(appContext, modernConfig, needModernServer);
48
- break;
49
- case "vercel":
50
- deployPreset = (0, import_vercel.createVercelPreset)(appContext, modernConfig, needModernServer);
51
- break;
52
- case "netlify":
53
- deployPreset = (0, import_netlify.createNetlifyPreset)(appContext, modernConfig, needModernServer);
54
- break;
55
- default: {
56
- throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");
57
- }
58
- }
59
- await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare());
60
- await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput());
61
- await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry());
56
+ const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget);
57
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare());
58
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput());
59
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry());
60
+ (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end());
62
61
  }
63
62
  };
64
63
  }
@@ -36,86 +36,59 @@ var import_utils = require("@modern-js/utils");
36
36
  var import_routes = require("../../../utils/routes");
37
37
  var import_utils2 = require("../utils");
38
38
  var import_dependencies = require("../dependencies");
39
- const createNetlifyPreset = (appContext, config, needModernServer) => {
40
- const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
39
+ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
40
+ const { appDirectory, distDirectory, serverInternalPlugins, entrypoints } = appContext;
41
41
  const plugins = (0, import_utils.getInternalPlugins)(appDirectory, serverInternalPlugins);
42
42
  const netlifyOutput = import_node_path.default.join(appDirectory, ".netlify");
43
- const outputDirectory = import_node_path.default.join(netlifyOutput, "output");
44
- const funcsDirectory = import_node_path.default.join(outputDirectory, "functions", "index.func");
43
+ const funcsDirectory = import_node_path.default.join(netlifyOutput, "functions");
45
44
  const entryFilePath = import_node_path.default.join(funcsDirectory, "index.js");
46
45
  return {
47
46
  async prepare() {
48
47
  await import_utils.fs.remove(netlifyOutput);
49
48
  },
50
49
  async writeOutput() {
51
- const config2 = {
52
- version: 3,
53
- routes: [
54
- {
55
- src: "/static/(.*)",
56
- headers: {
57
- "cache-control": "s-maxage=31536000, immutable"
58
- },
59
- continue: true
60
- },
61
- {
62
- handle: "filesystem"
63
- }
64
- ]
65
- };
50
+ const routes = [];
51
+ const { source: { mainEntryName } } = modernConfig;
66
52
  if (!needModernServer) {
67
- const { source: { mainEntryName } } = config2;
68
53
  entrypoints.forEach((entry) => {
69
54
  const isMain = (0, import_routes.isMainEntry)(entry.entryName, mainEntryName);
70
- config2.routes.push({
71
- src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
72
- headers: {
73
- "cache-control": "s-maxage=0"
74
- },
75
- dest: `/html/${entry.entryName}/index.html`
55
+ routes.push({
56
+ src: `/${isMain ? "" : `${entry.entryName}/`}*`,
57
+ dest: `/html/${entry.entryName}/index.html`,
58
+ status: 200
76
59
  });
77
60
  });
78
61
  } else {
79
- config2.routes.push({
80
- src: "/(.*)",
81
- dest: `/index`
62
+ routes.push({
63
+ src: "/*",
64
+ dest: `/.netlify/functions/index`,
65
+ status: 200
82
66
  });
83
67
  }
84
- await import_utils.fs.ensureDir(outputDirectory);
85
- await import_utils.fs.writeJSON(import_node_path.default.join(outputDirectory, "config.json"), config2, {
86
- spaces: 2
87
- });
88
- const staticDirectory = import_node_path.default.join(outputDirectory, "static/static");
89
- await import_utils.fs.copy(import_node_path.default.join(distDirectory, "static"), staticDirectory);
90
- if (!needModernServer) {
91
- const destHtmlDirectory = import_node_path.default.join(distDirectory, "html");
92
- const outputHtmlDirectory = import_node_path.default.join(import_node_path.default.join(outputDirectory, "static"), "html");
93
- await import_utils.fs.copy(destHtmlDirectory, outputHtmlDirectory);
94
- } else {
68
+ const redirectContent = routes.map((route) => {
69
+ return `${route.src} ${route.dest} ${route.status}`;
70
+ }).join("\n");
71
+ if (needModernServer) {
95
72
  await import_utils.fs.ensureDir(funcsDirectory);
73
+ await import_utils.fs.copy(distDirectory, funcsDirectory);
96
74
  await import_utils.fs.copy(distDirectory, funcsDirectory, {
97
75
  filter: (src) => {
98
- const distStaticDirectory = import_node_path.default.join(distDirectory, "static");
76
+ const distStaticDirectory = import_node_path.default.join(distDirectory, `static`);
99
77
  return !src.includes(distStaticDirectory);
100
78
  }
101
79
  });
102
- await import_utils.fs.writeJSON(import_node_path.default.join(funcsDirectory, ".vc-config.json"), {
103
- runtime: "nodejs16.x",
104
- handler: "index.js",
105
- launcherType: "Nodejs",
106
- shouldAddHelpers: false,
107
- supportsResponseStreaming: true
108
- });
109
80
  }
81
+ const redirectFilePath = import_node_path.default.join(distDirectory, "_redirects");
82
+ await import_utils.fs.writeFile(redirectFilePath, redirectContent);
110
83
  },
111
84
  async genEntry() {
112
- var _config_bff;
85
+ var _modernConfig_bff;
113
86
  if (!needModernServer) {
114
87
  return;
115
88
  }
116
89
  const serverConfig = {
117
90
  bff: {
118
- prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
91
+ prefix: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_bff = modernConfig.bff) === null || _modernConfig_bff === void 0 ? void 0 : _modernConfig_bff.prefix
119
92
  },
120
93
  output: {
121
94
  path: "."
@@ -36,9 +36,10 @@ var import_utils = require("@modern-js/utils");
36
36
  var import_utils2 = require("../utils");
37
37
  var import_dependencies = require("../dependencies");
38
38
  const createNodePreset = (appContext, config, needModernServer) => {
39
- const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
39
+ const { appDirectory, distDirectory, serverInternalPlugins } = appContext;
40
40
  const plugins = (0, import_utils.getInternalPlugins)(appDirectory, serverInternalPlugins);
41
41
  const outputDirectory = import_node_path.default.join(appDirectory, ".output");
42
+ const staticDirectory = import_node_path.default.join(outputDirectory, "static");
42
43
  const entryFilePath = import_node_path.default.join(outputDirectory, "index.js");
43
44
  return {
44
45
  async prepare() {
@@ -76,6 +77,10 @@ const createNodePreset = (appContext, config, needModernServer) => {
76
77
  await (0, import_dependencies.handleDependencies)(appDirectory, outputDirectory, [
77
78
  "@modern-js/prod-server"
78
79
  ]);
80
+ },
81
+ async end() {
82
+ console.log("Static directory:", import_utils.chalk.blue(import_node_path.default.relative(appDirectory, staticDirectory)));
83
+ console.log(`You can preview this build by`, import_utils.chalk.blue(`node .output/index`));
79
84
  }
80
85
  };
81
86
  };
@@ -36,8 +36,8 @@ var import_utils = require("@modern-js/utils");
36
36
  var import_routes = require("../../../utils/routes");
37
37
  var import_utils2 = require("../utils");
38
38
  var import_dependencies = require("../dependencies");
39
- const createVercelPreset = (appContext, config, needModernServer) => {
40
- const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
39
+ const createVercelPreset = (appContext, modernConfig, needModernServer) => {
40
+ const { appDirectory, distDirectory, serverInternalPlugins, entrypoints } = appContext;
41
41
  const plugins = (0, import_utils.getInternalPlugins)(appDirectory, serverInternalPlugins);
42
42
  const vercelOutput = import_node_path.default.join(appDirectory, ".vercel");
43
43
  const outputDirectory = import_node_path.default.join(vercelOutput, "output");
@@ -48,7 +48,7 @@ const createVercelPreset = (appContext, config, needModernServer) => {
48
48
  await import_utils.fs.remove(vercelOutput);
49
49
  },
50
50
  async writeOutput() {
51
- const config2 = {
51
+ const config = {
52
52
  version: 3,
53
53
  routes: [
54
54
  {
@@ -64,10 +64,10 @@ const createVercelPreset = (appContext, config, needModernServer) => {
64
64
  ]
65
65
  };
66
66
  if (!needModernServer) {
67
- const { source: { mainEntryName } } = config2;
67
+ const { source: { mainEntryName } } = modernConfig;
68
68
  entrypoints.forEach((entry) => {
69
69
  const isMain = (0, import_routes.isMainEntry)(entry.entryName, mainEntryName);
70
- config2.routes.push({
70
+ config.routes.push({
71
71
  src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
72
72
  headers: {
73
73
  "cache-control": "s-maxage=0"
@@ -76,13 +76,13 @@ const createVercelPreset = (appContext, config, needModernServer) => {
76
76
  });
77
77
  });
78
78
  } else {
79
- config2.routes.push({
79
+ config.routes.push({
80
80
  src: "/(.*)",
81
81
  dest: `/index`
82
82
  });
83
83
  }
84
84
  await import_utils.fs.ensureDir(outputDirectory);
85
- await import_utils.fs.writeJSON(import_node_path.default.join(outputDirectory, "config.json"), config2, {
85
+ await import_utils.fs.writeJSON(import_node_path.default.join(outputDirectory, "config.json"), config, {
86
86
  spaces: 2
87
87
  });
88
88
  const staticDirectory = import_node_path.default.join(outputDirectory, "static/static");
@@ -109,13 +109,13 @@ const createVercelPreset = (appContext, config, needModernServer) => {
109
109
  }
110
110
  },
111
111
  async genEntry() {
112
- var _config_bff;
112
+ var _modernConfig_bff;
113
113
  if (!needModernServer) {
114
114
  return;
115
115
  }
116
116
  const serverConfig = {
117
117
  bff: {
118
- prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
118
+ prefix: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_bff = modernConfig.bff) === null || _modernConfig_bff === void 0 ? void 0 : _modernConfig_bff.prefix
119
119
  },
120
120
  output: {
121
121
  path: "."
@@ -432,7 +432,6 @@ var handleDependencies = function() {
432
432
  ];
433
433
  case 12:
434
434
  _state.sent();
435
- console.log("multiVersionPkgs111111111", multiVersionPkgs);
436
435
  _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
437
436
  _state.label = 13;
438
437
  case 13:
@@ -5,6 +5,33 @@ import { getProjectUsage } from "./utils";
5
5
  import { createNodePreset } from "./platforms/node";
6
6
  import { createVercelPreset } from "./platforms/vercel";
7
7
  import { createNetlifyPreset } from "./platforms/netlify";
8
+ var deployPresets = {
9
+ node: createNodePreset,
10
+ vercel: createVercelPreset,
11
+ netlify: createNetlifyPreset
12
+ };
13
+ function getDeployPreset(appContext, modernConfig, deployTarget) {
14
+ return _getDeployPreset.apply(this, arguments);
15
+ }
16
+ function _getDeployPreset() {
17
+ _getDeployPreset = _async_to_generator(function(appContext, modernConfig, deployTarget) {
18
+ var appDirectory, distDirectory, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, createPreset;
19
+ return _ts_generator(this, function(_state) {
20
+ appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory;
21
+ _getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
22
+ needModernServer = useSSR || useAPI || useWebServer;
23
+ createPreset = deployPresets[deployTarget];
24
+ if (!createPreset) {
25
+ throw new Error("Unknown deploy target: '".concat(deployTarget, "'. MODERNJS_DEPLOY should be 'node', 'vercel', or 'netlify'."));
26
+ }
27
+ return [
28
+ 2,
29
+ createPreset(appContext, modernConfig, needModernServer)
30
+ ];
31
+ });
32
+ });
33
+ return _getDeployPreset.apply(this, arguments);
34
+ }
8
35
  function deploy_default() {
9
36
  return {
10
37
  name: "@modern-js/plugin-deploy",
@@ -17,47 +44,78 @@ function deploy_default() {
17
44
  return {
18
45
  beforeDeploy: function beforeDeploy() {
19
46
  return _async_to_generator(function() {
20
- var appContext, appDirectory, distDirectory, modernConfig, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, deployPreset;
47
+ var appContext, modernConfig, deployPreset, _tmp, _tmp1, _tmp2, _tmp3;
21
48
  return _ts_generator(this, function(_state) {
22
49
  switch (_state.label) {
23
50
  case 0:
24
51
  appContext = api.useAppContext();
25
- appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory;
26
52
  modernConfig = api.useResolvedConfigContext();
27
- _getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
28
- needModernServer = useSSR || useAPI || useWebServer;
29
- switch (deployTarget) {
30
- case "node":
31
- deployPreset = createNodePreset(appContext, modernConfig, needModernServer);
32
- break;
33
- case "vercel":
34
- deployPreset = createVercelPreset(appContext, modernConfig, needModernServer);
35
- break;
36
- case "netlify":
37
- deployPreset = createNetlifyPreset(appContext, modernConfig, needModernServer);
38
- break;
39
- default: {
40
- throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");
41
- }
42
- }
43
53
  return [
44
54
  4,
45
- deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare()
55
+ getDeployPreset(appContext, modernConfig, deployTarget)
46
56
  ];
47
57
  case 1:
48
- _state.sent();
58
+ deployPreset = _state.sent();
59
+ _tmp = deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare;
60
+ if (!_tmp)
61
+ return [
62
+ 3,
63
+ 3
64
+ ];
49
65
  return [
50
66
  4,
51
- deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput()
67
+ deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare()
52
68
  ];
53
69
  case 2:
54
- _state.sent();
70
+ _tmp = _state.sent();
71
+ _state.label = 3;
72
+ case 3:
73
+ _tmp;
74
+ _tmp1 = deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput;
75
+ if (!_tmp1)
76
+ return [
77
+ 3,
78
+ 5
79
+ ];
80
+ return [
81
+ 4,
82
+ deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput()
83
+ ];
84
+ case 4:
85
+ _tmp1 = _state.sent();
86
+ _state.label = 5;
87
+ case 5:
88
+ _tmp1;
89
+ _tmp2 = deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry;
90
+ if (!_tmp2)
91
+ return [
92
+ 3,
93
+ 7
94
+ ];
55
95
  return [
56
96
  4,
57
97
  deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry()
58
98
  ];
59
- case 3:
60
- _state.sent();
99
+ case 6:
100
+ _tmp2 = _state.sent();
101
+ _state.label = 7;
102
+ case 7:
103
+ _tmp2;
104
+ _tmp3 = deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end;
105
+ if (!_tmp3)
106
+ return [
107
+ 3,
108
+ 9
109
+ ];
110
+ return [
111
+ 4,
112
+ deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end()
113
+ ];
114
+ case 8:
115
+ _tmp3 = _state.sent();
116
+ _state.label = 9;
117
+ case 9:
118
+ _tmp3;
61
119
  return [
62
120
  2
63
121
  ];
@@ -5,12 +5,11 @@ import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins }
5
5
  import { isMainEntry } from "../../../utils/routes";
6
6
  import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
7
7
  import { handleDependencies } from "../dependencies";
8
- var createNetlifyPreset = function(appContext, config, needModernServer) {
9
- var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
8
+ var createNetlifyPreset = function(appContext, modernConfig, needModernServer) {
9
+ var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, entrypoints = appContext.entrypoints;
10
10
  var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
11
11
  var netlifyOutput = path.join(appDirectory, ".netlify");
12
- var outputDirectory = path.join(netlifyOutput, "output");
13
- var funcsDirectory = path.join(outputDirectory, "functions", "index.func");
12
+ var funcsDirectory = path.join(netlifyOutput, "functions");
14
13
  var entryFilePath = path.join(funcsDirectory, "index.js");
15
14
  return {
16
15
  prepare: function prepare() {
@@ -33,87 +32,47 @@ var createNetlifyPreset = function(appContext, config, needModernServer) {
33
32
  },
34
33
  writeOutput: function writeOutput() {
35
34
  return _async_to_generator(function() {
36
- var config2, mainEntryName, staticDirectory, destHtmlDirectory, outputHtmlDirectory;
35
+ var routes, mainEntryName, redirectContent, redirectFilePath;
37
36
  return _ts_generator(this, function(_state) {
38
37
  switch (_state.label) {
39
38
  case 0:
40
- config2 = {
41
- version: 3,
42
- routes: [
43
- {
44
- src: "/static/(.*)",
45
- headers: {
46
- "cache-control": "s-maxage=31536000, immutable"
47
- },
48
- continue: true
49
- },
50
- {
51
- handle: "filesystem"
52
- }
53
- ]
54
- };
39
+ routes = [];
40
+ mainEntryName = modernConfig.source.mainEntryName;
55
41
  if (!needModernServer) {
56
- mainEntryName = config2.source.mainEntryName;
57
42
  entrypoints.forEach(function(entry) {
58
43
  var isMain = isMainEntry(entry.entryName, mainEntryName);
59
- config2.routes.push({
60
- src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
61
- headers: {
62
- "cache-control": "s-maxage=0"
63
- },
64
- dest: "/html/".concat(entry.entryName, "/index.html")
44
+ routes.push({
45
+ src: "/".concat(isMain ? "" : "".concat(entry.entryName, "/"), "*"),
46
+ dest: "/html/".concat(entry.entryName, "/index.html"),
47
+ status: 200
65
48
  });
66
49
  });
67
50
  } else {
68
- config2.routes.push({
69
- src: "/(.*)",
70
- dest: "/index"
51
+ routes.push({
52
+ src: "/*",
53
+ dest: "/.netlify/functions/index",
54
+ status: 200
71
55
  });
72
56
  }
73
- return [
74
- 4,
75
- fse.ensureDir(outputDirectory)
76
- ];
77
- case 1:
78
- _state.sent();
79
- return [
80
- 4,
81
- fse.writeJSON(path.join(outputDirectory, "config.json"), config2, {
82
- spaces: 2
83
- })
84
- ];
85
- case 2:
86
- _state.sent();
87
- staticDirectory = path.join(outputDirectory, "static/static");
88
- return [
89
- 4,
90
- fse.copy(path.join(distDirectory, "static"), staticDirectory)
91
- ];
92
- case 3:
93
- _state.sent();
94
- if (!!needModernServer)
57
+ redirectContent = routes.map(function(route) {
58
+ return "".concat(route.src, " ").concat(route.dest, " ").concat(route.status);
59
+ }).join("\n");
60
+ if (!needModernServer)
95
61
  return [
96
62
  3,
97
- 5
63
+ 4
98
64
  ];
99
- destHtmlDirectory = path.join(distDirectory, "html");
100
- outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
101
65
  return [
102
66
  4,
103
- fse.copy(destHtmlDirectory, outputHtmlDirectory)
67
+ fse.ensureDir(funcsDirectory)
104
68
  ];
105
- case 4:
69
+ case 1:
106
70
  _state.sent();
107
- return [
108
- 3,
109
- 9
110
- ];
111
- case 5:
112
71
  return [
113
72
  4,
114
- fse.ensureDir(funcsDirectory)
73
+ fse.copy(distDirectory, funcsDirectory)
115
74
  ];
116
- case 6:
75
+ case 2:
117
76
  _state.sent();
118
77
  return [
119
78
  4,
@@ -124,22 +83,17 @@ var createNetlifyPreset = function(appContext, config, needModernServer) {
124
83
  }
125
84
  })
126
85
  ];
127
- case 7:
86
+ case 3:
128
87
  _state.sent();
88
+ _state.label = 4;
89
+ case 4:
90
+ redirectFilePath = path.join(distDirectory, "_redirects");
129
91
  return [
130
92
  4,
131
- fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
132
- runtime: "nodejs16.x",
133
- handler: "index.js",
134
- launcherType: "Nodejs",
135
- shouldAddHelpers: false,
136
- supportsResponseStreaming: true
137
- })
93
+ fse.writeFile(redirectFilePath, redirectContent)
138
94
  ];
139
- case 8:
95
+ case 5:
140
96
  _state.sent();
141
- _state.label = 9;
142
- case 9:
143
97
  return [
144
98
  2
145
99
  ];
@@ -149,7 +103,7 @@ var createNetlifyPreset = function(appContext, config, needModernServer) {
149
103
  },
150
104
  genEntry: function genEntry() {
151
105
  return _async_to_generator(function() {
152
- var _config_bff, serverConfig, pluginImportCode, dynamicProdOptions, entryCode, serverAppContext;
106
+ var _modernConfig_bff, serverConfig, pluginImportCode, dynamicProdOptions, entryCode, serverAppContext;
153
107
  return _ts_generator(this, function(_state) {
154
108
  switch (_state.label) {
155
109
  case 0:
@@ -160,7 +114,7 @@ var createNetlifyPreset = function(appContext, config, needModernServer) {
160
114
  }
161
115
  serverConfig = {
162
116
  bff: {
163
- prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
117
+ prefix: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_bff = modernConfig.bff) === null || _modernConfig_bff === void 0 ? void 0 : _modernConfig_bff.prefix
164
118
  },
165
119
  output: {
166
120
  path: "."
@@ -1,13 +1,14 @@
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 "node:path";
4
- import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
4
+ import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins, chalk } from "@modern-js/utils";
5
5
  import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
6
6
  import { handleDependencies } from "../dependencies";
7
7
  var createNodePreset = function(appContext, config, needModernServer) {
8
- var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
8
+ var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins;
9
9
  var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
10
10
  var outputDirectory = path.join(appDirectory, ".output");
11
+ var staticDirectory = path.join(outputDirectory, "static");
11
12
  var entryFilePath = path.join(outputDirectory, "index.js");
12
13
  return {
13
14
  prepare: function prepare() {
@@ -102,6 +103,17 @@ var createNodePreset = function(appContext, config, needModernServer) {
102
103
  }
103
104
  });
104
105
  })();
106
+ },
107
+ end: function end() {
108
+ return _async_to_generator(function() {
109
+ return _ts_generator(this, function(_state) {
110
+ console.log("Static directory:", chalk.blue(path.relative(appDirectory, staticDirectory)));
111
+ console.log("You can preview this build by", chalk.blue("node .output/index"));
112
+ return [
113
+ 2
114
+ ];
115
+ });
116
+ })();
105
117
  }
106
118
  };
107
119
  };