@modern-js/app-tools 2.49.3-alpha.16 → 2.49.3-alpha.17
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/plugins/deploy/dependencies.js +0 -1
- package/dist/cjs/plugins/deploy/index.js +20 -21
- package/dist/cjs/plugins/deploy/platforms/netlify.js +23 -50
- package/dist/cjs/plugins/deploy/platforms/node.js +6 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +9 -9
- package/dist/esm/plugins/deploy/dependencies.js +0 -1
- package/dist/esm/plugins/deploy/index.js +82 -24
- package/dist/esm/plugins/deploy/platforms/netlify.js +31 -77
- package/dist/esm/plugins/deploy/platforms/node.js +14 -2
- package/dist/esm/plugins/deploy/platforms/vercel.js +10 -10
- package/dist/esm-node/plugins/deploy/dependencies.js +0 -1
- package/dist/esm-node/plugins/deploy/index.js +20 -21
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +23 -50
- package/dist/esm-node/plugins/deploy/platforms/node.js +7 -2
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +9 -9
- package/dist/types/plugins/deploy/platforms/platform.d.ts +4 -3
- package/package.json +7 -7
- package/dist/cjs/plugins/deploy/index copy.js +0 -216
- package/dist/esm/plugins/deploy/index copy.js +0 -367
- package/dist/esm-node/plugins/deploy/index copy.js +0 -186
- package/dist/types/plugins/deploy/index copy.d.ts +0 -4
@@ -1,367 +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 as fse, getInternalPlugins } from "@modern-js/utils";
|
5
|
-
import { provider } from "std-env";
|
6
|
-
import { isMainEntry } from "../../utils/routes";
|
7
|
-
import { getProjectUsage } from "./utils";
|
8
|
-
import { handleDependencies } from "./dependencies";
|
9
|
-
function index_copy_default() {
|
10
|
-
return {
|
11
|
-
name: "@modern-js/plugin-deploy",
|
12
|
-
pre: [
|
13
|
-
"@modern-js/plugin-bff",
|
14
|
-
"@modern-js/plugin-server"
|
15
|
-
],
|
16
|
-
setup: function(api) {
|
17
|
-
var deployTarget = process.env.MODERNJS_DEPLOY || provider || "node";
|
18
|
-
return {
|
19
|
-
beforeDeploy: function beforeDeploy() {
|
20
|
-
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;
|
22
|
-
return _ts_generator(this, function(_state) {
|
23
|
-
switch (_state.label) {
|
24
|
-
case 0:
|
25
|
-
appContext = api.useAppContext();
|
26
|
-
modernConfig = api.useResolvedConfigContext();
|
27
|
-
mainEntryName = modernConfig.source.mainEntryName;
|
28
|
-
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
|
-
_getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
|
30
|
-
needModernServer = useSSR || useAPI || useWebServer;
|
31
|
-
outputDirectory = path.join(appDirectory, ".output");
|
32
|
-
funcsDirectory = outputDirectory;
|
33
|
-
staticDirectory = path.join(outputDirectory, "static");
|
34
|
-
if (!(deployTarget === "node"))
|
35
|
-
return [
|
36
|
-
3,
|
37
|
-
3
|
38
|
-
];
|
39
|
-
return [
|
40
|
-
4,
|
41
|
-
fse.remove(outputDirectory)
|
42
|
-
];
|
43
|
-
case 1:
|
44
|
-
_state.sent();
|
45
|
-
return [
|
46
|
-
4,
|
47
|
-
fse.copy(distDirectory, outputDirectory)
|
48
|
-
];
|
49
|
-
case 2:
|
50
|
-
_state.sent();
|
51
|
-
_state.label = 3;
|
52
|
-
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 supported, 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
|
-
if (!(deployTarget === "vercel"))
|
116
|
-
return [
|
117
|
-
3,
|
118
|
-
18
|
119
|
-
];
|
120
|
-
vercelOutput = path.join(appDirectory, ".vercel");
|
121
|
-
return [
|
122
|
-
4,
|
123
|
-
fse.remove(vercelOutput)
|
124
|
-
];
|
125
|
-
case 9:
|
126
|
-
_state.sent();
|
127
|
-
outputDirectory = path.join(vercelOutput, "output");
|
128
|
-
config = {
|
129
|
-
version: 3,
|
130
|
-
routes: [
|
131
|
-
{
|
132
|
-
src: "/static/(.*)",
|
133
|
-
headers: {
|
134
|
-
"cache-control": "s-maxage=31536000, immutable"
|
135
|
-
},
|
136
|
-
continue: true
|
137
|
-
},
|
138
|
-
{
|
139
|
-
handle: "filesystem"
|
140
|
-
}
|
141
|
-
]
|
142
|
-
};
|
143
|
-
if (!needModernServer) {
|
144
|
-
entrypoints.forEach(function(entry) {
|
145
|
-
var isMain = isMainEntry(entry.entryName, mainEntryName);
|
146
|
-
config.routes.push({
|
147
|
-
src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
|
148
|
-
headers: {
|
149
|
-
"cache-control": "s-maxage=0"
|
150
|
-
},
|
151
|
-
dest: "/html/".concat(entry.entryName, "/index.html")
|
152
|
-
});
|
153
|
-
});
|
154
|
-
} else {
|
155
|
-
config.routes.push({
|
156
|
-
src: "/(.*)",
|
157
|
-
dest: "/index"
|
158
|
-
});
|
159
|
-
}
|
160
|
-
return [
|
161
|
-
4,
|
162
|
-
fse.ensureDir(outputDirectory)
|
163
|
-
];
|
164
|
-
case 10:
|
165
|
-
_state.sent();
|
166
|
-
return [
|
167
|
-
4,
|
168
|
-
fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
|
169
|
-
spaces: 2
|
170
|
-
})
|
171
|
-
];
|
172
|
-
case 11:
|
173
|
-
_state.sent();
|
174
|
-
staticDirectory = path.join(outputDirectory, "static/static");
|
175
|
-
return [
|
176
|
-
4,
|
177
|
-
fse.copy(path.join(distDirectory, "static"), staticDirectory)
|
178
|
-
];
|
179
|
-
case 12:
|
180
|
-
_state.sent();
|
181
|
-
if (!!needModernServer)
|
182
|
-
return [
|
183
|
-
3,
|
184
|
-
14
|
185
|
-
];
|
186
|
-
destHtmlDirectory = path.join(distDirectory, "html");
|
187
|
-
outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
|
188
|
-
return [
|
189
|
-
4,
|
190
|
-
fse.copy(destHtmlDirectory, outputHtmlDirectory)
|
191
|
-
];
|
192
|
-
case 13:
|
193
|
-
_state.sent();
|
194
|
-
return [
|
195
|
-
3,
|
196
|
-
18
|
197
|
-
];
|
198
|
-
case 14:
|
199
|
-
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
200
|
-
return [
|
201
|
-
4,
|
202
|
-
fse.ensureDir(funcsDirectory)
|
203
|
-
];
|
204
|
-
case 15:
|
205
|
-
_state.sent();
|
206
|
-
return [
|
207
|
-
4,
|
208
|
-
fse.copy(distDirectory, funcsDirectory, {
|
209
|
-
filter: function(src) {
|
210
|
-
var distStaticDirectory = path.join(distDirectory, "static");
|
211
|
-
return !src.includes(distStaticDirectory);
|
212
|
-
}
|
213
|
-
})
|
214
|
-
];
|
215
|
-
case 16:
|
216
|
-
_state.sent();
|
217
|
-
return [
|
218
|
-
4,
|
219
|
-
fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
|
220
|
-
runtime: "nodejs16.x",
|
221
|
-
handler: "index.js",
|
222
|
-
launcherType: "Nodejs",
|
223
|
-
shouldAddHelpers: false,
|
224
|
-
supportsResponseStreaming: true
|
225
|
-
})
|
226
|
-
];
|
227
|
-
case 17:
|
228
|
-
_state.sent();
|
229
|
-
_state.label = 18;
|
230
|
-
case 18:
|
231
|
-
plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
232
|
-
serverAppContext = {
|
233
|
-
sharedDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, sharedDirectory), '")'),
|
234
|
-
apiDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, apiDirectory), '")'),
|
235
|
-
lambdaDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, lambdaDirectory), '")'),
|
236
|
-
metaName
|
237
|
-
};
|
238
|
-
console.log("serverAppContext", serverAppContext);
|
239
|
-
code = "";
|
240
|
-
console.log("deployTarget111111111", deployTarget);
|
241
|
-
switch (deployTarget) {
|
242
|
-
case "node":
|
243
|
-
return [
|
244
|
-
3,
|
245
|
-
19
|
246
|
-
];
|
247
|
-
case "vercel":
|
248
|
-
return [
|
249
|
-
3,
|
250
|
-
22
|
251
|
-
];
|
252
|
-
case "netlify":
|
253
|
-
return [
|
254
|
-
3,
|
255
|
-
25
|
256
|
-
];
|
257
|
-
}
|
258
|
-
return [
|
259
|
-
3,
|
260
|
-
28
|
261
|
-
];
|
262
|
-
case 19:
|
263
|
-
return [
|
264
|
-
4,
|
265
|
-
import("./platforms/node")
|
266
|
-
];
|
267
|
-
case 20:
|
268
|
-
genNodeEntry = _state.sent().genNodeEntry;
|
269
|
-
return [
|
270
|
-
4,
|
271
|
-
genNodeEntry({
|
272
|
-
plugins,
|
273
|
-
config: modernConfig,
|
274
|
-
appContext: serverAppContext
|
275
|
-
})
|
276
|
-
];
|
277
|
-
case 21:
|
278
|
-
code = _state.sent();
|
279
|
-
return [
|
280
|
-
3,
|
281
|
-
29
|
282
|
-
];
|
283
|
-
case 22:
|
284
|
-
return [
|
285
|
-
4,
|
286
|
-
import("./platforms/vercel")
|
287
|
-
];
|
288
|
-
case 23:
|
289
|
-
genVercelEntry = _state.sent().genVercelEntry;
|
290
|
-
return [
|
291
|
-
4,
|
292
|
-
genVercelEntry({
|
293
|
-
plugins,
|
294
|
-
config: modernConfig,
|
295
|
-
appContext: serverAppContext
|
296
|
-
})
|
297
|
-
];
|
298
|
-
case 24:
|
299
|
-
code = _state.sent();
|
300
|
-
return [
|
301
|
-
3,
|
302
|
-
29
|
303
|
-
];
|
304
|
-
case 25:
|
305
|
-
return [
|
306
|
-
4,
|
307
|
-
import("./platforms/netlify")
|
308
|
-
];
|
309
|
-
case 26:
|
310
|
-
genNetlifyEntry = _state.sent().genNetlifyEntry;
|
311
|
-
return [
|
312
|
-
4,
|
313
|
-
genNetlifyEntry({
|
314
|
-
plugins,
|
315
|
-
config: modernConfig,
|
316
|
-
appContext: serverAppContext
|
317
|
-
})
|
318
|
-
];
|
319
|
-
case 27:
|
320
|
-
code = _state.sent();
|
321
|
-
return [
|
322
|
-
3,
|
323
|
-
29
|
324
|
-
];
|
325
|
-
case 28:
|
326
|
-
{
|
327
|
-
code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
|
328
|
-
}
|
329
|
-
_state.label = 29;
|
330
|
-
case 29:
|
331
|
-
entryFilePath = path.join(funcsDirectory, "index.js");
|
332
|
-
if (!needModernServer)
|
333
|
-
return [
|
334
|
-
3,
|
335
|
-
32
|
336
|
-
];
|
337
|
-
return [
|
338
|
-
4,
|
339
|
-
fse.writeFile(entryFilePath, code)
|
340
|
-
];
|
341
|
-
case 30:
|
342
|
-
_state.sent();
|
343
|
-
return [
|
344
|
-
4,
|
345
|
-
handleDependencies(appDirectory, funcsDirectory, [
|
346
|
-
"@modern-js/prod-server"
|
347
|
-
])
|
348
|
-
];
|
349
|
-
case 31:
|
350
|
-
_state.sent();
|
351
|
-
_state.label = 32;
|
352
|
-
case 32:
|
353
|
-
return [
|
354
|
-
2
|
355
|
-
];
|
356
|
-
}
|
357
|
-
});
|
358
|
-
})();
|
359
|
-
}
|
360
|
-
};
|
361
|
-
}
|
362
|
-
};
|
363
|
-
}
|
364
|
-
;
|
365
|
-
export {
|
366
|
-
index_copy_default as default
|
367
|
-
};
|
@@ -1,186 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { fs as fse, getInternalPlugins } from "@modern-js/utils";
|
3
|
-
import { provider } from "std-env";
|
4
|
-
import { isMainEntry } from "../../utils/routes";
|
5
|
-
import { getProjectUsage } from "./utils";
|
6
|
-
import { handleDependencies } from "./dependencies";
|
7
|
-
var index_copy_default = () => ({
|
8
|
-
name: "@modern-js/plugin-deploy",
|
9
|
-
pre: [
|
10
|
-
"@modern-js/plugin-bff",
|
11
|
-
"@modern-js/plugin-server"
|
12
|
-
],
|
13
|
-
setup: (api) => {
|
14
|
-
const deployTarget = process.env.MODERNJS_DEPLOY || provider || "node";
|
15
|
-
return {
|
16
|
-
async beforeDeploy() {
|
17
|
-
const appContext = api.useAppContext();
|
18
|
-
const modernConfig = api.useResolvedConfigContext();
|
19
|
-
const { source: { mainEntryName } } = modernConfig;
|
20
|
-
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
|
21
|
-
const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory);
|
22
|
-
const needModernServer = useSSR || useAPI || useWebServer;
|
23
|
-
let outputDirectory = path.join(appDirectory, ".output");
|
24
|
-
let funcsDirectory = outputDirectory;
|
25
|
-
let staticDirectory = path.join(outputDirectory, "static");
|
26
|
-
if (deployTarget === "node") {
|
27
|
-
await fse.remove(outputDirectory);
|
28
|
-
await fse.copy(distDirectory, outputDirectory);
|
29
|
-
}
|
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 supported, 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
|
-
if (deployTarget === "vercel") {
|
68
|
-
const vercelOutput = path.join(appDirectory, ".vercel");
|
69
|
-
await fse.remove(vercelOutput);
|
70
|
-
outputDirectory = path.join(vercelOutput, "output");
|
71
|
-
const config = {
|
72
|
-
version: 3,
|
73
|
-
routes: [
|
74
|
-
{
|
75
|
-
src: "/static/(.*)",
|
76
|
-
headers: {
|
77
|
-
"cache-control": "s-maxage=31536000, immutable"
|
78
|
-
},
|
79
|
-
continue: true
|
80
|
-
},
|
81
|
-
{
|
82
|
-
handle: "filesystem"
|
83
|
-
}
|
84
|
-
]
|
85
|
-
};
|
86
|
-
if (!needModernServer) {
|
87
|
-
entrypoints.forEach((entry) => {
|
88
|
-
const isMain = isMainEntry(entry.entryName, mainEntryName);
|
89
|
-
config.routes.push({
|
90
|
-
src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
|
91
|
-
headers: {
|
92
|
-
"cache-control": "s-maxage=0"
|
93
|
-
},
|
94
|
-
dest: `/html/${entry.entryName}/index.html`
|
95
|
-
});
|
96
|
-
});
|
97
|
-
} else {
|
98
|
-
config.routes.push({
|
99
|
-
src: "/(.*)",
|
100
|
-
dest: `/index`
|
101
|
-
});
|
102
|
-
}
|
103
|
-
await fse.ensureDir(outputDirectory);
|
104
|
-
await fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
|
105
|
-
spaces: 2
|
106
|
-
});
|
107
|
-
staticDirectory = path.join(outputDirectory, "static/static");
|
108
|
-
await fse.copy(path.join(distDirectory, "static"), staticDirectory);
|
109
|
-
if (!needModernServer) {
|
110
|
-
const destHtmlDirectory = path.join(distDirectory, "html");
|
111
|
-
const outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
|
112
|
-
await fse.copy(destHtmlDirectory, outputHtmlDirectory);
|
113
|
-
} else {
|
114
|
-
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
115
|
-
await fse.ensureDir(funcsDirectory);
|
116
|
-
await fse.copy(distDirectory, funcsDirectory, {
|
117
|
-
filter: (src) => {
|
118
|
-
const distStaticDirectory = path.join(distDirectory, "static");
|
119
|
-
return !src.includes(distStaticDirectory);
|
120
|
-
}
|
121
|
-
});
|
122
|
-
await fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
|
123
|
-
runtime: "nodejs16.x",
|
124
|
-
handler: "index.js",
|
125
|
-
launcherType: "Nodejs",
|
126
|
-
shouldAddHelpers: false,
|
127
|
-
supportsResponseStreaming: true
|
128
|
-
});
|
129
|
-
}
|
130
|
-
}
|
131
|
-
const plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
132
|
-
const serverAppContext = {
|
133
|
-
sharedDirectory: `path.join(__dirname, "${path.relative(appDirectory, sharedDirectory)}")`,
|
134
|
-
apiDirectory: `path.join(__dirname, "${path.relative(appDirectory, apiDirectory)}")`,
|
135
|
-
lambdaDirectory: `path.join(__dirname, "${path.relative(appDirectory, lambdaDirectory)}")`,
|
136
|
-
metaName
|
137
|
-
};
|
138
|
-
console.log("serverAppContext", serverAppContext);
|
139
|
-
let code = ``;
|
140
|
-
console.log("deployTarget111111111", deployTarget);
|
141
|
-
switch (deployTarget) {
|
142
|
-
case "node": {
|
143
|
-
const { genNodeEntry } = await import("./platforms/node");
|
144
|
-
code = await genNodeEntry({
|
145
|
-
plugins,
|
146
|
-
config: modernConfig,
|
147
|
-
appContext: serverAppContext
|
148
|
-
});
|
149
|
-
break;
|
150
|
-
}
|
151
|
-
case "vercel": {
|
152
|
-
const { genVercelEntry } = await import("./platforms/vercel");
|
153
|
-
code = await genVercelEntry({
|
154
|
-
plugins,
|
155
|
-
config: modernConfig,
|
156
|
-
appContext: serverAppContext
|
157
|
-
});
|
158
|
-
break;
|
159
|
-
}
|
160
|
-
case "netlify": {
|
161
|
-
const { genNetlifyEntry } = await import("./platforms/netlify");
|
162
|
-
code = await genNetlifyEntry({
|
163
|
-
plugins,
|
164
|
-
config: modernConfig,
|
165
|
-
appContext: serverAppContext
|
166
|
-
});
|
167
|
-
break;
|
168
|
-
}
|
169
|
-
default: {
|
170
|
-
code = `throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");`;
|
171
|
-
}
|
172
|
-
}
|
173
|
-
const entryFilePath = path.join(funcsDirectory, "index.js");
|
174
|
-
if (needModernServer) {
|
175
|
-
await fse.writeFile(entryFilePath, code);
|
176
|
-
await handleDependencies(appDirectory, funcsDirectory, [
|
177
|
-
"@modern-js/prod-server"
|
178
|
-
]);
|
179
|
-
}
|
180
|
-
}
|
181
|
-
};
|
182
|
-
}
|
183
|
-
});
|
184
|
-
export {
|
185
|
-
index_copy_default as default
|
186
|
-
};
|