@modern-js/app-tools 2.49.3-alpha.11 → 2.49.3-alpha.13
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.
- package/dist/cjs/plugins/deploy/index.js +4 -9
- package/dist/cjs/plugins/deploy/platforms/node.js +21 -50
- package/dist/cjs/plugins/deploy/platforms/nodeEntry.js +6 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +3 -13
- package/dist/cjs/plugins/deploy/platforms/vercelEntry.js +5 -0
- package/dist/esm/plugins/deploy/index.js +42 -37
- package/dist/esm/plugins/deploy/platforms/node.js +43 -34
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +7 -2
- package/dist/esm/plugins/deploy/platforms/vercel.js +6 -17
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +6 -1
- package/dist/esm-node/plugins/deploy/index.js +4 -9
- package/dist/esm-node/plugins/deploy/platforms/node.js +13 -52
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +6 -1
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +3 -13
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +5 -0
- package/dist/types/plugins/deploy/platforms/node.d.ts +7 -4
- package/dist/types/plugins/deploy/platforms/platform.d.ts +5 -1
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +6 -3
- package/package.json +9 -9
|
@@ -168,12 +168,13 @@ var deploy_default = () => ({
|
|
|
168
168
|
lambdaDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, lambdaDirectory)}")`,
|
|
169
169
|
metaName
|
|
170
170
|
};
|
|
171
|
+
console.log("serverAppContext", serverAppContext);
|
|
171
172
|
let code = ``;
|
|
172
173
|
console.log("deployTarget111111111", deployTarget);
|
|
173
174
|
switch (deployTarget) {
|
|
174
175
|
case "node": {
|
|
175
176
|
const { genNodeEntry } = await Promise.resolve().then(() => __toESM(require("./platforms/node")));
|
|
176
|
-
code = genNodeEntry({
|
|
177
|
+
code = await genNodeEntry({
|
|
177
178
|
plugins,
|
|
178
179
|
config: modernConfig,
|
|
179
180
|
appContext: serverAppContext
|
|
@@ -182,22 +183,16 @@ var deploy_default = () => ({
|
|
|
182
183
|
}
|
|
183
184
|
case "vercel": {
|
|
184
185
|
const { genVercelEntry } = await Promise.resolve().then(() => __toESM(require("./platforms/vercel")));
|
|
185
|
-
const serverAppContext2 = {
|
|
186
|
-
sharedDirectory: import_path.default.join(__dirname, import_path.default.relative(appDirectory, sharedDirectory)),
|
|
187
|
-
apiDirectory: import_path.default.join(__dirname, import_path.default.relative(appDirectory, apiDirectory)),
|
|
188
|
-
lambdaDirectory: import_path.default.join(__dirname, import_path.default.relative(appDirectory, lambdaDirectory)),
|
|
189
|
-
metaName
|
|
190
|
-
};
|
|
191
186
|
code = await genVercelEntry({
|
|
192
187
|
plugins,
|
|
193
188
|
config: modernConfig,
|
|
194
|
-
appContext:
|
|
189
|
+
appContext: serverAppContext
|
|
195
190
|
});
|
|
196
191
|
break;
|
|
197
192
|
}
|
|
198
193
|
case "netlify": {
|
|
199
194
|
const { genNetlifyEntry } = await Promise.resolve().then(() => __toESM(require("./platforms/netlify")));
|
|
200
|
-
code = genNetlifyEntry({
|
|
195
|
+
code = await genNetlifyEntry({
|
|
201
196
|
plugins,
|
|
202
197
|
config: modernConfig,
|
|
203
198
|
appContext: serverAppContext
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,15 +17,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var node_exports = {};
|
|
20
30
|
__export(node_exports, {
|
|
21
31
|
genNodeEntry: () => genNodeEntry
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(node_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"));
|
|
24
35
|
var import_utils = require("@modern-js/utils");
|
|
25
36
|
var import_utils2 = require("../utils");
|
|
26
|
-
function genNodeEntry({ config, plugins, appContext }
|
|
37
|
+
async function genNodeEntry({ config, plugins, appContext }) {
|
|
27
38
|
const defaultConfig = {
|
|
28
39
|
server: {
|
|
29
40
|
port: 8080
|
|
@@ -32,55 +43,15 @@ function genNodeEntry({ config, plugins, appContext } = {}) {
|
|
|
32
43
|
path: "."
|
|
33
44
|
}
|
|
34
45
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function main() {
|
|
47
|
-
try {
|
|
48
|
-
let routes = [];
|
|
49
|
-
const routeFilepath = path.join(__dirname, "${import_utils.ROUTE_SPEC_FILE}");
|
|
50
|
-
try {
|
|
51
|
-
await fs.access(routeFilepath);
|
|
52
|
-
const content = await fs.readFile(routeFilepath, "utf-8");
|
|
53
|
-
const routeSpec = JSON.parse(content);
|
|
54
|
-
routes = routeSpec.routes;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.warn('route.json not found, continuing with empty routes.');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const prodServerOptions = {
|
|
60
|
-
pwd: __dirname,
|
|
61
|
-
routes,
|
|
62
|
-
config: ${JSON.stringify(config || defaultConfig)},
|
|
63
|
-
serverConfigFile: '${import_utils.DEFAULT_SERVER_CONFIG}',
|
|
64
|
-
plugins: ${(0, import_utils2.getPluginsCode)(plugins || [])},
|
|
65
|
-
appContext: ${appContext ? (0, import_utils2.severAppContextTemplate)(appContext) : "undefined"},
|
|
66
|
-
disableCustomHook: true
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const app = await createProdServer(prodServerOptions)
|
|
70
|
-
|
|
71
|
-
const port = process.env.PORT || 3000;
|
|
72
|
-
|
|
73
|
-
app.listen(port, () => {
|
|
74
|
-
console.log('\\x1b[32mServer is listening on port', port, '\\x1b[0m');
|
|
75
|
-
});
|
|
76
|
-
} catch(error) {
|
|
77
|
-
console.error(error);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
main();
|
|
83
|
-
`;
|
|
46
|
+
const pluginImportCode = (0, import_utils2.genPluginImportsCode)(plugins || []);
|
|
47
|
+
const dynamicProdOptions = {
|
|
48
|
+
config: config || defaultConfig,
|
|
49
|
+
serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG,
|
|
50
|
+
plugins
|
|
51
|
+
};
|
|
52
|
+
let entryCode = (await import_utils.fs.readFile(import_node_path.default.join(__dirname, "./nodeEntry.js"))).toString();
|
|
53
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
|
|
54
|
+
return entryCode;
|
|
84
55
|
}
|
|
85
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
57
|
0 && (module.exports = {
|
|
@@ -25,12 +25,17 @@ async function main() {
|
|
|
25
25
|
pwd: __dirname,
|
|
26
26
|
routes,
|
|
27
27
|
disableCustomHook: true,
|
|
28
|
+
appContext: {
|
|
29
|
+
sharedDirectory: p_sharedDirectory,
|
|
30
|
+
apiDirectory: p_apiDirectory,
|
|
31
|
+
lambdaDirectory: p_lambdaDirectory
|
|
32
|
+
},
|
|
28
33
|
...dynamicProdOptions
|
|
29
34
|
};
|
|
30
35
|
const app = await createProdServer(prodServerOptions);
|
|
31
36
|
const port = process.env.PORT || 8080;
|
|
32
37
|
app.listen(port, () => {
|
|
33
|
-
console.log("
|
|
38
|
+
console.log("\x1B[32mServer is listening on port", port, "\x1B[0m");
|
|
34
39
|
});
|
|
35
40
|
}
|
|
36
41
|
main();
|
|
@@ -34,30 +34,20 @@ module.exports = __toCommonJS(vercel_exports);
|
|
|
34
34
|
var import_node_path = __toESM(require("node:path"));
|
|
35
35
|
var import_utils = require("@modern-js/utils");
|
|
36
36
|
var import_utils2 = require("../utils");
|
|
37
|
-
async function genVercelEntry({ config, plugins, appContext }
|
|
37
|
+
async function genVercelEntry({ config, plugins, appContext }) {
|
|
38
38
|
const defaultConfig = {
|
|
39
39
|
output: {
|
|
40
40
|
path: "."
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
console.log("appContext.sharedDirectory", appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory);
|
|
44
43
|
const pluginImportCode = (0, import_utils2.genPluginImportsCode)(plugins || []);
|
|
45
44
|
const dynamicProdOptions = {
|
|
46
45
|
config: config || defaultConfig,
|
|
47
46
|
serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG,
|
|
48
|
-
plugins
|
|
49
|
-
appContext: appContext ? {
|
|
50
|
-
sharedDirectory: appContext.sharedDirectory,
|
|
51
|
-
apiDirectory: appContext.apiDirectory,
|
|
52
|
-
lambdaDirectory: appContext.lambdaDirectory
|
|
53
|
-
} : "undefined"
|
|
47
|
+
plugins
|
|
54
48
|
};
|
|
55
49
|
let entryCode = (await import_utils.fs.readFile(import_node_path.default.join(__dirname, "./vercelEntry.js"))).toString();
|
|
56
|
-
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace(
|
|
57
|
-
"p_dynamicProdOptions",
|
|
58
|
-
// JSON.stringify(dynamicProdOptions),
|
|
59
|
-
JSON.stringify(dynamicProdOptions)
|
|
60
|
-
);
|
|
50
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
|
|
61
51
|
return entryCode;
|
|
62
52
|
}
|
|
63
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -27,6 +27,11 @@ async function initServer() {
|
|
|
27
27
|
pwd: __dirname,
|
|
28
28
|
routes,
|
|
29
29
|
disableCustomHook: true,
|
|
30
|
+
appContext: {
|
|
31
|
+
sharedDirectory: p_sharedDirectory,
|
|
32
|
+
apiDirectory: p_apiDirectory,
|
|
33
|
+
lambdaDirectory: p_lambdaDirectory
|
|
34
|
+
},
|
|
30
35
|
...dynamicProdOptions
|
|
31
36
|
};
|
|
32
37
|
const app = await createProdServer(prodServerOptions);
|
|
@@ -18,7 +18,7 @@ function deploy_default() {
|
|
|
18
18
|
return {
|
|
19
19
|
beforeDeploy: function beforeDeploy() {
|
|
20
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,
|
|
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
22
|
return _ts_generator(this, function(_state) {
|
|
23
23
|
switch (_state.label) {
|
|
24
24
|
case 0:
|
|
@@ -235,6 +235,7 @@ function deploy_default() {
|
|
|
235
235
|
lambdaDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, lambdaDirectory), '")'),
|
|
236
236
|
metaName
|
|
237
237
|
};
|
|
238
|
+
console.log("serverAppContext", serverAppContext);
|
|
238
239
|
code = "";
|
|
239
240
|
console.log("deployTarget111111111", deployTarget);
|
|
240
241
|
switch (deployTarget) {
|
|
@@ -246,17 +247,17 @@ function deploy_default() {
|
|
|
246
247
|
case "vercel":
|
|
247
248
|
return [
|
|
248
249
|
3,
|
|
249
|
-
|
|
250
|
+
22
|
|
250
251
|
];
|
|
251
252
|
case "netlify":
|
|
252
253
|
return [
|
|
253
254
|
3,
|
|
254
|
-
|
|
255
|
+
25
|
|
255
256
|
];
|
|
256
257
|
}
|
|
257
258
|
return [
|
|
258
259
|
3,
|
|
259
|
-
|
|
260
|
+
28
|
|
260
261
|
];
|
|
261
262
|
case 19:
|
|
262
263
|
return [
|
|
@@ -265,75 +266,79 @@ function deploy_default() {
|
|
|
265
266
|
];
|
|
266
267
|
case 20:
|
|
267
268
|
genNodeEntry = _state.sent().genNodeEntry;
|
|
268
|
-
code = genNodeEntry({
|
|
269
|
-
plugins,
|
|
270
|
-
config: modernConfig,
|
|
271
|
-
appContext: serverAppContext
|
|
272
|
-
});
|
|
273
269
|
return [
|
|
274
|
-
|
|
275
|
-
|
|
270
|
+
4,
|
|
271
|
+
genNodeEntry({
|
|
272
|
+
plugins,
|
|
273
|
+
config: modernConfig,
|
|
274
|
+
appContext: serverAppContext
|
|
275
|
+
})
|
|
276
276
|
];
|
|
277
277
|
case 21:
|
|
278
|
+
code = _state.sent();
|
|
279
|
+
return [
|
|
280
|
+
3,
|
|
281
|
+
29
|
|
282
|
+
];
|
|
283
|
+
case 22:
|
|
278
284
|
return [
|
|
279
285
|
4,
|
|
280
286
|
import("./platforms/vercel")
|
|
281
287
|
];
|
|
282
|
-
case
|
|
288
|
+
case 23:
|
|
283
289
|
genVercelEntry = _state.sent().genVercelEntry;
|
|
284
|
-
serverAppContext1 = {
|
|
285
|
-
sharedDirectory: path.join(__dirname, path.relative(appDirectory, sharedDirectory)),
|
|
286
|
-
apiDirectory: path.join(__dirname, path.relative(appDirectory, apiDirectory)),
|
|
287
|
-
lambdaDirectory: path.join(__dirname, path.relative(appDirectory, lambdaDirectory)),
|
|
288
|
-
metaName
|
|
289
|
-
};
|
|
290
290
|
return [
|
|
291
291
|
4,
|
|
292
292
|
genVercelEntry({
|
|
293
293
|
plugins,
|
|
294
294
|
config: modernConfig,
|
|
295
|
-
appContext:
|
|
295
|
+
appContext: serverAppContext
|
|
296
296
|
})
|
|
297
297
|
];
|
|
298
|
-
case
|
|
298
|
+
case 24:
|
|
299
299
|
code = _state.sent();
|
|
300
300
|
return [
|
|
301
301
|
3,
|
|
302
|
-
|
|
302
|
+
29
|
|
303
303
|
];
|
|
304
|
-
case
|
|
304
|
+
case 25:
|
|
305
305
|
return [
|
|
306
306
|
4,
|
|
307
307
|
import("./platforms/netlify")
|
|
308
308
|
];
|
|
309
|
-
case
|
|
309
|
+
case 26:
|
|
310
310
|
genNetlifyEntry = _state.sent().genNetlifyEntry;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
311
|
+
return [
|
|
312
|
+
4,
|
|
313
|
+
genNetlifyEntry({
|
|
314
|
+
plugins,
|
|
315
|
+
config: modernConfig,
|
|
316
|
+
appContext: serverAppContext
|
|
317
|
+
})
|
|
318
|
+
];
|
|
319
|
+
case 27:
|
|
320
|
+
code = _state.sent();
|
|
316
321
|
return [
|
|
317
322
|
3,
|
|
318
|
-
|
|
323
|
+
29
|
|
319
324
|
];
|
|
320
|
-
case
|
|
325
|
+
case 28:
|
|
321
326
|
{
|
|
322
327
|
code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
|
|
323
328
|
}
|
|
324
|
-
_state.label =
|
|
325
|
-
case
|
|
329
|
+
_state.label = 29;
|
|
330
|
+
case 29:
|
|
326
331
|
entryFilePath = path.join(funcsDirectory, "index.js");
|
|
327
332
|
if (!needModernServer)
|
|
328
333
|
return [
|
|
329
334
|
3,
|
|
330
|
-
|
|
335
|
+
32
|
|
331
336
|
];
|
|
332
337
|
return [
|
|
333
338
|
4,
|
|
334
339
|
fse.writeFile(entryFilePath, code)
|
|
335
340
|
];
|
|
336
|
-
case
|
|
341
|
+
case 30:
|
|
337
342
|
_state.sent();
|
|
338
343
|
return [
|
|
339
344
|
4,
|
|
@@ -341,10 +346,10 @@ function deploy_default() {
|
|
|
341
346
|
"@modern-js/prod-server"
|
|
342
347
|
])
|
|
343
348
|
];
|
|
344
|
-
case
|
|
349
|
+
case 31:
|
|
345
350
|
_state.sent();
|
|
346
|
-
_state.label =
|
|
347
|
-
case
|
|
351
|
+
_state.label = 32;
|
|
352
|
+
case 32:
|
|
348
353
|
return [
|
|
349
354
|
2
|
|
350
355
|
];
|
|
@@ -1,38 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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 { genPluginImportsCode } from "../utils";
|
|
6
|
+
function genNodeEntry(_) {
|
|
7
|
+
return _genNodeEntry.apply(this, arguments);
|
|
8
|
+
}
|
|
9
|
+
function _genNodeEntry() {
|
|
10
|
+
_genNodeEntry = _async_to_generator(function(param) {
|
|
11
|
+
var config, plugins, appContext, defaultConfig, pluginImportCode, dynamicProdOptions, entryCode;
|
|
12
|
+
return _ts_generator(this, function(_state) {
|
|
13
|
+
switch (_state.label) {
|
|
14
|
+
case 0:
|
|
15
|
+
config = param.config, plugins = param.plugins, appContext = param.appContext;
|
|
16
|
+
defaultConfig = {
|
|
17
|
+
server: {
|
|
18
|
+
port: 8080
|
|
19
|
+
},
|
|
20
|
+
output: {
|
|
21
|
+
path: "."
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
pluginImportCode = genPluginImportsCode(plugins || []);
|
|
25
|
+
dynamicProdOptions = {
|
|
26
|
+
config: config || defaultConfig,
|
|
27
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
28
|
+
plugins
|
|
29
|
+
};
|
|
30
|
+
return [
|
|
31
|
+
4,
|
|
32
|
+
fse.readFile(path.join(__dirname, "./nodeEntry.js"))
|
|
33
|
+
];
|
|
34
|
+
case 1:
|
|
35
|
+
entryCode = _state.sent().toString();
|
|
36
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
|
|
37
|
+
return [
|
|
38
|
+
2,
|
|
39
|
+
entryCode
|
|
40
|
+
];
|
|
30
41
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
routes,
|
|
35
|
-
config: `).concat(JSON.stringify(config || defaultConfig), ",\n serverConfigFile: '").concat(DEFAULT_SERVER_CONFIG, "',\n plugins: ").concat(getPluginsCode(plugins || []), ",\n appContext: ").concat(appContext ? severAppContextTemplate(appContext) : "undefined", ",\n disableCustomHook: true\n }\n\n const app = await createProdServer(prodServerOptions)\n\n const port = process.env.PORT || 3000;\n\n app.listen(port, () => {\n console.log('\\x1b[32mServer is listening on port', port, '\\x1b[0m');\n });\n } catch(error) {\n console.error(error);\n process.exit(1);\n }\n }\n\n main();\n ");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return _genNodeEntry.apply(this, arguments);
|
|
36
45
|
}
|
|
37
46
|
export {
|
|
38
47
|
genNodeEntry
|
|
@@ -76,7 +76,12 @@ function _main() {
|
|
|
76
76
|
prodServerOptions = _object_spread._({
|
|
77
77
|
pwd: __dirname,
|
|
78
78
|
routes,
|
|
79
|
-
disableCustomHook: true
|
|
79
|
+
disableCustomHook: true,
|
|
80
|
+
appContext: {
|
|
81
|
+
sharedDirectory: p_sharedDirectory,
|
|
82
|
+
apiDirectory: p_apiDirectory,
|
|
83
|
+
lambdaDirectory: p_lambdaDirectory
|
|
84
|
+
}
|
|
80
85
|
}, dynamicProdOptions);
|
|
81
86
|
return [
|
|
82
87
|
4,
|
|
@@ -86,7 +91,7 @@ function _main() {
|
|
|
86
91
|
app = _state.sent();
|
|
87
92
|
port = process.env.PORT || 8080;
|
|
88
93
|
app.listen(port, function() {
|
|
89
|
-
console.log("
|
|
94
|
+
console.log("\x1B[32mServer is listening on port", port, "\x1B[0m");
|
|
90
95
|
});
|
|
91
96
|
return [
|
|
92
97
|
2
|
|
@@ -3,33 +3,26 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
5
5
|
import { genPluginImportsCode } from "../utils";
|
|
6
|
-
function genVercelEntry() {
|
|
6
|
+
function genVercelEntry(_) {
|
|
7
7
|
return _genVercelEntry.apply(this, arguments);
|
|
8
8
|
}
|
|
9
9
|
function _genVercelEntry() {
|
|
10
|
-
_genVercelEntry = _async_to_generator(function() {
|
|
11
|
-
var
|
|
12
|
-
var _arguments = arguments;
|
|
10
|
+
_genVercelEntry = _async_to_generator(function(param) {
|
|
11
|
+
var config, plugins, appContext, defaultConfig, pluginImportCode, dynamicProdOptions, entryCode;
|
|
13
12
|
return _ts_generator(this, function(_state) {
|
|
14
13
|
switch (_state.label) {
|
|
15
14
|
case 0:
|
|
16
|
-
|
|
15
|
+
config = param.config, plugins = param.plugins, appContext = param.appContext;
|
|
17
16
|
defaultConfig = {
|
|
18
17
|
output: {
|
|
19
18
|
path: "."
|
|
20
19
|
}
|
|
21
20
|
};
|
|
22
|
-
console.log("appContext.sharedDirectory", appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory);
|
|
23
21
|
pluginImportCode = genPluginImportsCode(plugins || []);
|
|
24
22
|
dynamicProdOptions = {
|
|
25
23
|
config: config || defaultConfig,
|
|
26
24
|
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
27
|
-
plugins
|
|
28
|
-
appContext: appContext ? {
|
|
29
|
-
sharedDirectory: appContext.sharedDirectory,
|
|
30
|
-
apiDirectory: appContext.apiDirectory,
|
|
31
|
-
lambdaDirectory: appContext.lambdaDirectory
|
|
32
|
-
} : "undefined"
|
|
25
|
+
plugins
|
|
33
26
|
};
|
|
34
27
|
return [
|
|
35
28
|
4,
|
|
@@ -37,11 +30,7 @@ function _genVercelEntry() {
|
|
|
37
30
|
];
|
|
38
31
|
case 1:
|
|
39
32
|
entryCode = _state.sent().toString();
|
|
40
|
-
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace(
|
|
41
|
-
"p_dynamicProdOptions",
|
|
42
|
-
// JSON.stringify(dynamicProdOptions),
|
|
43
|
-
JSON.stringify(dynamicProdOptions)
|
|
44
|
-
);
|
|
33
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
|
|
45
34
|
return [
|
|
46
35
|
2,
|
|
47
36
|
entryCode
|
|
@@ -84,7 +84,12 @@ var require_vercelEntry = __commonJS({
|
|
|
84
84
|
prodServerOptions = _object_spread._({
|
|
85
85
|
pwd: __dirname,
|
|
86
86
|
routes,
|
|
87
|
-
disableCustomHook: true
|
|
87
|
+
disableCustomHook: true,
|
|
88
|
+
appContext: {
|
|
89
|
+
sharedDirectory: p_sharedDirectory,
|
|
90
|
+
apiDirectory: p_apiDirectory,
|
|
91
|
+
lambdaDirectory: p_lambdaDirectory
|
|
92
|
+
}
|
|
88
93
|
}, dynamicProdOptions);
|
|
89
94
|
return [
|
|
90
95
|
4,
|
|
@@ -135,12 +135,13 @@ var deploy_default = () => ({
|
|
|
135
135
|
lambdaDirectory: `path.join(__dirname, "${path.relative(appDirectory, lambdaDirectory)}")`,
|
|
136
136
|
metaName
|
|
137
137
|
};
|
|
138
|
+
console.log("serverAppContext", serverAppContext);
|
|
138
139
|
let code = ``;
|
|
139
140
|
console.log("deployTarget111111111", deployTarget);
|
|
140
141
|
switch (deployTarget) {
|
|
141
142
|
case "node": {
|
|
142
143
|
const { genNodeEntry } = await import("./platforms/node");
|
|
143
|
-
code = genNodeEntry({
|
|
144
|
+
code = await genNodeEntry({
|
|
144
145
|
plugins,
|
|
145
146
|
config: modernConfig,
|
|
146
147
|
appContext: serverAppContext
|
|
@@ -149,22 +150,16 @@ var deploy_default = () => ({
|
|
|
149
150
|
}
|
|
150
151
|
case "vercel": {
|
|
151
152
|
const { genVercelEntry } = await import("./platforms/vercel");
|
|
152
|
-
const serverAppContext2 = {
|
|
153
|
-
sharedDirectory: path.join(__dirname, path.relative(appDirectory, sharedDirectory)),
|
|
154
|
-
apiDirectory: path.join(__dirname, path.relative(appDirectory, apiDirectory)),
|
|
155
|
-
lambdaDirectory: path.join(__dirname, path.relative(appDirectory, lambdaDirectory)),
|
|
156
|
-
metaName
|
|
157
|
-
};
|
|
158
153
|
code = await genVercelEntry({
|
|
159
154
|
plugins,
|
|
160
155
|
config: modernConfig,
|
|
161
|
-
appContext:
|
|
156
|
+
appContext: serverAppContext
|
|
162
157
|
});
|
|
163
158
|
break;
|
|
164
159
|
}
|
|
165
160
|
case "netlify": {
|
|
166
161
|
const { genNetlifyEntry } = await import("./platforms/netlify");
|
|
167
|
-
code = genNetlifyEntry({
|
|
162
|
+
code = await genNetlifyEntry({
|
|
168
163
|
plugins,
|
|
169
164
|
config: modernConfig,
|
|
170
165
|
appContext: serverAppContext
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
3
|
+
import { genPluginImportsCode } from "../utils";
|
|
4
|
+
async function genNodeEntry({ config, plugins, appContext }) {
|
|
4
5
|
const defaultConfig = {
|
|
5
6
|
server: {
|
|
6
7
|
port: 8080
|
|
@@ -9,55 +10,15 @@ function genNodeEntry({ config, plugins, appContext } = {}) {
|
|
|
9
10
|
path: "."
|
|
10
11
|
}
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function main() {
|
|
24
|
-
try {
|
|
25
|
-
let routes = [];
|
|
26
|
-
const routeFilepath = path.join(__dirname, "${ROUTE_SPEC_FILE}");
|
|
27
|
-
try {
|
|
28
|
-
await fs.access(routeFilepath);
|
|
29
|
-
const content = await fs.readFile(routeFilepath, "utf-8");
|
|
30
|
-
const routeSpec = JSON.parse(content);
|
|
31
|
-
routes = routeSpec.routes;
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.warn('route.json not found, continuing with empty routes.');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const prodServerOptions = {
|
|
37
|
-
pwd: __dirname,
|
|
38
|
-
routes,
|
|
39
|
-
config: ${JSON.stringify(config || defaultConfig)},
|
|
40
|
-
serverConfigFile: '${DEFAULT_SERVER_CONFIG}',
|
|
41
|
-
plugins: ${getPluginsCode(plugins || [])},
|
|
42
|
-
appContext: ${appContext ? severAppContextTemplate(appContext) : "undefined"},
|
|
43
|
-
disableCustomHook: true
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const app = await createProdServer(prodServerOptions)
|
|
47
|
-
|
|
48
|
-
const port = process.env.PORT || 3000;
|
|
49
|
-
|
|
50
|
-
app.listen(port, () => {
|
|
51
|
-
console.log('\\x1b[32mServer is listening on port', port, '\\x1b[0m');
|
|
52
|
-
});
|
|
53
|
-
} catch(error) {
|
|
54
|
-
console.error(error);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
main();
|
|
60
|
-
`;
|
|
13
|
+
const pluginImportCode = genPluginImportsCode(plugins || []);
|
|
14
|
+
const dynamicProdOptions = {
|
|
15
|
+
config: config || defaultConfig,
|
|
16
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
17
|
+
plugins
|
|
18
|
+
};
|
|
19
|
+
let entryCode = (await fse.readFile(path.join(__dirname, "./nodeEntry.js"))).toString();
|
|
20
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
|
|
21
|
+
return entryCode;
|
|
61
22
|
}
|
|
62
23
|
export {
|
|
63
24
|
genNodeEntry
|
|
@@ -24,12 +24,17 @@ async function main() {
|
|
|
24
24
|
pwd: __dirname,
|
|
25
25
|
routes,
|
|
26
26
|
disableCustomHook: true,
|
|
27
|
+
appContext: {
|
|
28
|
+
sharedDirectory: p_sharedDirectory,
|
|
29
|
+
apiDirectory: p_apiDirectory,
|
|
30
|
+
lambdaDirectory: p_lambdaDirectory
|
|
31
|
+
},
|
|
27
32
|
...dynamicProdOptions
|
|
28
33
|
};
|
|
29
34
|
const app = await createProdServer(prodServerOptions);
|
|
30
35
|
const port = process.env.PORT || 8080;
|
|
31
36
|
app.listen(port, () => {
|
|
32
|
-
console.log("
|
|
37
|
+
console.log("\x1B[32mServer is listening on port", port, "\x1B[0m");
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
40
|
main();
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
3
3
|
import { genPluginImportsCode } from "../utils";
|
|
4
|
-
async function genVercelEntry({ config, plugins, appContext }
|
|
4
|
+
async function genVercelEntry({ config, plugins, appContext }) {
|
|
5
5
|
const defaultConfig = {
|
|
6
6
|
output: {
|
|
7
7
|
path: "."
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
console.log("appContext.sharedDirectory", appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory);
|
|
11
10
|
const pluginImportCode = genPluginImportsCode(plugins || []);
|
|
12
11
|
const dynamicProdOptions = {
|
|
13
12
|
config: config || defaultConfig,
|
|
14
13
|
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
|
15
|
-
plugins
|
|
16
|
-
appContext: appContext ? {
|
|
17
|
-
sharedDirectory: appContext.sharedDirectory,
|
|
18
|
-
apiDirectory: appContext.apiDirectory,
|
|
19
|
-
lambdaDirectory: appContext.lambdaDirectory
|
|
20
|
-
} : "undefined"
|
|
14
|
+
plugins
|
|
21
15
|
};
|
|
22
16
|
let entryCode = (await fse.readFile(path.join(__dirname, "./vercelEntry.js"))).toString();
|
|
23
|
-
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace(
|
|
24
|
-
"p_dynamicProdOptions",
|
|
25
|
-
// JSON.stringify(dynamicProdOptions),
|
|
26
|
-
JSON.stringify(dynamicProdOptions)
|
|
27
|
-
);
|
|
17
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
|
|
28
18
|
return entryCode;
|
|
29
19
|
}
|
|
30
20
|
export {
|
|
@@ -32,6 +32,11 @@ var require_vercelEntry = __commonJS({
|
|
|
32
32
|
pwd: __dirname,
|
|
33
33
|
routes,
|
|
34
34
|
disableCustomHook: true,
|
|
35
|
+
appContext: {
|
|
36
|
+
sharedDirectory: p_sharedDirectory,
|
|
37
|
+
apiDirectory: p_apiDirectory,
|
|
38
|
+
lambdaDirectory: p_lambdaDirectory
|
|
39
|
+
},
|
|
35
40
|
...dynamicProdOptions
|
|
36
41
|
};
|
|
37
42
|
const app = await createProdServer(prodServerOptions);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { NormalizedConfig } from '@modern-js/core';
|
|
2
|
+
import { AppTools } from '../../../types';
|
|
3
|
+
import { AppContext } from './platform';
|
|
4
|
+
export declare function genNodeEntry({ config, plugins, appContext, }: {
|
|
5
|
+
config?: NormalizedConfig<AppTools>;
|
|
3
6
|
plugins?: string[];
|
|
4
|
-
appContext
|
|
5
|
-
}): string
|
|
7
|
+
appContext: AppContext;
|
|
8
|
+
}): Promise<string>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { NormalizedConfig } from '@modern-js/core';
|
|
2
|
+
import { AppTools } from '../../../types';
|
|
3
|
+
import { AppContext } from './platform';
|
|
4
|
+
export declare function genVercelEntry({ config, plugins, appContext, }: {
|
|
5
|
+
config?: NormalizedConfig<AppTools>;
|
|
3
6
|
plugins?: string[];
|
|
4
|
-
appContext
|
|
7
|
+
appContext: AppContext;
|
|
5
8
|
}): Promise<string>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.49.3-alpha.
|
|
18
|
+
"version": "2.49.3-alpha.13",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -80,20 +80,20 @@
|
|
|
80
80
|
"mlly": "^1.6.1",
|
|
81
81
|
"pkg-types": "^1.1.0",
|
|
82
82
|
"std-env": "^3.7.0",
|
|
83
|
-
"@modern-js/
|
|
84
|
-
"@modern-js/plugin": "2.49.2",
|
|
83
|
+
"@modern-js/node-bundle-require": "2.49.2",
|
|
85
84
|
"@modern-js/plugin-data-loader": "2.49.2",
|
|
85
|
+
"@modern-js/core": "2.49.2",
|
|
86
86
|
"@modern-js/plugin-i18n": "2.49.2",
|
|
87
|
-
"@modern-js/rsbuild-plugin-esbuild": "2.49.2",
|
|
88
|
-
"@modern-js/prod-server": "2.49.2",
|
|
89
87
|
"@modern-js/plugin-lint": "2.49.2",
|
|
88
|
+
"@modern-js/prod-server": "2.49.2",
|
|
89
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.49.2",
|
|
90
|
+
"@modern-js/plugin": "2.49.2",
|
|
91
|
+
"@modern-js/server": "2.49.2",
|
|
90
92
|
"@modern-js/server-core": "2.49.2",
|
|
91
|
-
"@modern-js/
|
|
93
|
+
"@modern-js/uni-builder": "2.49.2",
|
|
92
94
|
"@modern-js/server-utils": "2.49.2",
|
|
93
95
|
"@modern-js/types": "2.49.2",
|
|
94
|
-
"@modern-js/
|
|
95
|
-
"@modern-js/utils": "2.49.2",
|
|
96
|
-
"@modern-js/server": "2.49.2"
|
|
96
|
+
"@modern-js/utils": "2.49.2"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@rsbuild/plugin-swc": "0.6.10",
|