@modern-js/app-tools 2.49.1-alpha.7 → 2.49.1-alpha.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/plugins/deploy/dependencies.js +10 -11
- package/dist/cjs/plugins/deploy/index.js +47 -23
- package/dist/esm/plugins/deploy/dependencies.js +12 -13
- package/dist/esm/plugins/deploy/index.js +77 -45
- package/dist/esm-node/plugins/deploy/dependencies.js +11 -12
- package/dist/esm-node/plugins/deploy/index.js +47 -23
- package/package.json +8 -8
@@ -214,18 +214,17 @@ const handleDependencies = async (appDir, serverRootDir, include) => {
|
|
214
214
|
}));
|
215
215
|
console.log("multiVersionPkgs111111111", multiVersionPkgs);
|
216
216
|
for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
|
217
|
-
const versionEntires = Object.entries(pkgVersions).sort(
|
218
|
-
|
219
|
-
|
220
|
-
([v1, p1], [v2, p2]) => {
|
221
|
-
if (p1.length === 0) {
|
222
|
-
return -1;
|
223
|
-
}
|
224
|
-
if (p2.length === 0) {
|
225
|
-
return 1;
|
226
|
-
}
|
217
|
+
const versionEntires = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
|
218
|
+
if (p1.length === 0) {
|
219
|
+
return -1;
|
227
220
|
}
|
228
|
-
|
221
|
+
if (p2.length === 0) {
|
222
|
+
return 1;
|
223
|
+
}
|
224
|
+
return import_utils.semver.lt(v1, v2, {
|
225
|
+
loose: true
|
226
|
+
}) ? 1 : -1;
|
227
|
+
});
|
229
228
|
for (const [version, parentPkgs] of versionEntires) {
|
230
229
|
const pkg = tracedPackages[pkgName];
|
231
230
|
const pkgDestPath = `.modernjs/${pkgName}@${version}/node_modules/${pkgName}`;
|
@@ -47,38 +47,63 @@ var deploy_default = () => ({
|
|
47
47
|
async beforeDeploy() {
|
48
48
|
const appContext = api.useAppContext();
|
49
49
|
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
|
50
|
+
const { useSSR, useAPI, useWebServer } = (0, import_utils2.getProjectUsage)(appDirectory, distDirectory);
|
51
|
+
const needModernServer = useSSR || useAPI || useWebServer;
|
50
52
|
const configContext = api.useResolvedConfigContext();
|
51
53
|
let outputDirectory = import_path.default.join(appDirectory, ".output");
|
52
54
|
let funcsDirectory = outputDirectory;
|
53
55
|
let staticDirectory = import_path.default.join(outputDirectory, "static");
|
54
|
-
await import_utils.fs.remove(outputDirectory);
|
55
56
|
if (deployTarget === "node") {
|
57
|
+
await import_utils.fs.remove(outputDirectory);
|
56
58
|
await import_utils.fs.copy(distDirectory, outputDirectory);
|
57
59
|
}
|
58
60
|
if (deployTarget === "vercel") {
|
59
|
-
|
61
|
+
const vercelOutput = import_path.default.join(appDirectory, ".vercel");
|
62
|
+
await import_utils.fs.remove(vercelOutput);
|
63
|
+
outputDirectory = import_path.default.join(vercelOutput, "output");
|
60
64
|
const config2 = {
|
61
|
-
version: 3
|
65
|
+
version: 3,
|
66
|
+
routes: [
|
67
|
+
{
|
68
|
+
src: "/static/(.*)",
|
69
|
+
headers: {
|
70
|
+
"cache-control": "s-maxage=31536000, immutable"
|
71
|
+
},
|
72
|
+
continue: true
|
73
|
+
},
|
74
|
+
{
|
75
|
+
handle: "filesystem"
|
76
|
+
},
|
77
|
+
{
|
78
|
+
src: "/(.*)",
|
79
|
+
headers: {
|
80
|
+
"cache-control": "s-maxage=0"
|
81
|
+
},
|
82
|
+
dest: "/html/main/index.html"
|
83
|
+
}
|
84
|
+
]
|
62
85
|
};
|
63
86
|
await import_utils.fs.ensureDir(outputDirectory);
|
64
87
|
await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config2);
|
65
|
-
funcsDirectory = import_path.default.join(outputDirectory, "functions", "index.func");
|
66
88
|
staticDirectory = import_path.default.join(outputDirectory, "static/static");
|
67
|
-
await import_utils.fs.ensureDir(funcsDirectory);
|
68
|
-
await import_utils.fs.copy(distDirectory, funcsDirectory, {
|
69
|
-
filter: (src) => {
|
70
|
-
const distStaticDirectory = import_path.default.join(distDirectory, "static");
|
71
|
-
return !src.includes(distStaticDirectory);
|
72
|
-
}
|
73
|
-
});
|
74
89
|
await import_utils.fs.copy(import_path.default.join(distDirectory, "static"), staticDirectory);
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
90
|
+
if (needModernServer) {
|
91
|
+
funcsDirectory = import_path.default.join(outputDirectory, "functions", "index.func");
|
92
|
+
await import_utils.fs.ensureDir(funcsDirectory);
|
93
|
+
await import_utils.fs.copy(distDirectory, funcsDirectory, {
|
94
|
+
filter: (src) => {
|
95
|
+
const distStaticDirectory = import_path.default.join(distDirectory, "static");
|
96
|
+
return !src.includes(distStaticDirectory);
|
97
|
+
}
|
98
|
+
});
|
99
|
+
await import_utils.fs.writeJSON(import_path.default.join(funcsDirectory, ".vc-config.json"), {
|
100
|
+
runtime: "nodejs16.x",
|
101
|
+
handler: "index.js",
|
102
|
+
launcherType: "Nodejs",
|
103
|
+
shouldAddHelpers: false,
|
104
|
+
supportsResponseStreaming: true
|
105
|
+
});
|
106
|
+
}
|
82
107
|
}
|
83
108
|
const { bff } = configContext;
|
84
109
|
const config = {
|
@@ -128,14 +153,13 @@ var deploy_default = () => ({
|
|
128
153
|
code = `throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");`;
|
129
154
|
}
|
130
155
|
}
|
131
|
-
const { useSSR, useAPI, useWebServer } = (0, import_utils2.getProjectUsage)(appDirectory, distDirectory);
|
132
156
|
const entryFilePath = import_path.default.join(funcsDirectory, "index.js");
|
133
|
-
if (
|
157
|
+
if (needModernServer) {
|
134
158
|
await import_utils.fs.writeFile(entryFilePath, code);
|
159
|
+
await (0, import_dependencies.handleDependencies)(appDirectory, funcsDirectory, [
|
160
|
+
"@modern-js/prod-server"
|
161
|
+
]);
|
135
162
|
}
|
136
|
-
await (0, import_dependencies.handleDependencies)(appDirectory, funcsDirectory, [
|
137
|
-
"@modern-js/prod-server"
|
138
|
-
]);
|
139
163
|
}
|
140
164
|
};
|
141
165
|
}
|
@@ -5,7 +5,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
5
|
import { _ as _ts_values } from "@swc/helpers/_/_ts_values";
|
6
6
|
import path, { isAbsolute } from "node:path";
|
7
7
|
import { nodeFileTrace, resolve } from "@vercel/nft";
|
8
|
-
import { fs as fse, pkgUp } from "@modern-js/utils";
|
8
|
+
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
9
9
|
import { readPackageJSON } from "pkg-types";
|
10
10
|
import { parseNodeModulePath } from "mlly";
|
11
11
|
import { linkPackage, writePackage } from "./utils";
|
@@ -493,19 +493,18 @@ var handleDependencies = function() {
|
|
493
493
|
switch (_state2.label) {
|
494
494
|
case 0:
|
495
495
|
_step_value = _sliced_to_array(_step3.value, 2), pkgName2 = _step_value[0], pkgVersions = _step_value[1];
|
496
|
-
versionEntires = Object.entries(pkgVersions).sort(
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
var _param = _sliced_to_array(param, 2), v1 = _param[0], p1 = _param[1], _param1 = _sliced_to_array(param1, 2), v2 = _param1[0], p2 = _param1[1];
|
501
|
-
if (p1.length === 0) {
|
502
|
-
return -1;
|
503
|
-
}
|
504
|
-
if (p2.length === 0) {
|
505
|
-
return 1;
|
506
|
-
}
|
496
|
+
versionEntires = Object.entries(pkgVersions).sort(function(param, param1) {
|
497
|
+
var _param = _sliced_to_array(param, 2), v1 = _param[0], p1 = _param[1], _param1 = _sliced_to_array(param1, 2), v2 = _param1[0], p2 = _param1[1];
|
498
|
+
if (p1.length === 0) {
|
499
|
+
return -1;
|
507
500
|
}
|
508
|
-
|
501
|
+
if (p2.length === 0) {
|
502
|
+
return 1;
|
503
|
+
}
|
504
|
+
return semver.lt(v1, v2, {
|
505
|
+
loose: true
|
506
|
+
}) ? 1 : -1;
|
507
|
+
});
|
509
508
|
_iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
|
510
509
|
_state2.label = 1;
|
511
510
|
case 1:
|
@@ -16,27 +16,29 @@ function deploy_default() {
|
|
16
16
|
return {
|
17
17
|
beforeDeploy: function beforeDeploy() {
|
18
18
|
return _async_to_generator(function() {
|
19
|
-
var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, configContext, outputDirectory, funcsDirectory, staticDirectory, config, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry,
|
19
|
+
var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, configContext, outputDirectory, funcsDirectory, staticDirectory, vercelOutput, config, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
|
20
20
|
return _ts_generator(this, function(_state) {
|
21
21
|
switch (_state.label) {
|
22
22
|
case 0:
|
23
23
|
appContext = api.useAppContext();
|
24
24
|
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName;
|
25
|
+
_getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
|
26
|
+
needModernServer = useSSR || useAPI || useWebServer;
|
25
27
|
configContext = api.useResolvedConfigContext();
|
26
28
|
outputDirectory = path.join(appDirectory, ".output");
|
27
29
|
funcsDirectory = outputDirectory;
|
28
30
|
staticDirectory = path.join(outputDirectory, "static");
|
31
|
+
if (!(deployTarget === "node"))
|
32
|
+
return [
|
33
|
+
3,
|
34
|
+
3
|
35
|
+
];
|
29
36
|
return [
|
30
37
|
4,
|
31
38
|
fse.remove(outputDirectory)
|
32
39
|
];
|
33
40
|
case 1:
|
34
41
|
_state.sent();
|
35
|
-
if (!(deployTarget === "node"))
|
36
|
-
return [
|
37
|
-
3,
|
38
|
-
3
|
39
|
-
];
|
40
42
|
return [
|
41
43
|
4,
|
42
44
|
fse.copy(distDirectory, outputDirectory)
|
@@ -48,31 +50,68 @@ function deploy_default() {
|
|
48
50
|
if (!(deployTarget === "vercel"))
|
49
51
|
return [
|
50
52
|
3,
|
51
|
-
|
53
|
+
11
|
52
54
|
];
|
53
|
-
|
55
|
+
vercelOutput = path.join(appDirectory, ".vercel");
|
56
|
+
return [
|
57
|
+
4,
|
58
|
+
fse.remove(vercelOutput)
|
59
|
+
];
|
60
|
+
case 4:
|
61
|
+
_state.sent();
|
62
|
+
outputDirectory = path.join(vercelOutput, "output");
|
54
63
|
config = {
|
55
|
-
version: 3
|
64
|
+
version: 3,
|
65
|
+
routes: [
|
66
|
+
{
|
67
|
+
src: "/static/(.*)",
|
68
|
+
headers: {
|
69
|
+
"cache-control": "s-maxage=31536000, immutable"
|
70
|
+
},
|
71
|
+
continue: true
|
72
|
+
},
|
73
|
+
{
|
74
|
+
handle: "filesystem"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
src: "/(.*)",
|
78
|
+
headers: {
|
79
|
+
"cache-control": "s-maxage=0"
|
80
|
+
},
|
81
|
+
dest: "/html/main/index.html"
|
82
|
+
}
|
83
|
+
]
|
56
84
|
};
|
57
85
|
return [
|
58
86
|
4,
|
59
87
|
fse.ensureDir(outputDirectory)
|
60
88
|
];
|
61
|
-
case
|
89
|
+
case 5:
|
62
90
|
_state.sent();
|
63
91
|
return [
|
64
92
|
4,
|
65
93
|
fse.writeJSON(path.join(outputDirectory, "config.json"), config)
|
66
94
|
];
|
67
|
-
case
|
95
|
+
case 6:
|
68
96
|
_state.sent();
|
69
|
-
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
70
97
|
staticDirectory = path.join(outputDirectory, "static/static");
|
98
|
+
return [
|
99
|
+
4,
|
100
|
+
fse.copy(path.join(distDirectory, "static"), staticDirectory)
|
101
|
+
];
|
102
|
+
case 7:
|
103
|
+
_state.sent();
|
104
|
+
if (!needModernServer)
|
105
|
+
return [
|
106
|
+
3,
|
107
|
+
11
|
108
|
+
];
|
109
|
+
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
71
110
|
return [
|
72
111
|
4,
|
73
112
|
fse.ensureDir(funcsDirectory)
|
74
113
|
];
|
75
|
-
case
|
114
|
+
case 8:
|
76
115
|
_state.sent();
|
77
116
|
return [
|
78
117
|
4,
|
@@ -83,13 +122,7 @@ function deploy_default() {
|
|
83
122
|
}
|
84
123
|
})
|
85
124
|
];
|
86
|
-
case
|
87
|
-
_state.sent();
|
88
|
-
return [
|
89
|
-
4,
|
90
|
-
fse.copy(path.join(distDirectory, "static"), staticDirectory)
|
91
|
-
];
|
92
|
-
case 8:
|
125
|
+
case 9:
|
93
126
|
_state.sent();
|
94
127
|
return [
|
95
128
|
4,
|
@@ -101,10 +134,10 @@ function deploy_default() {
|
|
101
134
|
supportsResponseStreaming: true
|
102
135
|
})
|
103
136
|
];
|
104
|
-
case 9:
|
105
|
-
_state.sent();
|
106
|
-
_state.label = 10;
|
107
137
|
case 10:
|
138
|
+
_state.sent();
|
139
|
+
_state.label = 11;
|
140
|
+
case 11:
|
108
141
|
bff = configContext.bff;
|
109
142
|
config1 = {
|
110
143
|
output: {
|
@@ -125,29 +158,29 @@ function deploy_default() {
|
|
125
158
|
case "node":
|
126
159
|
return [
|
127
160
|
3,
|
128
|
-
|
161
|
+
12
|
129
162
|
];
|
130
163
|
case "vercel":
|
131
164
|
return [
|
132
165
|
3,
|
133
|
-
|
166
|
+
14
|
134
167
|
];
|
135
168
|
case "netlify":
|
136
169
|
return [
|
137
170
|
3,
|
138
|
-
|
171
|
+
16
|
139
172
|
];
|
140
173
|
}
|
141
174
|
return [
|
142
175
|
3,
|
143
|
-
|
176
|
+
18
|
144
177
|
];
|
145
|
-
case
|
178
|
+
case 12:
|
146
179
|
return [
|
147
180
|
4,
|
148
181
|
import("./entrys/node")
|
149
182
|
];
|
150
|
-
case
|
183
|
+
case 13:
|
151
184
|
genNodeEntry = _state.sent().genNodeEntry;
|
152
185
|
code = genNodeEntry({
|
153
186
|
plugins,
|
@@ -156,14 +189,14 @@ function deploy_default() {
|
|
156
189
|
});
|
157
190
|
return [
|
158
191
|
3,
|
159
|
-
|
192
|
+
19
|
160
193
|
];
|
161
|
-
case
|
194
|
+
case 14:
|
162
195
|
return [
|
163
196
|
4,
|
164
197
|
import("./entrys/vercel")
|
165
198
|
];
|
166
|
-
case
|
199
|
+
case 15:
|
167
200
|
genVercelEntry = _state.sent().genVercelEntry;
|
168
201
|
code = genVercelEntry({
|
169
202
|
plugins,
|
@@ -172,14 +205,14 @@ function deploy_default() {
|
|
172
205
|
});
|
173
206
|
return [
|
174
207
|
3,
|
175
|
-
|
208
|
+
19
|
176
209
|
];
|
177
|
-
case
|
210
|
+
case 16:
|
178
211
|
return [
|
179
212
|
4,
|
180
213
|
import("./entrys/netlify")
|
181
214
|
];
|
182
|
-
case
|
215
|
+
case 17:
|
183
216
|
genNetlifyEntry = _state.sent().genNetlifyEntry;
|
184
217
|
code = genNetlifyEntry({
|
185
218
|
plugins,
|
@@ -188,29 +221,26 @@ function deploy_default() {
|
|
188
221
|
});
|
189
222
|
return [
|
190
223
|
3,
|
191
|
-
|
224
|
+
19
|
192
225
|
];
|
193
|
-
case
|
226
|
+
case 18:
|
194
227
|
{
|
195
228
|
code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
|
196
229
|
}
|
197
|
-
_state.label =
|
198
|
-
case
|
199
|
-
_getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
|
230
|
+
_state.label = 19;
|
231
|
+
case 19:
|
200
232
|
entryFilePath = path.join(funcsDirectory, "index.js");
|
201
|
-
if (!
|
233
|
+
if (!needModernServer)
|
202
234
|
return [
|
203
235
|
3,
|
204
|
-
|
236
|
+
22
|
205
237
|
];
|
206
238
|
return [
|
207
239
|
4,
|
208
240
|
fse.writeFile(entryFilePath, code)
|
209
241
|
];
|
210
|
-
case 19:
|
211
|
-
_state.sent();
|
212
|
-
_state.label = 20;
|
213
242
|
case 20:
|
243
|
+
_state.sent();
|
214
244
|
return [
|
215
245
|
4,
|
216
246
|
handleDependencies(appDirectory, funcsDirectory, [
|
@@ -219,6 +249,8 @@ function deploy_default() {
|
|
219
249
|
];
|
220
250
|
case 21:
|
221
251
|
_state.sent();
|
252
|
+
_state.label = 22;
|
253
|
+
case 22:
|
222
254
|
return [
|
223
255
|
2
|
224
256
|
];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import path, { isAbsolute } from "node:path";
|
2
2
|
import { nodeFileTrace, resolve } from "@vercel/nft";
|
3
|
-
import { fs as fse, pkgUp } from "@modern-js/utils";
|
3
|
+
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
4
4
|
import { readPackageJSON } from "pkg-types";
|
5
5
|
import { parseNodeModulePath } from "mlly";
|
6
6
|
import { linkPackage, writePackage } from "./utils";
|
@@ -181,18 +181,17 @@ const handleDependencies = async (appDir, serverRootDir, include) => {
|
|
181
181
|
}));
|
182
182
|
console.log("multiVersionPkgs111111111", multiVersionPkgs);
|
183
183
|
for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
|
184
|
-
const versionEntires = Object.entries(pkgVersions).sort(
|
185
|
-
|
186
|
-
|
187
|
-
([v1, p1], [v2, p2]) => {
|
188
|
-
if (p1.length === 0) {
|
189
|
-
return -1;
|
190
|
-
}
|
191
|
-
if (p2.length === 0) {
|
192
|
-
return 1;
|
193
|
-
}
|
184
|
+
const versionEntires = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
|
185
|
+
if (p1.length === 0) {
|
186
|
+
return -1;
|
194
187
|
}
|
195
|
-
|
188
|
+
if (p2.length === 0) {
|
189
|
+
return 1;
|
190
|
+
}
|
191
|
+
return semver.lt(v1, v2, {
|
192
|
+
loose: true
|
193
|
+
}) ? 1 : -1;
|
194
|
+
});
|
196
195
|
for (const [version, parentPkgs] of versionEntires) {
|
197
196
|
const pkg = tracedPackages[pkgName];
|
198
197
|
const pkgDestPath = `.modernjs/${pkgName}@${version}/node_modules/${pkgName}`;
|
@@ -14,38 +14,63 @@ var deploy_default = () => ({
|
|
14
14
|
async beforeDeploy() {
|
15
15
|
const appContext = api.useAppContext();
|
16
16
|
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
|
17
|
+
const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory);
|
18
|
+
const needModernServer = useSSR || useAPI || useWebServer;
|
17
19
|
const configContext = api.useResolvedConfigContext();
|
18
20
|
let outputDirectory = path.join(appDirectory, ".output");
|
19
21
|
let funcsDirectory = outputDirectory;
|
20
22
|
let staticDirectory = path.join(outputDirectory, "static");
|
21
|
-
await fse.remove(outputDirectory);
|
22
23
|
if (deployTarget === "node") {
|
24
|
+
await fse.remove(outputDirectory);
|
23
25
|
await fse.copy(distDirectory, outputDirectory);
|
24
26
|
}
|
25
27
|
if (deployTarget === "vercel") {
|
26
|
-
|
28
|
+
const vercelOutput = path.join(appDirectory, ".vercel");
|
29
|
+
await fse.remove(vercelOutput);
|
30
|
+
outputDirectory = path.join(vercelOutput, "output");
|
27
31
|
const config2 = {
|
28
|
-
version: 3
|
32
|
+
version: 3,
|
33
|
+
routes: [
|
34
|
+
{
|
35
|
+
src: "/static/(.*)",
|
36
|
+
headers: {
|
37
|
+
"cache-control": "s-maxage=31536000, immutable"
|
38
|
+
},
|
39
|
+
continue: true
|
40
|
+
},
|
41
|
+
{
|
42
|
+
handle: "filesystem"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
src: "/(.*)",
|
46
|
+
headers: {
|
47
|
+
"cache-control": "s-maxage=0"
|
48
|
+
},
|
49
|
+
dest: "/html/main/index.html"
|
50
|
+
}
|
51
|
+
]
|
29
52
|
};
|
30
53
|
await fse.ensureDir(outputDirectory);
|
31
54
|
await fse.writeJSON(path.join(outputDirectory, "config.json"), config2);
|
32
|
-
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
33
55
|
staticDirectory = path.join(outputDirectory, "static/static");
|
34
|
-
await fse.ensureDir(funcsDirectory);
|
35
|
-
await fse.copy(distDirectory, funcsDirectory, {
|
36
|
-
filter: (src) => {
|
37
|
-
const distStaticDirectory = path.join(distDirectory, "static");
|
38
|
-
return !src.includes(distStaticDirectory);
|
39
|
-
}
|
40
|
-
});
|
41
56
|
await fse.copy(path.join(distDirectory, "static"), staticDirectory);
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
57
|
+
if (needModernServer) {
|
58
|
+
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
59
|
+
await fse.ensureDir(funcsDirectory);
|
60
|
+
await fse.copy(distDirectory, funcsDirectory, {
|
61
|
+
filter: (src) => {
|
62
|
+
const distStaticDirectory = path.join(distDirectory, "static");
|
63
|
+
return !src.includes(distStaticDirectory);
|
64
|
+
}
|
65
|
+
});
|
66
|
+
await fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
|
67
|
+
runtime: "nodejs16.x",
|
68
|
+
handler: "index.js",
|
69
|
+
launcherType: "Nodejs",
|
70
|
+
shouldAddHelpers: false,
|
71
|
+
supportsResponseStreaming: true
|
72
|
+
});
|
73
|
+
}
|
49
74
|
}
|
50
75
|
const { bff } = configContext;
|
51
76
|
const config = {
|
@@ -95,14 +120,13 @@ var deploy_default = () => ({
|
|
95
120
|
code = `throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");`;
|
96
121
|
}
|
97
122
|
}
|
98
|
-
const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory);
|
99
123
|
const entryFilePath = path.join(funcsDirectory, "index.js");
|
100
|
-
if (
|
124
|
+
if (needModernServer) {
|
101
125
|
await fse.writeFile(entryFilePath, code);
|
126
|
+
await handleDependencies(appDirectory, funcsDirectory, [
|
127
|
+
"@modern-js/prod-server"
|
128
|
+
]);
|
102
129
|
}
|
103
|
-
await handleDependencies(appDirectory, funcsDirectory, [
|
104
|
-
"@modern-js/prod-server"
|
105
|
-
]);
|
106
130
|
}
|
107
131
|
};
|
108
132
|
}
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.49.1-alpha.
|
18
|
+
"version": "2.49.1-alpha.9",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -80,19 +80,19 @@
|
|
80
80
|
"mlly": "^1.6.1",
|
81
81
|
"pkg-types": "^1.1.0",
|
82
82
|
"@modern-js/core": "2.49.0",
|
83
|
-
"@modern-js/plugin": "2.49.0",
|
84
83
|
"@modern-js/node-bundle-require": "2.49.0",
|
85
|
-
"@modern-js/plugin
|
86
|
-
"@modern-js/plugin-lint": "2.49.0",
|
84
|
+
"@modern-js/plugin": "2.49.0",
|
87
85
|
"@modern-js/prod-server": "2.49.0",
|
86
|
+
"@modern-js/plugin-lint": "2.49.0",
|
87
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.49.1",
|
88
|
+
"@modern-js/server": "2.49.0",
|
88
89
|
"@modern-js/server-core": "2.49.0",
|
90
|
+
"@modern-js/plugin-i18n": "2.49.0",
|
89
91
|
"@modern-js/server-utils": "2.49.0",
|
90
|
-
"@modern-js/types": "2.49.0",
|
91
92
|
"@modern-js/utils": "2.49.0",
|
92
|
-
"@modern-js/
|
93
|
+
"@modern-js/types": "2.49.0",
|
93
94
|
"@modern-js/uni-builder": "2.49.0",
|
94
|
-
"@modern-js/plugin-data-loader": "2.49.0"
|
95
|
-
"@modern-js/rsbuild-plugin-esbuild": "2.49.1"
|
95
|
+
"@modern-js/plugin-data-loader": "2.49.0"
|
96
96
|
},
|
97
97
|
"devDependencies": {
|
98
98
|
"@rsbuild/plugin-swc": "0.6.4",
|