@modern-js/app-tools 2.60.1 → 2.60.2
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/platforms/netlify.js +5 -4
- package/dist/cjs/plugins/deploy/platforms/node.js +5 -4
- package/dist/cjs/plugins/deploy/platforms/vercel.js +5 -4
- package/dist/cjs/plugins/deploy/utils.js +5 -3
- package/dist/esm/plugins/deploy/platforms/netlify.js +6 -5
- package/dist/esm/plugins/deploy/platforms/node.js +6 -5
- package/dist/esm/plugins/deploy/platforms/vercel.js +6 -5
- package/dist/esm/plugins/deploy/utils.js +10 -7
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -5
- package/dist/esm-node/plugins/deploy/platforms/node.js +6 -5
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -5
- package/dist/esm-node/plugins/deploy/utils.js +5 -3
- package/dist/types/plugins/deploy/utils.d.ts +3 -2
- package/package.json +31 -19
|
@@ -52,7 +52,10 @@ async function cleanDistDirectory(dir) {
|
|
|
52
52
|
const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
53
53
|
const { appDirectory, distDirectory, entrypoints, serverPlugins, moduleType } = appContext;
|
|
54
54
|
const isEsmProject = moduleType === "module";
|
|
55
|
-
const plugins = serverPlugins.map((plugin) =>
|
|
55
|
+
const plugins = serverPlugins.map((plugin) => [
|
|
56
|
+
plugin.name,
|
|
57
|
+
plugin.options
|
|
58
|
+
]);
|
|
56
59
|
const netlifyOutput = import_node_path.default.join(appDirectory, ".netlify");
|
|
57
60
|
const funcsDirectory = import_node_path.default.join(netlifyOutput, "functions");
|
|
58
61
|
const entryFilePath = import_node_path.default.join(funcsDirectory, "index.js");
|
|
@@ -115,9 +118,7 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
115
118
|
config: serverConfig,
|
|
116
119
|
serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG
|
|
117
120
|
};
|
|
118
|
-
const pluginsCode =
|
|
119
|
-
return `plugin_${index}()`;
|
|
120
|
-
}).join(",")}]`;
|
|
121
|
+
const pluginsCode = (0, import_utils2.getPluginsCode)(plugins);
|
|
121
122
|
let handlerCode = (await import_utils.fs.readFile(import_node_path.default.join(__dirname, "./netlify-handler.js"))).toString();
|
|
122
123
|
const serverAppContext = (0, import_utils2.serverAppContenxtTemplate)(appContext);
|
|
123
124
|
handlerCode = handlerCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
@@ -38,7 +38,10 @@ var import_utils2 = require("../utils");
|
|
|
38
38
|
const createNodePreset = (appContext, config) => {
|
|
39
39
|
const { appDirectory, distDirectory, serverPlugins, moduleType } = appContext;
|
|
40
40
|
const isEsmProject = moduleType === "module";
|
|
41
|
-
const plugins = serverPlugins.map((plugin) =>
|
|
41
|
+
const plugins = serverPlugins.map((plugin) => [
|
|
42
|
+
plugin.name,
|
|
43
|
+
plugin.options
|
|
44
|
+
]);
|
|
42
45
|
const outputDirectory = import_node_path.default.join(appDirectory, ".output");
|
|
43
46
|
const staticDirectory = import_node_path.default.join(outputDirectory, "static");
|
|
44
47
|
const entryFilePath = import_node_path.default.join(outputDirectory, "index.js");
|
|
@@ -69,9 +72,7 @@ const createNodePreset = (appContext, config) => {
|
|
|
69
72
|
config: serverConfig,
|
|
70
73
|
serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG
|
|
71
74
|
};
|
|
72
|
-
const pluginsCode =
|
|
73
|
-
return `plugin_${index}()`;
|
|
74
|
-
}).join(",")}]`;
|
|
75
|
+
const pluginsCode = (0, import_utils2.getPluginsCode)(plugins);
|
|
75
76
|
let entryCode = (await import_utils.fs.readFile(import_node_path.default.join(__dirname, "./node-entry.js"))).toString();
|
|
76
77
|
const serverAppContext = (0, import_utils2.serverAppContenxtTemplate)(appContext);
|
|
77
78
|
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
@@ -39,7 +39,10 @@ var import_utils2 = require("../utils");
|
|
|
39
39
|
const createVercelPreset = (appContext, modernConfig, needModernServer) => {
|
|
40
40
|
const { appDirectory, distDirectory, entrypoints, serverPlugins, moduleType } = appContext;
|
|
41
41
|
const isEsmProject = moduleType === "module";
|
|
42
|
-
const plugins = serverPlugins.map((plugin) =>
|
|
42
|
+
const plugins = serverPlugins.map((plugin) => [
|
|
43
|
+
plugin.name,
|
|
44
|
+
plugin.options
|
|
45
|
+
]);
|
|
43
46
|
const vercelOutput = import_node_path.default.join(appDirectory, ".vercel");
|
|
44
47
|
const outputDirectory = import_node_path.default.join(vercelOutput, "output");
|
|
45
48
|
const funcsDirectory = import_node_path.default.join(outputDirectory, "functions", "index.func");
|
|
@@ -130,9 +133,7 @@ const createVercelPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
130
133
|
config: serverConfig,
|
|
131
134
|
serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG
|
|
132
135
|
};
|
|
133
|
-
const pluginsCode =
|
|
134
|
-
return `plugin_${index}()`;
|
|
135
|
-
}).join(",")}]`;
|
|
136
|
+
const pluginsCode = (0, import_utils2.getPluginsCode)(plugins || []);
|
|
136
137
|
const serverAppContext = (0, import_utils2.serverAppContenxtTemplate)(appContext);
|
|
137
138
|
let handlerCode = (await import_utils.fs.readFile(import_node_path.default.join(__dirname, "./vercel-handler.js"))).toString();
|
|
138
139
|
handlerCode = handlerCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
@@ -45,13 +45,15 @@ const serverAppContenxtTemplate = (appContext) => {
|
|
|
45
45
|
metaName
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
|
-
const getPluginsCode = (plugins) => `[${plugins.map((_, index) => `plugin_${index}()`).join(",")}]`;
|
|
49
48
|
const genPluginImportsCode = (plugins) => {
|
|
50
|
-
return plugins.map((
|
|
51
|
-
let plugin_${index} = require('${
|
|
49
|
+
return plugins.map(([name, options], index) => `
|
|
50
|
+
let plugin_${index} = require('${name}')
|
|
52
51
|
plugin_${index} = plugin_${index}.default || plugin_${index}
|
|
53
52
|
`).join(";\n");
|
|
54
53
|
};
|
|
54
|
+
const getPluginsCode = (plugins) => {
|
|
55
|
+
return `[${plugins.map(([, options], index) => `plugin_${index}(${options ? JSON.stringify(options) : ""})`).join(",")}]`;
|
|
56
|
+
};
|
|
55
57
|
const getProjectUsage = (appDirectory, distDirectory) => {
|
|
56
58
|
const routeJSON = import_path.default.join(distDirectory, import_utils.ROUTE_SPEC_FILE);
|
|
57
59
|
const { routes } = import_utils.fs.readJSONSync(routeJSON);
|
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
|
|
5
5
|
import { isMainEntry } from "../../../utils/routes";
|
|
6
6
|
import { handleDependencies } from "../dependencies";
|
|
7
|
-
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
7
|
+
import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
|
|
8
8
|
function cleanDistDirectory(dir) {
|
|
9
9
|
return _cleanDistDirectory.apply(this, arguments);
|
|
10
10
|
}
|
|
@@ -114,7 +114,10 @@ var createNetlifyPreset = function(appContext, modernConfig, needModernServer) {
|
|
|
114
114
|
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, entrypoints = appContext.entrypoints, serverPlugins = appContext.serverPlugins, moduleType = appContext.moduleType;
|
|
115
115
|
var isEsmProject = moduleType === "module";
|
|
116
116
|
var plugins = serverPlugins.map(function(plugin) {
|
|
117
|
-
return
|
|
117
|
+
return [
|
|
118
|
+
plugin.name,
|
|
119
|
+
plugin.options
|
|
120
|
+
];
|
|
118
121
|
});
|
|
119
122
|
var netlifyOutput = path.join(appDirectory, ".netlify");
|
|
120
123
|
var funcsDirectory = path.join(netlifyOutput, "functions");
|
|
@@ -230,9 +233,7 @@ var createNetlifyPreset = function(appContext, modernConfig, needModernServer) {
|
|
|
230
233
|
config: serverConfig,
|
|
231
234
|
serverConfigFile: DEFAULT_SERVER_CONFIG
|
|
232
235
|
};
|
|
233
|
-
pluginsCode =
|
|
234
|
-
return "plugin_".concat(index, "()");
|
|
235
|
-
}).join(","), "]");
|
|
236
|
+
pluginsCode = getPluginsCode(plugins);
|
|
236
237
|
return [
|
|
237
238
|
4,
|
|
238
239
|
fse.readFile(path.join(__dirname, "./netlify-handler.js"))
|
|
@@ -3,12 +3,15 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, chalk, fs as fse } from "@modern-js/utils";
|
|
5
5
|
import { handleDependencies } from "../dependencies";
|
|
6
|
-
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
6
|
+
import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
|
|
7
7
|
var createNodePreset = function(appContext, config) {
|
|
8
8
|
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverPlugins = appContext.serverPlugins, moduleType = appContext.moduleType;
|
|
9
9
|
var isEsmProject = moduleType === "module";
|
|
10
10
|
var plugins = serverPlugins.map(function(plugin) {
|
|
11
|
-
return
|
|
11
|
+
return [
|
|
12
|
+
plugin.name,
|
|
13
|
+
plugin.options
|
|
14
|
+
];
|
|
12
15
|
});
|
|
13
16
|
var outputDirectory = path.join(appDirectory, ".output");
|
|
14
17
|
var staticDirectory = path.join(outputDirectory, "static");
|
|
@@ -74,9 +77,7 @@ var createNodePreset = function(appContext, config) {
|
|
|
74
77
|
config: serverConfig,
|
|
75
78
|
serverConfigFile: DEFAULT_SERVER_CONFIG
|
|
76
79
|
};
|
|
77
|
-
pluginsCode =
|
|
78
|
-
return "plugin_".concat(index, "()");
|
|
79
|
-
}).join(","), "]");
|
|
80
|
+
pluginsCode = getPluginsCode(plugins);
|
|
80
81
|
return [
|
|
81
82
|
4,
|
|
82
83
|
fse.readFile(path.join(__dirname, "./node-entry.js"))
|
|
@@ -4,12 +4,15 @@ import path from "node:path";
|
|
|
4
4
|
import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
|
|
5
5
|
import { isMainEntry } from "../../../utils/routes";
|
|
6
6
|
import { handleDependencies } from "../dependencies";
|
|
7
|
-
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
7
|
+
import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
|
|
8
8
|
var createVercelPreset = function(appContext, modernConfig, needModernServer) {
|
|
9
9
|
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, entrypoints = appContext.entrypoints, serverPlugins = appContext.serverPlugins, moduleType = appContext.moduleType;
|
|
10
10
|
var isEsmProject = moduleType === "module";
|
|
11
11
|
var plugins = serverPlugins.map(function(plugin) {
|
|
12
|
-
return
|
|
12
|
+
return [
|
|
13
|
+
plugin.name,
|
|
14
|
+
plugin.options
|
|
15
|
+
];
|
|
13
16
|
});
|
|
14
17
|
var vercelOutput = path.join(appDirectory, ".vercel");
|
|
15
18
|
var outputDirectory = path.join(vercelOutput, "output");
|
|
@@ -177,9 +180,7 @@ var createVercelPreset = function(appContext, modernConfig, needModernServer) {
|
|
|
177
180
|
config: serverConfig,
|
|
178
181
|
serverConfigFile: DEFAULT_SERVER_CONFIG
|
|
179
182
|
};
|
|
180
|
-
pluginsCode =
|
|
181
|
-
return "plugin_".concat(index, "()");
|
|
182
|
-
}).join(","), "]");
|
|
183
|
+
pluginsCode = getPluginsCode(plugins || []);
|
|
183
184
|
serverAppContext = serverAppContenxtTemplate(appContext);
|
|
184
185
|
return [
|
|
185
186
|
4,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import { ROUTE_SPEC_FILE, fs as fse, isDepExists } from "@modern-js/utils";
|
|
3
4
|
var serverAppContenxtTemplate = function(appContext) {
|
|
@@ -9,16 +10,18 @@ var serverAppContenxtTemplate = function(appContext) {
|
|
|
9
10
|
metaName
|
|
10
11
|
};
|
|
11
12
|
};
|
|
12
|
-
var getPluginsCode = function(plugins) {
|
|
13
|
-
return "[".concat(plugins.map(function(_, index) {
|
|
14
|
-
return "plugin_".concat(index, "()");
|
|
15
|
-
}).join(","), "]");
|
|
16
|
-
};
|
|
17
13
|
var genPluginImportsCode = function(plugins) {
|
|
18
|
-
return plugins.map(function(
|
|
19
|
-
|
|
14
|
+
return plugins.map(function(param, index) {
|
|
15
|
+
var _param = _sliced_to_array(param, 2), name = _param[0], options = _param[1];
|
|
16
|
+
return "\n let plugin_".concat(index, " = require('").concat(name, "')\n plugin_").concat(index, " = plugin_").concat(index, ".default || plugin_").concat(index, "\n ");
|
|
20
17
|
}).join(";\n");
|
|
21
18
|
};
|
|
19
|
+
var getPluginsCode = function(plugins) {
|
|
20
|
+
return "[".concat(plugins.map(function(param, index) {
|
|
21
|
+
var _param = _sliced_to_array(param, 2), options = _param[1];
|
|
22
|
+
return "plugin_".concat(index, "(").concat(options ? JSON.stringify(options) : "", ")");
|
|
23
|
+
}).join(","), "]");
|
|
24
|
+
};
|
|
22
25
|
var getProjectUsage = function(appDirectory, distDirectory) {
|
|
23
26
|
var routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
|
24
27
|
var routes = fse.readJSONSync(routeJSON).routes;
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
|
|
3
3
|
import { isMainEntry } from "../../../utils/routes";
|
|
4
4
|
import { handleDependencies } from "../dependencies";
|
|
5
|
-
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
5
|
+
import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
|
|
6
6
|
async function cleanDistDirectory(dir) {
|
|
7
7
|
try {
|
|
8
8
|
const items = await fse.readdir(dir);
|
|
@@ -19,7 +19,10 @@ async function cleanDistDirectory(dir) {
|
|
|
19
19
|
const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
20
20
|
const { appDirectory, distDirectory, entrypoints, serverPlugins, moduleType } = appContext;
|
|
21
21
|
const isEsmProject = moduleType === "module";
|
|
22
|
-
const plugins = serverPlugins.map((plugin) =>
|
|
22
|
+
const plugins = serverPlugins.map((plugin) => [
|
|
23
|
+
plugin.name,
|
|
24
|
+
plugin.options
|
|
25
|
+
]);
|
|
23
26
|
const netlifyOutput = path.join(appDirectory, ".netlify");
|
|
24
27
|
const funcsDirectory = path.join(netlifyOutput, "functions");
|
|
25
28
|
const entryFilePath = path.join(funcsDirectory, "index.js");
|
|
@@ -82,9 +85,7 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
82
85
|
config: serverConfig,
|
|
83
86
|
serverConfigFile: DEFAULT_SERVER_CONFIG
|
|
84
87
|
};
|
|
85
|
-
const pluginsCode =
|
|
86
|
-
return `plugin_${index}()`;
|
|
87
|
-
}).join(",")}]`;
|
|
88
|
+
const pluginsCode = getPluginsCode(plugins);
|
|
88
89
|
let handlerCode = (await fse.readFile(path.join(__dirname, "./netlify-handler.js"))).toString();
|
|
89
90
|
const serverAppContext = serverAppContenxtTemplate(appContext);
|
|
90
91
|
handlerCode = handlerCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, chalk, fs as fse } from "@modern-js/utils";
|
|
3
3
|
import { handleDependencies } from "../dependencies";
|
|
4
|
-
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
4
|
+
import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
|
|
5
5
|
const createNodePreset = (appContext, config) => {
|
|
6
6
|
const { appDirectory, distDirectory, serverPlugins, moduleType } = appContext;
|
|
7
7
|
const isEsmProject = moduleType === "module";
|
|
8
|
-
const plugins = serverPlugins.map((plugin) =>
|
|
8
|
+
const plugins = serverPlugins.map((plugin) => [
|
|
9
|
+
plugin.name,
|
|
10
|
+
plugin.options
|
|
11
|
+
]);
|
|
9
12
|
const outputDirectory = path.join(appDirectory, ".output");
|
|
10
13
|
const staticDirectory = path.join(outputDirectory, "static");
|
|
11
14
|
const entryFilePath = path.join(outputDirectory, "index.js");
|
|
@@ -36,9 +39,7 @@ const createNodePreset = (appContext, config) => {
|
|
|
36
39
|
config: serverConfig,
|
|
37
40
|
serverConfigFile: DEFAULT_SERVER_CONFIG
|
|
38
41
|
};
|
|
39
|
-
const pluginsCode =
|
|
40
|
-
return `plugin_${index}()`;
|
|
41
|
-
}).join(",")}]`;
|
|
42
|
+
const pluginsCode = getPluginsCode(plugins);
|
|
42
43
|
let entryCode = (await fse.readFile(path.join(__dirname, "./node-entry.js"))).toString();
|
|
43
44
|
const serverAppContext = serverAppContenxtTemplate(appContext);
|
|
44
45
|
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
@@ -2,11 +2,14 @@ import path from "node:path";
|
|
|
2
2
|
import { DEFAULT_SERVER_CONFIG, ROUTE_SPEC_FILE, fs as fse } from "@modern-js/utils";
|
|
3
3
|
import { isMainEntry } from "../../../utils/routes";
|
|
4
4
|
import { handleDependencies } from "../dependencies";
|
|
5
|
-
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
5
|
+
import { genPluginImportsCode, getPluginsCode, serverAppContenxtTemplate } from "../utils";
|
|
6
6
|
const createVercelPreset = (appContext, modernConfig, needModernServer) => {
|
|
7
7
|
const { appDirectory, distDirectory, entrypoints, serverPlugins, moduleType } = appContext;
|
|
8
8
|
const isEsmProject = moduleType === "module";
|
|
9
|
-
const plugins = serverPlugins.map((plugin) =>
|
|
9
|
+
const plugins = serverPlugins.map((plugin) => [
|
|
10
|
+
plugin.name,
|
|
11
|
+
plugin.options
|
|
12
|
+
]);
|
|
10
13
|
const vercelOutput = path.join(appDirectory, ".vercel");
|
|
11
14
|
const outputDirectory = path.join(vercelOutput, "output");
|
|
12
15
|
const funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
|
@@ -97,9 +100,7 @@ const createVercelPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
97
100
|
config: serverConfig,
|
|
98
101
|
serverConfigFile: DEFAULT_SERVER_CONFIG
|
|
99
102
|
};
|
|
100
|
-
const pluginsCode =
|
|
101
|
-
return `plugin_${index}()`;
|
|
102
|
-
}).join(",")}]`;
|
|
103
|
+
const pluginsCode = getPluginsCode(plugins || []);
|
|
103
104
|
const serverAppContext = serverAppContenxtTemplate(appContext);
|
|
104
105
|
let handlerCode = (await fse.readFile(path.join(__dirname, "./vercel-handler.js"))).toString();
|
|
105
106
|
handlerCode = handlerCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_plugins", pluginsCode).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
|
@@ -9,13 +9,15 @@ const serverAppContenxtTemplate = (appContext) => {
|
|
|
9
9
|
metaName
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
const getPluginsCode = (plugins) => `[${plugins.map((_, index) => `plugin_${index}()`).join(",")}]`;
|
|
13
12
|
const genPluginImportsCode = (plugins) => {
|
|
14
|
-
return plugins.map((
|
|
15
|
-
let plugin_${index} = require('${
|
|
13
|
+
return plugins.map(([name, options], index) => `
|
|
14
|
+
let plugin_${index} = require('${name}')
|
|
16
15
|
plugin_${index} = plugin_${index}.default || plugin_${index}
|
|
17
16
|
`).join(";\n");
|
|
18
17
|
};
|
|
18
|
+
const getPluginsCode = (plugins) => {
|
|
19
|
+
return `[${plugins.map(([, options], index) => `plugin_${index}(${options ? JSON.stringify(options) : ""})`).join(",")}]`;
|
|
20
|
+
};
|
|
19
21
|
const getProjectUsage = (appDirectory, distDirectory) => {
|
|
20
22
|
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
|
21
23
|
const { routes } = fse.readJSONSync(routeJSON);
|
|
@@ -11,8 +11,9 @@ export declare const serverAppContenxtTemplate: (appContext: IAppContext) => {
|
|
|
11
11
|
lambdaDirectory: string;
|
|
12
12
|
metaName: string;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
15
|
-
export declare const genPluginImportsCode: (plugins:
|
|
14
|
+
export type PluginItem = [string, Record<string, any> | undefined];
|
|
15
|
+
export declare const genPluginImportsCode: (plugins: PluginItem[]) => string;
|
|
16
|
+
export declare const getPluginsCode: (plugins: PluginItem[]) => string;
|
|
16
17
|
export declare const getProjectUsage: (appDirectory: string, distDirectory: string) => {
|
|
17
18
|
useSSR: boolean;
|
|
18
19
|
useAPI: boolean;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.60.
|
|
18
|
+
"version": "2.60.2",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@babel/parser": "^7.22.15",
|
|
78
78
|
"@babel/traverse": "^7.23.2",
|
|
79
79
|
"@babel/types": "^7.24.7",
|
|
80
|
-
"@rsbuild/core": "1.0.
|
|
80
|
+
"@rsbuild/core": "1.0.7",
|
|
81
81
|
"@rsbuild/plugin-node-polyfill": "1.0.4",
|
|
82
82
|
"@swc/helpers": "0.5.13",
|
|
83
83
|
"@vercel/nft": "^0.26.4",
|
|
@@ -88,23 +88,23 @@
|
|
|
88
88
|
"mlly": "^1.6.1",
|
|
89
89
|
"pkg-types": "^1.1.0",
|
|
90
90
|
"std-env": "^3.7.0",
|
|
91
|
-
"@modern-js/core": "2.60.
|
|
92
|
-
"@modern-js/
|
|
93
|
-
"@modern-js/
|
|
94
|
-
"@modern-js/plugin-
|
|
95
|
-
"@modern-js/plugin-
|
|
96
|
-
"@modern-js/
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/server": "2.60.
|
|
99
|
-
"@modern-js/server
|
|
100
|
-
"@modern-js/
|
|
101
|
-
"@modern-js/
|
|
102
|
-
"@modern-js/
|
|
103
|
-
"@modern-js/utils": "2.60.
|
|
91
|
+
"@modern-js/core": "2.60.2",
|
|
92
|
+
"@modern-js/node-bundle-require": "2.60.2",
|
|
93
|
+
"@modern-js/plugin": "2.60.2",
|
|
94
|
+
"@modern-js/plugin-i18n": "2.60.2",
|
|
95
|
+
"@modern-js/plugin-data-loader": "2.60.2",
|
|
96
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.60.2",
|
|
97
|
+
"@modern-js/prod-server": "2.60.2",
|
|
98
|
+
"@modern-js/server-core": "2.60.2",
|
|
99
|
+
"@modern-js/server": "2.60.2",
|
|
100
|
+
"@modern-js/uni-builder": "2.60.2",
|
|
101
|
+
"@modern-js/types": "2.60.2",
|
|
102
|
+
"@modern-js/utils": "2.60.2",
|
|
103
|
+
"@modern-js/server-utils": "2.60.2"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@rsbuild/plugin-webpack-swc": "1.0.
|
|
107
|
-
"@types/babel__traverse": "7.
|
|
106
|
+
"@rsbuild/plugin-webpack-swc": "1.0.3",
|
|
107
|
+
"@types/babel__traverse": "7.20.6",
|
|
108
108
|
"@types/jest": "^29",
|
|
109
109
|
"@types/node": "^16",
|
|
110
110
|
"jest": "^29",
|
|
@@ -112,8 +112,20 @@
|
|
|
112
112
|
"tsconfig-paths": "^4.2.0",
|
|
113
113
|
"typescript": "^5",
|
|
114
114
|
"webpack": "^5.94.0",
|
|
115
|
-
"@scripts/
|
|
116
|
-
"@scripts/
|
|
115
|
+
"@scripts/build": "2.60.2",
|
|
116
|
+
"@scripts/jest-config": "2.60.2"
|
|
117
|
+
},
|
|
118
|
+
"peerDependencies": {
|
|
119
|
+
"ts-node": "^10.7.0",
|
|
120
|
+
"tsconfig-paths": "^4.2.0"
|
|
121
|
+
},
|
|
122
|
+
"peerDependenciesMeta": {
|
|
123
|
+
"ts-node": {
|
|
124
|
+
"optional": true
|
|
125
|
+
},
|
|
126
|
+
"tsconfig-paths": {
|
|
127
|
+
"optional": true
|
|
128
|
+
}
|
|
117
129
|
},
|
|
118
130
|
"sideEffects": false,
|
|
119
131
|
"publishConfig": {
|