@modern-js/app-tools 2.49.3-alpha.1 → 2.49.3-alpha.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/analyze/getServerRoutes.js +4 -3
- package/dist/cjs/plugins/deploy/index.js +53 -24
- package/dist/cjs/plugins/deploy/platforms/nodeEntry.js +36 -0
- package/dist/cjs/plugins/deploy/platforms/platform.js +16 -0
- package/dist/cjs/plugins/deploy/platforms/vercel.js +57 -0
- package/dist/cjs/plugins/deploy/platforms/vercelEntry.js +55 -0
- package/dist/cjs/utils/routes.js +7 -2
- package/dist/esm/analyze/getServerRoutes.js +5 -4
- package/dist/esm/plugins/deploy/index.js +118 -74
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +99 -0
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +47 -0
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +197 -0
- package/dist/esm/utils/routes.js +6 -2
- package/dist/esm-node/analyze/getServerRoutes.js +5 -4
- package/dist/esm-node/plugins/deploy/index.js +53 -24
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +35 -0
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +23 -0
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +63 -0
- package/dist/esm-node/utils/routes.js +6 -2
- package/dist/types/plugins/deploy/platforms/nodeEntry.d.ts +1 -0
- package/dist/types/plugins/deploy/platforms/platform.d.ts +1 -0
- package/dist/types/plugins/deploy/{entrys → platforms}/vercel.d.ts +2 -3
- package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +2 -0
- package/dist/types/utils/routes.d.ts +3 -3
- package/package.json +7 -7
- package/dist/cjs/plugins/deploy/entrys/vercel.js +0 -97
- package/dist/esm/plugins/deploy/entrys/vercel.js +0 -43
- package/dist/esm-node/plugins/deploy/entrys/vercel.js +0 -73
- /package/dist/cjs/plugins/deploy/{entrys → platforms}/netlify.js +0 -0
- /package/dist/cjs/plugins/deploy/{entrys → platforms}/node.js +0 -0
- /package/dist/esm/plugins/deploy/{entrys → platforms}/netlify.js +0 -0
- /package/dist/esm/plugins/deploy/{entrys → platforms}/node.js +0 -0
- /package/dist/esm-node/plugins/deploy/{entrys → platforms}/netlify.js +0 -0
- /package/dist/esm-node/plugins/deploy/{entrys → platforms}/node.js +0 -0
- /package/dist/types/plugins/deploy/{entrys → platforms}/netlify.d.ts +0 -0
- /package/dist/types/plugins/deploy/{entrys → platforms}/node.d.ts +0 -0
@@ -1,97 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
var vercel_exports = {};
|
20
|
-
__export(vercel_exports, {
|
21
|
-
genVercelEntry: () => genVercelEntry
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(vercel_exports);
|
24
|
-
var import_utils = require("@modern-js/utils");
|
25
|
-
var import_utils2 = require("../utils");
|
26
|
-
function genVercelEntry({ config, plugins, appContext } = {}) {
|
27
|
-
const defaultConfig = {
|
28
|
-
server: {
|
29
|
-
port: 8080
|
30
|
-
},
|
31
|
-
output: {
|
32
|
-
path: "."
|
33
|
-
}
|
34
|
-
};
|
35
|
-
if (appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory) {
|
36
|
-
appContext.apiDirectory = appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory.replace(/\/api$/, "/_api");
|
37
|
-
}
|
38
|
-
return `
|
39
|
-
|
40
|
-
const fs = require('node:fs/promises');
|
41
|
-
const path = require('node:path');
|
42
|
-
const { createProdServer } = require('@modern-js/prod-server');
|
43
|
-
${(0, import_utils2.genPluginImportsCode)(plugins || [])}
|
44
|
-
|
45
|
-
if(!process.env.NODE_ENV){
|
46
|
-
process.env.NODE_ENV = 'production';
|
47
|
-
}
|
48
|
-
|
49
|
-
let requestHandler = null;
|
50
|
-
async function createHandler() {
|
51
|
-
try {
|
52
|
-
let routes = [];
|
53
|
-
const routeFilepath = path.join(__dirname, "${import_utils.ROUTE_SPEC_FILE}");
|
54
|
-
try {
|
55
|
-
await fs.access(routeFilepath);
|
56
|
-
const content = await fs.readFile(routeFilepath, "utf-8");
|
57
|
-
const routeSpec = JSON.parse(content);
|
58
|
-
routes = routeSpec.routes;
|
59
|
-
} catch (error) {
|
60
|
-
console.warn('route.json not found, continuing with empty routes.');
|
61
|
-
}
|
62
|
-
|
63
|
-
const prodServerOptions = {
|
64
|
-
pwd: __dirname,
|
65
|
-
routes,
|
66
|
-
config: ${JSON.stringify(config || defaultConfig)},
|
67
|
-
serverConfigFile: '${import_utils.DEFAULT_SERVER_CONFIG}',
|
68
|
-
plugins: ${(0, import_utils2.getPluginsCode)(plugins || [])},
|
69
|
-
appContext: ${appContext ? (0, import_utils2.severAppContextTemplate)(appContext) : "undefined"},
|
70
|
-
disableCustomHook: true
|
71
|
-
}
|
72
|
-
|
73
|
-
const app = await createProdServer(prodServerOptions)
|
74
|
-
|
75
|
-
requestHandler = app.getRequestListener();
|
76
|
-
|
77
|
-
return requestHandler;
|
78
|
-
} catch(error) {
|
79
|
-
console.error(error);
|
80
|
-
process.exit(1);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
createHandler();
|
85
|
-
|
86
|
-
module.exports = async(req, res) => {
|
87
|
-
if(typeof requestHandler !== 'function'){
|
88
|
-
await createHandler();
|
89
|
-
}
|
90
|
-
return requestHandler(req, res);
|
91
|
-
}
|
92
|
-
`;
|
93
|
-
}
|
94
|
-
// Annotate the CommonJS export names for ESM import in node:
|
95
|
-
0 && (module.exports = {
|
96
|
-
genVercelEntry
|
97
|
-
});
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG } from "@modern-js/utils";
|
2
|
-
import { genPluginImportsCode, getPluginsCode, severAppContextTemplate } from "../utils";
|
3
|
-
function genVercelEntry() {
|
4
|
-
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, config = _ref.config, plugins = _ref.plugins, appContext = _ref.appContext;
|
5
|
-
var defaultConfig = {
|
6
|
-
server: {
|
7
|
-
port: 8080
|
8
|
-
},
|
9
|
-
output: {
|
10
|
-
path: "."
|
11
|
-
}
|
12
|
-
};
|
13
|
-
if (appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory) {
|
14
|
-
appContext.apiDirectory = appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory.replace(/\/api$/, "/_api");
|
15
|
-
}
|
16
|
-
return "\n\n const fs = require('node:fs/promises');\n const path = require('node:path');\n const { createProdServer } = require('@modern-js/prod-server');\n ".concat(genPluginImportsCode(plugins || []), `
|
17
|
-
|
18
|
-
if(!process.env.NODE_ENV){
|
19
|
-
process.env.NODE_ENV = 'production';
|
20
|
-
}
|
21
|
-
|
22
|
-
let requestHandler = null;
|
23
|
-
async function createHandler() {
|
24
|
-
try {
|
25
|
-
let routes = [];
|
26
|
-
const routeFilepath = path.join(__dirname, "`).concat(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: `).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 requestHandler = app.getRequestListener();\n\n return requestHandler;\n } catch(error) {\n console.error(error);\n process.exit(1);\n }\n }\n\n createHandler();\n\n module.exports = async(req, res) => {\n if(typeof requestHandler !== 'function'){\n await createHandler();\n }\n return requestHandler(req, res);\n }\n ");
|
40
|
-
}
|
41
|
-
export {
|
42
|
-
genVercelEntry
|
43
|
-
};
|
@@ -1,73 +0,0 @@
|
|
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
|
-
if (appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory) {
|
13
|
-
appContext.apiDirectory = appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory.replace(/\/api$/, "/_api");
|
14
|
-
}
|
15
|
-
return `
|
16
|
-
|
17
|
-
const fs = require('node:fs/promises');
|
18
|
-
const path = require('node:path');
|
19
|
-
const { createProdServer } = require('@modern-js/prod-server');
|
20
|
-
${genPluginImportsCode(plugins || [])}
|
21
|
-
|
22
|
-
if(!process.env.NODE_ENV){
|
23
|
-
process.env.NODE_ENV = 'production';
|
24
|
-
}
|
25
|
-
|
26
|
-
let requestHandler = null;
|
27
|
-
async function createHandler() {
|
28
|
-
try {
|
29
|
-
let routes = [];
|
30
|
-
const routeFilepath = path.join(__dirname, "${ROUTE_SPEC_FILE}");
|
31
|
-
try {
|
32
|
-
await fs.access(routeFilepath);
|
33
|
-
const content = await fs.readFile(routeFilepath, "utf-8");
|
34
|
-
const routeSpec = JSON.parse(content);
|
35
|
-
routes = routeSpec.routes;
|
36
|
-
} catch (error) {
|
37
|
-
console.warn('route.json not found, continuing with empty routes.');
|
38
|
-
}
|
39
|
-
|
40
|
-
const prodServerOptions = {
|
41
|
-
pwd: __dirname,
|
42
|
-
routes,
|
43
|
-
config: ${JSON.stringify(config || defaultConfig)},
|
44
|
-
serverConfigFile: '${DEFAULT_SERVER_CONFIG}',
|
45
|
-
plugins: ${getPluginsCode(plugins || [])},
|
46
|
-
appContext: ${appContext ? severAppContextTemplate(appContext) : "undefined"},
|
47
|
-
disableCustomHook: true
|
48
|
-
}
|
49
|
-
|
50
|
-
const app = await createProdServer(prodServerOptions)
|
51
|
-
|
52
|
-
requestHandler = app.getRequestListener();
|
53
|
-
|
54
|
-
return requestHandler;
|
55
|
-
} catch(error) {
|
56
|
-
console.error(error);
|
57
|
-
process.exit(1);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
createHandler();
|
62
|
-
|
63
|
-
module.exports = async(req, res) => {
|
64
|
-
if(typeof requestHandler !== 'function'){
|
65
|
-
await createHandler();
|
66
|
-
}
|
67
|
-
return requestHandler(req, res);
|
68
|
-
}
|
69
|
-
`;
|
70
|
-
}
|
71
|
-
export {
|
72
|
-
genVercelEntry
|
73
|
-
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|