@modern-js/app-tools 2.49.3-alpha.14 → 2.49.3-alpha.16
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/plugins/deploy/dependencies.js +1 -11
- package/dist/cjs/plugins/deploy/index copy.js +216 -0
- package/dist/cjs/plugins/deploy/index.js +17 -168
- package/dist/cjs/plugins/deploy/platforms/netlify.js +112 -64
- package/dist/cjs/plugins/deploy/platforms/netlifyEntry.js +60 -0
- package/dist/cjs/plugins/deploy/platforms/node.js +43 -21
- package/dist/cjs/plugins/deploy/platforms/vercel.js +102 -19
- package/dist/cjs/plugins/deploy/utils.js +22 -8
- package/dist/esm/plugins/deploy/dependencies.js +1 -46
- package/dist/esm/plugins/deploy/index copy.js +367 -0
- package/dist/esm/plugins/deploy/index.js +21 -313
- package/dist/esm/plugins/deploy/platforms/netlify.js +203 -36
- package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +202 -0
- package/dist/esm/plugins/deploy/platforms/node.js +105 -46
- package/dist/esm/plugins/deploy/platforms/vercel.js +203 -43
- package/dist/esm/plugins/deploy/utils.js +55 -3
- package/dist/esm-node/plugins/deploy/dependencies.js +1 -11
- package/dist/esm-node/plugins/deploy/index copy.js +186 -0
- package/dist/esm-node/plugins/deploy/index.js +15 -156
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +103 -65
- package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +68 -0
- package/dist/esm-node/plugins/deploy/platforms/node.js +44 -22
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +103 -20
- package/dist/esm-node/plugins/deploy/utils.js +20 -7
- package/dist/types/plugins/deploy/index copy.d.ts +4 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +2 -5
- package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/node.d.ts +2 -8
- package/dist/types/plugins/deploy/platforms/platform.d.ts +8 -4
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +2 -8
- package/dist/types/plugins/deploy/utils.d.ts +8 -1
- package/package.json +8 -8
@@ -0,0 +1,202 @@
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
4
|
+
};
|
5
|
+
var require_netlifyEntry = __commonJS({
|
6
|
+
"src/plugins/deploy/platforms/netlifyEntry.js"(exports, module) {
|
7
|
+
var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
|
8
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
9
|
+
var _ts_generator = require("@swc/helpers/_/_ts_generator");
|
10
|
+
var fs = require("node:fs/promises");
|
11
|
+
var path = require("node:path");
|
12
|
+
var createNetlifyFunction = require("@modern-js/prod-server/netlify").createNetlifyFunction;
|
13
|
+
p_genPluginImportsCode;
|
14
|
+
if (!process.env.NODE_ENV) {
|
15
|
+
process.env.NODE_ENV = "production";
|
16
|
+
}
|
17
|
+
var requestHandler = null;
|
18
|
+
var handlerCreationPromise = null;
|
19
|
+
function loadRoutes(routeFilepath) {
|
20
|
+
return _loadRoutes.apply(this, arguments);
|
21
|
+
}
|
22
|
+
function _loadRoutes() {
|
23
|
+
_loadRoutes = _async_to_generator._(function(routeFilepath) {
|
24
|
+
var content, routeSpec, error;
|
25
|
+
return _ts_generator._(this, function(_state) {
|
26
|
+
switch (_state.label) {
|
27
|
+
case 0:
|
28
|
+
_state.trys.push([
|
29
|
+
0,
|
30
|
+
3,
|
31
|
+
,
|
32
|
+
4
|
33
|
+
]);
|
34
|
+
return [
|
35
|
+
4,
|
36
|
+
fs.access(routeFilepath)
|
37
|
+
];
|
38
|
+
case 1:
|
39
|
+
_state.sent();
|
40
|
+
return [
|
41
|
+
4,
|
42
|
+
fs.readFile(routeFilepath, "utf-8")
|
43
|
+
];
|
44
|
+
case 2:
|
45
|
+
content = _state.sent();
|
46
|
+
routeSpec = JSON.parse(content);
|
47
|
+
return [
|
48
|
+
2,
|
49
|
+
routeSpec.routes || []
|
50
|
+
];
|
51
|
+
case 3:
|
52
|
+
error = _state.sent();
|
53
|
+
console.warn("route.json not found or invalid, continuing with empty routes.");
|
54
|
+
return [
|
55
|
+
2,
|
56
|
+
[]
|
57
|
+
];
|
58
|
+
case 4:
|
59
|
+
return [
|
60
|
+
2
|
61
|
+
];
|
62
|
+
}
|
63
|
+
});
|
64
|
+
});
|
65
|
+
return _loadRoutes.apply(this, arguments);
|
66
|
+
}
|
67
|
+
function initServer() {
|
68
|
+
return _initServer.apply(this, arguments);
|
69
|
+
}
|
70
|
+
function _initServer() {
|
71
|
+
_initServer = _async_to_generator._(function() {
|
72
|
+
var routeFilepath, routes, dynamicProdOptions, prodServerOptions, app;
|
73
|
+
return _ts_generator._(this, function(_state) {
|
74
|
+
switch (_state.label) {
|
75
|
+
case 0:
|
76
|
+
routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
77
|
+
return [
|
78
|
+
4,
|
79
|
+
loadRoutes(routeFilepath)
|
80
|
+
];
|
81
|
+
case 1:
|
82
|
+
routes = _state.sent();
|
83
|
+
dynamicProdOptions = p_dynamicProdOptions;
|
84
|
+
prodServerOptions = _object_spread._({
|
85
|
+
pwd: __dirname,
|
86
|
+
routes,
|
87
|
+
disableCustomHook: true,
|
88
|
+
appContext: {
|
89
|
+
sharedDirectory: p_sharedDirectory,
|
90
|
+
apiDirectory: p_apiDirectory,
|
91
|
+
lambdaDirectory: p_lambdaDirectory
|
92
|
+
}
|
93
|
+
}, dynamicProdOptions);
|
94
|
+
return [
|
95
|
+
4,
|
96
|
+
createNetlifyFunction(prodServerOptions)
|
97
|
+
];
|
98
|
+
case 2:
|
99
|
+
app = _state.sent();
|
100
|
+
return [
|
101
|
+
2,
|
102
|
+
app.getRequestListener()
|
103
|
+
];
|
104
|
+
}
|
105
|
+
});
|
106
|
+
});
|
107
|
+
return _initServer.apply(this, arguments);
|
108
|
+
}
|
109
|
+
function createHandler() {
|
110
|
+
return _createHandler.apply(this, arguments);
|
111
|
+
}
|
112
|
+
function _createHandler() {
|
113
|
+
_createHandler = _async_to_generator._(function() {
|
114
|
+
return _ts_generator._(this, function(_state) {
|
115
|
+
switch (_state.label) {
|
116
|
+
case 0:
|
117
|
+
if (!handlerCreationPromise) {
|
118
|
+
handlerCreationPromise = _async_to_generator._(function() {
|
119
|
+
var error;
|
120
|
+
return _ts_generator._(this, function(_state2) {
|
121
|
+
switch (_state2.label) {
|
122
|
+
case 0:
|
123
|
+
_state2.trys.push([
|
124
|
+
0,
|
125
|
+
2,
|
126
|
+
,
|
127
|
+
3
|
128
|
+
]);
|
129
|
+
return [
|
130
|
+
4,
|
131
|
+
initServer()
|
132
|
+
];
|
133
|
+
case 1:
|
134
|
+
requestHandler = _state2.sent();
|
135
|
+
return [
|
136
|
+
3,
|
137
|
+
3
|
138
|
+
];
|
139
|
+
case 2:
|
140
|
+
error = _state2.sent();
|
141
|
+
console.error("Error creating server:", error);
|
142
|
+
process.exit(1);
|
143
|
+
return [
|
144
|
+
3,
|
145
|
+
3
|
146
|
+
];
|
147
|
+
case 3:
|
148
|
+
return [
|
149
|
+
2
|
150
|
+
];
|
151
|
+
}
|
152
|
+
});
|
153
|
+
})();
|
154
|
+
}
|
155
|
+
return [
|
156
|
+
4,
|
157
|
+
handlerCreationPromise
|
158
|
+
];
|
159
|
+
case 1:
|
160
|
+
_state.sent();
|
161
|
+
return [
|
162
|
+
2,
|
163
|
+
requestHandler
|
164
|
+
];
|
165
|
+
}
|
166
|
+
});
|
167
|
+
});
|
168
|
+
return _createHandler.apply(this, arguments);
|
169
|
+
}
|
170
|
+
createHandler();
|
171
|
+
module.exports = function() {
|
172
|
+
var _ref = _async_to_generator._(function(request, context) {
|
173
|
+
return _ts_generator._(this, function(_state) {
|
174
|
+
switch (_state.label) {
|
175
|
+
case 0:
|
176
|
+
if (!!requestHandler)
|
177
|
+
return [
|
178
|
+
3,
|
179
|
+
2
|
180
|
+
];
|
181
|
+
return [
|
182
|
+
4,
|
183
|
+
createHandler()
|
184
|
+
];
|
185
|
+
case 1:
|
186
|
+
_state.sent();
|
187
|
+
_state.label = 2;
|
188
|
+
case 2:
|
189
|
+
return [
|
190
|
+
2,
|
191
|
+
requestHandler(request, context)
|
192
|
+
];
|
193
|
+
}
|
194
|
+
});
|
195
|
+
});
|
196
|
+
return function(request, context) {
|
197
|
+
return _ref.apply(this, arguments);
|
198
|
+
};
|
199
|
+
}();
|
200
|
+
}
|
201
|
+
});
|
202
|
+
export default require_netlifyEntry();
|
@@ -1,51 +1,110 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
4
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
|
5
|
+
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
6
|
+
import { handleDependencies } from "../dependencies";
|
7
|
+
var createNodePreset = function(appContext, config, needModernServer) {
|
8
|
+
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
|
9
|
+
var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
10
|
+
var outputDirectory = path.join(appDirectory, ".output");
|
11
|
+
var entryFilePath = path.join(outputDirectory, "index.js");
|
12
|
+
return {
|
13
|
+
prepare: function prepare() {
|
14
|
+
return _async_to_generator(function() {
|
15
|
+
return _ts_generator(this, function(_state) {
|
16
|
+
switch (_state.label) {
|
17
|
+
case 0:
|
18
|
+
return [
|
19
|
+
4,
|
20
|
+
fse.remove(outputDirectory)
|
21
|
+
];
|
22
|
+
case 1:
|
23
|
+
_state.sent();
|
24
|
+
return [
|
25
|
+
2
|
26
|
+
];
|
27
|
+
}
|
28
|
+
});
|
29
|
+
})();
|
30
|
+
},
|
31
|
+
writeOutput: function writeOutput() {
|
32
|
+
return _async_to_generator(function() {
|
33
|
+
return _ts_generator(this, function(_state) {
|
34
|
+
switch (_state.label) {
|
35
|
+
case 0:
|
36
|
+
return [
|
37
|
+
4,
|
38
|
+
fse.copy(distDirectory, outputDirectory)
|
39
|
+
];
|
40
|
+
case 1:
|
41
|
+
_state.sent();
|
42
|
+
return [
|
43
|
+
2
|
44
|
+
];
|
45
|
+
}
|
46
|
+
});
|
47
|
+
})();
|
48
|
+
},
|
49
|
+
genEntry: function genEntry() {
|
50
|
+
return _async_to_generator(function() {
|
51
|
+
var _config_bff, serverConfig, pluginImportCode, dynamicProdOptions, entryCode, serverAppContext;
|
52
|
+
return _ts_generator(this, function(_state) {
|
53
|
+
switch (_state.label) {
|
54
|
+
case 0:
|
55
|
+
if (!needModernServer) {
|
56
|
+
return [
|
57
|
+
2
|
58
|
+
];
|
59
|
+
}
|
60
|
+
serverConfig = {
|
61
|
+
server: {
|
62
|
+
port: 8080
|
63
|
+
},
|
64
|
+
bff: {
|
65
|
+
prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
|
66
|
+
},
|
67
|
+
output: {
|
68
|
+
path: "."
|
69
|
+
}
|
70
|
+
};
|
71
|
+
pluginImportCode = genPluginImportsCode(plugins || []);
|
72
|
+
dynamicProdOptions = {
|
73
|
+
config: serverConfig,
|
74
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
75
|
+
plugins
|
76
|
+
};
|
77
|
+
return [
|
78
|
+
4,
|
79
|
+
fse.readFile(path.join(__dirname, "./nodeEntry.js"))
|
80
|
+
];
|
81
|
+
case 1:
|
82
|
+
entryCode = _state.sent().toString();
|
83
|
+
serverAppContext = serverAppContenxtTemplate(appContext);
|
84
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
85
|
+
return [
|
86
|
+
4,
|
87
|
+
fse.writeFile(entryFilePath, entryCode)
|
88
|
+
];
|
89
|
+
case 2:
|
90
|
+
_state.sent();
|
91
|
+
return [
|
92
|
+
4,
|
93
|
+
handleDependencies(appDirectory, outputDirectory, [
|
94
|
+
"@modern-js/prod-server"
|
95
|
+
])
|
96
|
+
];
|
97
|
+
case 3:
|
98
|
+
_state.sent();
|
99
|
+
return [
|
100
|
+
2
|
101
|
+
];
|
102
|
+
}
|
103
|
+
});
|
104
|
+
})();
|
105
|
+
}
|
106
|
+
};
|
107
|
+
};
|
49
108
|
export {
|
50
|
-
|
109
|
+
createNodePreset
|
51
110
|
};
|
@@ -1,48 +1,208 @@
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
3
|
import path from "node:path";
|
4
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
5
|
-
import {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
4
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
|
5
|
+
import { isMainEntry } from "../../../utils/routes";
|
6
|
+
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
7
|
+
import { handleDependencies } from "../dependencies";
|
8
|
+
var createVercelPreset = function(appContext, config, needModernServer) {
|
9
|
+
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
|
10
|
+
var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
11
|
+
var vercelOutput = path.join(appDirectory, ".vercel");
|
12
|
+
var outputDirectory = path.join(vercelOutput, "output");
|
13
|
+
var funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
14
|
+
var entryFilePath = path.join(funcsDirectory, "index.js");
|
15
|
+
return {
|
16
|
+
prepare: function prepare() {
|
17
|
+
return _async_to_generator(function() {
|
18
|
+
return _ts_generator(this, function(_state) {
|
19
|
+
switch (_state.label) {
|
20
|
+
case 0:
|
21
|
+
return [
|
22
|
+
4,
|
23
|
+
fse.remove(vercelOutput)
|
24
|
+
];
|
25
|
+
case 1:
|
26
|
+
_state.sent();
|
27
|
+
return [
|
28
|
+
2
|
29
|
+
];
|
30
|
+
}
|
31
|
+
});
|
32
|
+
})();
|
33
|
+
},
|
34
|
+
writeOutput: function writeOutput() {
|
35
|
+
return _async_to_generator(function() {
|
36
|
+
var config2, mainEntryName, staticDirectory, destHtmlDirectory, outputHtmlDirectory;
|
37
|
+
return _ts_generator(this, function(_state) {
|
38
|
+
switch (_state.label) {
|
39
|
+
case 0:
|
40
|
+
config2 = {
|
41
|
+
version: 3,
|
42
|
+
routes: [
|
43
|
+
{
|
44
|
+
src: "/static/(.*)",
|
45
|
+
headers: {
|
46
|
+
"cache-control": "s-maxage=31536000, immutable"
|
47
|
+
},
|
48
|
+
continue: true
|
49
|
+
},
|
50
|
+
{
|
51
|
+
handle: "filesystem"
|
52
|
+
}
|
53
|
+
]
|
54
|
+
};
|
55
|
+
if (!needModernServer) {
|
56
|
+
mainEntryName = config2.source.mainEntryName;
|
57
|
+
entrypoints.forEach(function(entry) {
|
58
|
+
var isMain = isMainEntry(entry.entryName, mainEntryName);
|
59
|
+
config2.routes.push({
|
60
|
+
src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
|
61
|
+
headers: {
|
62
|
+
"cache-control": "s-maxage=0"
|
63
|
+
},
|
64
|
+
dest: "/html/".concat(entry.entryName, "/index.html")
|
65
|
+
});
|
66
|
+
});
|
67
|
+
} else {
|
68
|
+
config2.routes.push({
|
69
|
+
src: "/(.*)",
|
70
|
+
dest: "/index"
|
71
|
+
});
|
72
|
+
}
|
73
|
+
return [
|
74
|
+
4,
|
75
|
+
fse.ensureDir(outputDirectory)
|
76
|
+
];
|
77
|
+
case 1:
|
78
|
+
_state.sent();
|
79
|
+
return [
|
80
|
+
4,
|
81
|
+
fse.writeJSON(path.join(outputDirectory, "config.json"), config2, {
|
82
|
+
spaces: 2
|
83
|
+
})
|
84
|
+
];
|
85
|
+
case 2:
|
86
|
+
_state.sent();
|
87
|
+
staticDirectory = path.join(outputDirectory, "static/static");
|
88
|
+
return [
|
89
|
+
4,
|
90
|
+
fse.copy(path.join(distDirectory, "static"), staticDirectory)
|
91
|
+
];
|
92
|
+
case 3:
|
93
|
+
_state.sent();
|
94
|
+
if (!!needModernServer)
|
95
|
+
return [
|
96
|
+
3,
|
97
|
+
5
|
98
|
+
];
|
99
|
+
destHtmlDirectory = path.join(distDirectory, "html");
|
100
|
+
outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
|
101
|
+
return [
|
102
|
+
4,
|
103
|
+
fse.copy(destHtmlDirectory, outputHtmlDirectory)
|
104
|
+
];
|
105
|
+
case 4:
|
106
|
+
_state.sent();
|
107
|
+
return [
|
108
|
+
3,
|
109
|
+
9
|
110
|
+
];
|
111
|
+
case 5:
|
112
|
+
return [
|
113
|
+
4,
|
114
|
+
fse.ensureDir(funcsDirectory)
|
115
|
+
];
|
116
|
+
case 6:
|
117
|
+
_state.sent();
|
118
|
+
return [
|
119
|
+
4,
|
120
|
+
fse.copy(distDirectory, funcsDirectory, {
|
121
|
+
filter: function(src) {
|
122
|
+
var distStaticDirectory = path.join(distDirectory, "static");
|
123
|
+
return !src.includes(distStaticDirectory);
|
124
|
+
}
|
125
|
+
})
|
126
|
+
];
|
127
|
+
case 7:
|
128
|
+
_state.sent();
|
129
|
+
return [
|
130
|
+
4,
|
131
|
+
fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
|
132
|
+
runtime: "nodejs16.x",
|
133
|
+
handler: "index.js",
|
134
|
+
launcherType: "Nodejs",
|
135
|
+
shouldAddHelpers: false,
|
136
|
+
supportsResponseStreaming: true
|
137
|
+
})
|
138
|
+
];
|
139
|
+
case 8:
|
140
|
+
_state.sent();
|
141
|
+
_state.label = 9;
|
142
|
+
case 9:
|
143
|
+
return [
|
144
|
+
2
|
145
|
+
];
|
146
|
+
}
|
147
|
+
});
|
148
|
+
})();
|
149
|
+
},
|
150
|
+
genEntry: function genEntry() {
|
151
|
+
return _async_to_generator(function() {
|
152
|
+
var _config_bff, serverConfig, pluginImportCode, dynamicProdOptions, serverAppContext, entryCode;
|
153
|
+
return _ts_generator(this, function(_state) {
|
154
|
+
switch (_state.label) {
|
155
|
+
case 0:
|
156
|
+
if (!needModernServer) {
|
157
|
+
return [
|
158
|
+
2
|
159
|
+
];
|
160
|
+
}
|
161
|
+
serverConfig = {
|
162
|
+
bff: {
|
163
|
+
prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
|
164
|
+
},
|
165
|
+
output: {
|
166
|
+
path: "."
|
167
|
+
}
|
168
|
+
};
|
169
|
+
pluginImportCode = genPluginImportsCode(plugins || []);
|
170
|
+
dynamicProdOptions = {
|
171
|
+
config: serverConfig,
|
172
|
+
serverConfigFile: DEFAULT_SERVER_CONFIG,
|
173
|
+
plugins
|
174
|
+
};
|
175
|
+
serverAppContext = serverAppContenxtTemplate(appContext);
|
176
|
+
return [
|
177
|
+
4,
|
178
|
+
fse.readFile(path.join(__dirname, "./vercelEntry.js"))
|
179
|
+
];
|
180
|
+
case 1:
|
181
|
+
entryCode = _state.sent().toString();
|
182
|
+
entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
|
183
|
+
return [
|
184
|
+
4,
|
185
|
+
fse.writeFile(entryFilePath, entryCode)
|
186
|
+
];
|
187
|
+
case 2:
|
188
|
+
_state.sent();
|
189
|
+
return [
|
190
|
+
4,
|
191
|
+
handleDependencies(appDirectory, funcsDirectory, [
|
192
|
+
"@modern-js/prod-server"
|
193
|
+
])
|
194
|
+
];
|
195
|
+
case 3:
|
196
|
+
_state.sent();
|
197
|
+
return [
|
198
|
+
2
|
199
|
+
];
|
200
|
+
}
|
201
|
+
});
|
202
|
+
})();
|
203
|
+
}
|
204
|
+
};
|
205
|
+
};
|
46
206
|
export {
|
47
|
-
|
207
|
+
createVercelPreset
|
48
208
|
};
|