@modern-js/app-tools 2.49.1-alpha.5 → 2.49.1-alpha.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/plugins/deploy/entrys/vercel.js +3 -1
- package/dist/cjs/plugins/deploy/index.js +8 -8
- package/dist/esm/plugins/deploy/entrys/vercel.js +1 -1
- package/dist/esm/plugins/deploy/index.js +51 -41
- package/dist/esm-node/plugins/deploy/entrys/vercel.js +3 -1
- package/dist/esm-node/plugins/deploy/index.js +8 -8
- package/package.json +8 -8
@@ -67,7 +67,9 @@ function genVercelEntry({ config, plugins, appContext } = {}) {
|
|
67
67
|
disableCustomHook: true
|
68
68
|
}
|
69
69
|
|
70
|
-
|
70
|
+
const app = await createProdServer(prodServerOptions)
|
71
|
+
|
72
|
+
requestHandler = app.getRequestListener();
|
71
73
|
|
72
74
|
return requestHandler;
|
73
75
|
} catch(error) {
|
@@ -42,9 +42,9 @@ var deploy_default = () => ({
|
|
42
42
|
"@modern-js/plugin-server"
|
43
43
|
],
|
44
44
|
setup: (api) => {
|
45
|
+
const deployTarget = process.env.MODERNJS_DEPLOY || "node";
|
45
46
|
return {
|
46
47
|
async beforeDeploy() {
|
47
|
-
const deployTarget = process.env.MODERNJS_DEPLOY || "node";
|
48
48
|
const appContext = api.useAppContext();
|
49
49
|
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
|
50
50
|
const configContext = api.useResolvedConfigContext();
|
@@ -53,17 +53,17 @@ var deploy_default = () => ({
|
|
53
53
|
let staticDirectory = import_path.default.join(outputDirectory, "static");
|
54
54
|
await import_utils.fs.remove(outputDirectory);
|
55
55
|
if (deployTarget === "node") {
|
56
|
-
await import_utils.fs.copy(distDirectory, outputDirectory
|
57
|
-
filter: (src) => {
|
58
|
-
const distStaticDirectory = import_path.default.join(distDirectory, "static");
|
59
|
-
return !src.includes(distStaticDirectory);
|
60
|
-
}
|
61
|
-
});
|
56
|
+
await import_utils.fs.copy(distDirectory, outputDirectory);
|
62
57
|
}
|
63
58
|
if (deployTarget === "vercel") {
|
64
59
|
outputDirectory = import_path.default.join(appDirectory, ".vercel/output");
|
60
|
+
const config2 = {
|
61
|
+
version: 3
|
62
|
+
};
|
63
|
+
await import_utils.fs.ensureDir(outputDirectory);
|
64
|
+
await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config2);
|
65
65
|
funcsDirectory = import_path.default.join(outputDirectory, "functions", "index.func");
|
66
|
-
staticDirectory = import_path.default.join(outputDirectory, "static");
|
66
|
+
staticDirectory = import_path.default.join(outputDirectory, "static/static");
|
67
67
|
await import_utils.fs.ensureDir(funcsDirectory);
|
68
68
|
await import_utils.fs.copy(distDirectory, funcsDirectory, {
|
69
69
|
filter: (src) => {
|
@@ -33,7 +33,7 @@ function genVercelEntry() {
|
|
33
33
|
const prodServerOptions = {
|
34
34
|
pwd: __dirname,
|
35
35
|
routes,
|
36
|
-
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
|
36
|
+
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 ");
|
37
37
|
}
|
38
38
|
export {
|
39
39
|
genVercelEntry
|
@@ -12,14 +12,14 @@ function deploy_default() {
|
|
12
12
|
"@modern-js/plugin-server"
|
13
13
|
],
|
14
14
|
setup: function(api) {
|
15
|
+
var deployTarget = process.env.MODERNJS_DEPLOY || "node";
|
15
16
|
return {
|
16
17
|
beforeDeploy: function beforeDeploy() {
|
17
18
|
return _async_to_generator(function() {
|
18
|
-
var
|
19
|
+
var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, configContext, outputDirectory, funcsDirectory, staticDirectory, config, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, _getProjectUsage, useSSR, useAPI, useWebServer, entryFilePath;
|
19
20
|
return _ts_generator(this, function(_state) {
|
20
21
|
switch (_state.label) {
|
21
22
|
case 0:
|
22
|
-
deployTarget = process.env.MODERNJS_DEPLOY || "node";
|
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
25
|
configContext = api.useResolvedConfigContext();
|
@@ -39,12 +39,7 @@ function deploy_default() {
|
|
39
39
|
];
|
40
40
|
return [
|
41
41
|
4,
|
42
|
-
fse.copy(distDirectory, outputDirectory
|
43
|
-
filter: function(src) {
|
44
|
-
var distStaticDirectory = path.join(distDirectory, "static");
|
45
|
-
return !src.includes(distStaticDirectory);
|
46
|
-
}
|
47
|
-
})
|
42
|
+
fse.copy(distDirectory, outputDirectory)
|
48
43
|
];
|
49
44
|
case 2:
|
50
45
|
_state.sent();
|
@@ -53,16 +48,31 @@ function deploy_default() {
|
|
53
48
|
if (!(deployTarget === "vercel"))
|
54
49
|
return [
|
55
50
|
3,
|
56
|
-
|
51
|
+
10
|
57
52
|
];
|
58
53
|
outputDirectory = path.join(appDirectory, ".vercel/output");
|
54
|
+
config = {
|
55
|
+
version: 3
|
56
|
+
};
|
57
|
+
return [
|
58
|
+
4,
|
59
|
+
fse.ensureDir(outputDirectory)
|
60
|
+
];
|
61
|
+
case 4:
|
62
|
+
_state.sent();
|
63
|
+
return [
|
64
|
+
4,
|
65
|
+
fse.writeJSON(path.join(outputDirectory, "config.json"), config)
|
66
|
+
];
|
67
|
+
case 5:
|
68
|
+
_state.sent();
|
59
69
|
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
60
|
-
staticDirectory = path.join(outputDirectory, "static");
|
70
|
+
staticDirectory = path.join(outputDirectory, "static/static");
|
61
71
|
return [
|
62
72
|
4,
|
63
73
|
fse.ensureDir(funcsDirectory)
|
64
74
|
];
|
65
|
-
case
|
75
|
+
case 6:
|
66
76
|
_state.sent();
|
67
77
|
return [
|
68
78
|
4,
|
@@ -73,13 +83,13 @@ function deploy_default() {
|
|
73
83
|
}
|
74
84
|
})
|
75
85
|
];
|
76
|
-
case
|
86
|
+
case 7:
|
77
87
|
_state.sent();
|
78
88
|
return [
|
79
89
|
4,
|
80
90
|
fse.copy(path.join(distDirectory, "static"), staticDirectory)
|
81
91
|
];
|
82
|
-
case
|
92
|
+
case 8:
|
83
93
|
_state.sent();
|
84
94
|
return [
|
85
95
|
4,
|
@@ -91,12 +101,12 @@ function deploy_default() {
|
|
91
101
|
supportsResponseStreaming: true
|
92
102
|
})
|
93
103
|
];
|
94
|
-
case
|
104
|
+
case 9:
|
95
105
|
_state.sent();
|
96
|
-
_state.label =
|
97
|
-
case
|
106
|
+
_state.label = 10;
|
107
|
+
case 10:
|
98
108
|
bff = configContext.bff;
|
99
|
-
|
109
|
+
config1 = {
|
100
110
|
output: {
|
101
111
|
path: "."
|
102
112
|
},
|
@@ -115,99 +125,99 @@ function deploy_default() {
|
|
115
125
|
case "node":
|
116
126
|
return [
|
117
127
|
3,
|
118
|
-
|
128
|
+
11
|
119
129
|
];
|
120
130
|
case "vercel":
|
121
131
|
return [
|
122
132
|
3,
|
123
|
-
|
133
|
+
13
|
124
134
|
];
|
125
135
|
case "netlify":
|
126
136
|
return [
|
127
137
|
3,
|
128
|
-
|
138
|
+
15
|
129
139
|
];
|
130
140
|
}
|
131
141
|
return [
|
132
142
|
3,
|
133
|
-
|
143
|
+
17
|
134
144
|
];
|
135
|
-
case
|
145
|
+
case 11:
|
136
146
|
return [
|
137
147
|
4,
|
138
148
|
import("./entrys/node")
|
139
149
|
];
|
140
|
-
case
|
150
|
+
case 12:
|
141
151
|
genNodeEntry = _state.sent().genNodeEntry;
|
142
152
|
code = genNodeEntry({
|
143
153
|
plugins,
|
144
|
-
config,
|
154
|
+
config: config1,
|
145
155
|
appContext: serverAppContext
|
146
156
|
});
|
147
157
|
return [
|
148
158
|
3,
|
149
|
-
|
159
|
+
18
|
150
160
|
];
|
151
|
-
case
|
161
|
+
case 13:
|
152
162
|
return [
|
153
163
|
4,
|
154
164
|
import("./entrys/vercel")
|
155
165
|
];
|
156
|
-
case
|
166
|
+
case 14:
|
157
167
|
genVercelEntry = _state.sent().genVercelEntry;
|
158
168
|
code = genVercelEntry({
|
159
169
|
plugins,
|
160
|
-
config,
|
170
|
+
config: config1,
|
161
171
|
appContext: serverAppContext
|
162
172
|
});
|
163
173
|
return [
|
164
174
|
3,
|
165
|
-
|
175
|
+
18
|
166
176
|
];
|
167
|
-
case
|
177
|
+
case 15:
|
168
178
|
return [
|
169
179
|
4,
|
170
180
|
import("./entrys/netlify")
|
171
181
|
];
|
172
|
-
case
|
182
|
+
case 16:
|
173
183
|
genNetlifyEntry = _state.sent().genNetlifyEntry;
|
174
184
|
code = genNetlifyEntry({
|
175
185
|
plugins,
|
176
|
-
config,
|
186
|
+
config: config1,
|
177
187
|
appContext: serverAppContext
|
178
188
|
});
|
179
189
|
return [
|
180
190
|
3,
|
181
|
-
|
191
|
+
18
|
182
192
|
];
|
183
|
-
case
|
193
|
+
case 17:
|
184
194
|
{
|
185
195
|
code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
|
186
196
|
}
|
187
|
-
_state.label =
|
188
|
-
case
|
197
|
+
_state.label = 18;
|
198
|
+
case 18:
|
189
199
|
_getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
|
190
200
|
entryFilePath = path.join(funcsDirectory, "index.js");
|
191
201
|
if (!(useSSR || useAPI || useWebServer))
|
192
202
|
return [
|
193
203
|
3,
|
194
|
-
|
204
|
+
20
|
195
205
|
];
|
196
206
|
return [
|
197
207
|
4,
|
198
208
|
fse.writeFile(entryFilePath, code)
|
199
209
|
];
|
200
|
-
case
|
210
|
+
case 19:
|
201
211
|
_state.sent();
|
202
|
-
_state.label =
|
203
|
-
case
|
212
|
+
_state.label = 20;
|
213
|
+
case 20:
|
204
214
|
return [
|
205
215
|
4,
|
206
216
|
handleDependencies(appDirectory, funcsDirectory, [
|
207
217
|
"@modern-js/prod-server"
|
208
218
|
])
|
209
219
|
];
|
210
|
-
case
|
220
|
+
case 21:
|
211
221
|
_state.sent();
|
212
222
|
return [
|
213
223
|
2
|
@@ -44,7 +44,9 @@ function genVercelEntry({ config, plugins, appContext } = {}) {
|
|
44
44
|
disableCustomHook: true
|
45
45
|
}
|
46
46
|
|
47
|
-
|
47
|
+
const app = await createProdServer(prodServerOptions)
|
48
|
+
|
49
|
+
requestHandler = app.getRequestListener();
|
48
50
|
|
49
51
|
return requestHandler;
|
50
52
|
} catch(error) {
|
@@ -9,9 +9,9 @@ var deploy_default = () => ({
|
|
9
9
|
"@modern-js/plugin-server"
|
10
10
|
],
|
11
11
|
setup: (api) => {
|
12
|
+
const deployTarget = process.env.MODERNJS_DEPLOY || "node";
|
12
13
|
return {
|
13
14
|
async beforeDeploy() {
|
14
|
-
const deployTarget = process.env.MODERNJS_DEPLOY || "node";
|
15
15
|
const appContext = api.useAppContext();
|
16
16
|
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
|
17
17
|
const configContext = api.useResolvedConfigContext();
|
@@ -20,17 +20,17 @@ var deploy_default = () => ({
|
|
20
20
|
let staticDirectory = path.join(outputDirectory, "static");
|
21
21
|
await fse.remove(outputDirectory);
|
22
22
|
if (deployTarget === "node") {
|
23
|
-
await fse.copy(distDirectory, outputDirectory
|
24
|
-
filter: (src) => {
|
25
|
-
const distStaticDirectory = path.join(distDirectory, "static");
|
26
|
-
return !src.includes(distStaticDirectory);
|
27
|
-
}
|
28
|
-
});
|
23
|
+
await fse.copy(distDirectory, outputDirectory);
|
29
24
|
}
|
30
25
|
if (deployTarget === "vercel") {
|
31
26
|
outputDirectory = path.join(appDirectory, ".vercel/output");
|
27
|
+
const config2 = {
|
28
|
+
version: 3
|
29
|
+
};
|
30
|
+
await fse.ensureDir(outputDirectory);
|
31
|
+
await fse.writeJSON(path.join(outputDirectory, "config.json"), config2);
|
32
32
|
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
33
|
-
staticDirectory = path.join(outputDirectory, "static");
|
33
|
+
staticDirectory = path.join(outputDirectory, "static/static");
|
34
34
|
await fse.ensureDir(funcsDirectory);
|
35
35
|
await fse.copy(distDirectory, funcsDirectory, {
|
36
36
|
filter: (src) => {
|
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.7",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -79,20 +79,20 @@
|
|
79
79
|
"esbuild-register": "^3.5.0",
|
80
80
|
"mlly": "^1.6.1",
|
81
81
|
"pkg-types": "^1.1.0",
|
82
|
-
"@modern-js/plugin": "2.49.0",
|
83
82
|
"@modern-js/core": "2.49.0",
|
84
|
-
"@modern-js/plugin
|
83
|
+
"@modern-js/plugin": "2.49.0",
|
85
84
|
"@modern-js/node-bundle-require": "2.49.0",
|
85
|
+
"@modern-js/plugin-i18n": "2.49.0",
|
86
86
|
"@modern-js/plugin-lint": "2.49.0",
|
87
87
|
"@modern-js/prod-server": "2.49.0",
|
88
|
-
"@modern-js/rsbuild-plugin-esbuild": "2.49.1",
|
89
|
-
"@modern-js/server": "2.49.0",
|
90
88
|
"@modern-js/server-core": "2.49.0",
|
91
89
|
"@modern-js/server-utils": "2.49.0",
|
92
|
-
"@modern-js/uni-builder": "2.49.0",
|
93
|
-
"@modern-js/utils": "2.49.0",
|
94
90
|
"@modern-js/types": "2.49.0",
|
95
|
-
"@modern-js/
|
91
|
+
"@modern-js/utils": "2.49.0",
|
92
|
+
"@modern-js/server": "2.49.0",
|
93
|
+
"@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"
|
96
96
|
},
|
97
97
|
"devDependencies": {
|
98
98
|
"@rsbuild/plugin-swc": "0.6.4",
|