@modern-js/app-tools 2.49.3-alpha.15 → 2.49.3-alpha.17
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 -12
- package/dist/cjs/plugins/deploy/index.js +22 -18
- package/dist/cjs/plugins/deploy/platforms/netlify.js +23 -50
- package/dist/cjs/plugins/deploy/platforms/node.js +10 -2
- package/dist/cjs/plugins/deploy/platforms/vercel.js +9 -9
- package/dist/cjs/plugins/deploy/utils.js +12 -0
- package/dist/esm/plugins/deploy/dependencies.js +1 -47
- package/dist/esm/plugins/deploy/index.js +84 -21
- package/dist/esm/plugins/deploy/platforms/netlify.js +31 -77
- package/dist/esm/plugins/deploy/platforms/node.js +20 -3
- package/dist/esm/plugins/deploy/platforms/vercel.js +10 -10
- package/dist/esm/plugins/deploy/utils.js +46 -0
- package/dist/esm-node/plugins/deploy/dependencies.js +1 -12
- package/dist/esm-node/plugins/deploy/index.js +22 -18
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +23 -50
- package/dist/esm-node/plugins/deploy/platforms/node.js +11 -3
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +9 -9
- package/dist/esm-node/plugins/deploy/utils.js +11 -0
- package/dist/types/plugins/deploy/platforms/platform.d.ts +4 -3
- package/dist/types/plugins/deploy/utils.d.ts +1 -0
- package/package.json +7 -7
- package/dist/cjs/plugins/deploy/index copy.js +0 -216
- package/dist/esm/plugins/deploy/index copy.js +0 -367
- package/dist/esm-node/plugins/deploy/index copy.js +0 -186
- package/dist/types/plugins/deploy/index copy.d.ts +0 -4
@@ -99,6 +99,16 @@ const linkPackage = async (from, to, projectRootDir) => {
|
|
99
99
|
console.error("Cannot link", from, "to", to, error);
|
100
100
|
});
|
101
101
|
};
|
102
|
+
const readDirRecursive = async (dir) => {
|
103
|
+
const files = await fse.readdir(dir, {
|
104
|
+
withFileTypes: true
|
105
|
+
});
|
106
|
+
const filesAndDirs = await Promise.all(files.map(async (file) => {
|
107
|
+
const resPath = path.resolve(dir, file.name);
|
108
|
+
return file.isDirectory() ? readDirRecursive(resPath) : resPath;
|
109
|
+
}));
|
110
|
+
return filesAndDirs.flat();
|
111
|
+
};
|
102
112
|
export {
|
103
113
|
applyProductionCondition,
|
104
114
|
applyPublicCondition,
|
@@ -106,6 +116,7 @@ export {
|
|
106
116
|
getPluginsCode,
|
107
117
|
getProjectUsage,
|
108
118
|
linkPackage,
|
119
|
+
readDirRecursive,
|
109
120
|
serverAppContenxtTemplate,
|
110
121
|
writePackage
|
111
122
|
};
|
@@ -2,8 +2,9 @@ import { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
2
2
|
import { AppTools } from '../../../types';
|
3
3
|
export type CreatePreset = (appContext: IAppContext, config: NormalizedConfig<AppTools>, needModernServer?: boolean) => DeployPreset;
|
4
4
|
type DeployPreset = {
|
5
|
-
prepare
|
6
|
-
writeOutput
|
7
|
-
genEntry
|
5
|
+
prepare?: () => Promise<void>;
|
6
|
+
writeOutput?: () => Promise<void>;
|
7
|
+
genEntry?: () => Promise<void>;
|
8
|
+
end?: () => Promise<void>;
|
8
9
|
};
|
9
10
|
export {};
|
@@ -31,3 +31,4 @@ export type TracedPackage = {
|
|
31
31
|
};
|
32
32
|
export declare const writePackage: (pkg: TracedPackage, version: string, projectDir: string, _pkgPath?: string) => Promise<void>;
|
33
33
|
export declare const linkPackage: (from: string, to: string, projectRootDir: string) => Promise<void>;
|
34
|
+
export declare const readDirRecursive: (dir: string) => Promise<string[]>;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.49.3-alpha.
|
18
|
+
"version": "2.49.3-alpha.17",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -82,18 +82,18 @@
|
|
82
82
|
"std-env": "^3.7.0",
|
83
83
|
"@modern-js/core": "2.49.2",
|
84
84
|
"@modern-js/plugin": "2.49.2",
|
85
|
-
"@modern-js/prod-server": "2.49.2",
|
86
|
-
"@modern-js/node-bundle-require": "2.49.2",
|
87
85
|
"@modern-js/plugin-i18n": "2.49.2",
|
86
|
+
"@modern-js/prod-server": "2.49.2",
|
88
87
|
"@modern-js/plugin-lint": "2.49.2",
|
89
88
|
"@modern-js/rsbuild-plugin-esbuild": "2.49.2",
|
89
|
+
"@modern-js/node-bundle-require": "2.49.2",
|
90
|
+
"@modern-js/server-utils": "2.49.2",
|
90
91
|
"@modern-js/server-core": "2.49.2",
|
92
|
+
"@modern-js/plugin-data-loader": "2.49.2",
|
91
93
|
"@modern-js/server": "2.49.2",
|
92
|
-
"@modern-js/server-utils": "2.49.2",
|
93
|
-
"@modern-js/uni-builder": "2.49.2",
|
94
|
-
"@modern-js/utils": "2.49.2",
|
95
94
|
"@modern-js/types": "2.49.2",
|
96
|
-
"@modern-js/
|
95
|
+
"@modern-js/uni-builder": "2.49.2",
|
96
|
+
"@modern-js/utils": "2.49.2"
|
97
97
|
},
|
98
98
|
"devDependencies": {
|
99
99
|
"@rsbuild/plugin-swc": "0.6.10",
|
@@ -1,216 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var index_copy_exports = {};
|
30
|
-
__export(index_copy_exports, {
|
31
|
-
default: () => index_copy_default
|
32
|
-
});
|
33
|
-
module.exports = __toCommonJS(index_copy_exports);
|
34
|
-
var import_path = __toESM(require("path"));
|
35
|
-
var import_utils = require("@modern-js/utils");
|
36
|
-
var import_std_env = require("std-env");
|
37
|
-
var import_routes = require("../../utils/routes");
|
38
|
-
var import_utils2 = require("./utils");
|
39
|
-
var import_dependencies = require("./dependencies");
|
40
|
-
var index_copy_default = () => ({
|
41
|
-
name: "@modern-js/plugin-deploy",
|
42
|
-
pre: [
|
43
|
-
"@modern-js/plugin-bff",
|
44
|
-
"@modern-js/plugin-server"
|
45
|
-
],
|
46
|
-
setup: (api) => {
|
47
|
-
const deployTarget = process.env.MODERNJS_DEPLOY || import_std_env.provider || "node";
|
48
|
-
return {
|
49
|
-
async beforeDeploy() {
|
50
|
-
const appContext = api.useAppContext();
|
51
|
-
const modernConfig = api.useResolvedConfigContext();
|
52
|
-
const { source: { mainEntryName } } = modernConfig;
|
53
|
-
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
|
54
|
-
const { useSSR, useAPI, useWebServer } = (0, import_utils2.getProjectUsage)(appDirectory, distDirectory);
|
55
|
-
const needModernServer = useSSR || useAPI || useWebServer;
|
56
|
-
let outputDirectory = import_path.default.join(appDirectory, ".output");
|
57
|
-
let funcsDirectory = outputDirectory;
|
58
|
-
let staticDirectory = import_path.default.join(outputDirectory, "static");
|
59
|
-
if (deployTarget === "node") {
|
60
|
-
await import_utils.fs.remove(outputDirectory);
|
61
|
-
await import_utils.fs.copy(distDirectory, outputDirectory);
|
62
|
-
}
|
63
|
-
if (deployTarget === "netlify") {
|
64
|
-
const netlifyOutput = import_path.default.join(appDirectory, ".netlify");
|
65
|
-
funcsDirectory = import_path.default.join(netlifyOutput, "functions");
|
66
|
-
const routes = [];
|
67
|
-
if (!needModernServer) {
|
68
|
-
entrypoints.forEach((entry) => {
|
69
|
-
const isMain = (0, import_routes.isMainEntry)(entry.entryName, mainEntryName);
|
70
|
-
routes.push({
|
71
|
-
src: `/${isMain ? "" : `${entry.entryName}/`}*`,
|
72
|
-
dest: `/html/${entry.entryName}/index.html`,
|
73
|
-
status: 200
|
74
|
-
});
|
75
|
-
});
|
76
|
-
} else {
|
77
|
-
routes.push({
|
78
|
-
src: `/*`,
|
79
|
-
dest: `/.netlify/functions/index`,
|
80
|
-
status: 200
|
81
|
-
});
|
82
|
-
throw new Error("Currently on the Netlify platform, only CSR projects are supported, Support for SSR and BFF projects will be available later");
|
83
|
-
}
|
84
|
-
console.log("routes", routes, needModernServer);
|
85
|
-
const redirectContent = routes.map((route) => {
|
86
|
-
return `${route.src} ${route.dest} ${route.status}`;
|
87
|
-
}).join("\n");
|
88
|
-
console.log("redirectContent", redirectContent);
|
89
|
-
await import_utils.fs.remove(outputDirectory);
|
90
|
-
await import_utils.fs.ensureDir(funcsDirectory);
|
91
|
-
await import_utils.fs.copy(distDirectory, funcsDirectory, {
|
92
|
-
filter: (src) => {
|
93
|
-
const distStaticDirectory = import_path.default.join(distDirectory, "static");
|
94
|
-
return !src.includes(distStaticDirectory);
|
95
|
-
}
|
96
|
-
});
|
97
|
-
const redirectFilePath = import_path.default.join(distDirectory, "_redirects");
|
98
|
-
await import_utils.fs.writeFile(redirectFilePath, redirectContent);
|
99
|
-
}
|
100
|
-
if (deployTarget === "vercel") {
|
101
|
-
const vercelOutput = import_path.default.join(appDirectory, ".vercel");
|
102
|
-
await import_utils.fs.remove(vercelOutput);
|
103
|
-
outputDirectory = import_path.default.join(vercelOutput, "output");
|
104
|
-
const config = {
|
105
|
-
version: 3,
|
106
|
-
routes: [
|
107
|
-
{
|
108
|
-
src: "/static/(.*)",
|
109
|
-
headers: {
|
110
|
-
"cache-control": "s-maxage=31536000, immutable"
|
111
|
-
},
|
112
|
-
continue: true
|
113
|
-
},
|
114
|
-
{
|
115
|
-
handle: "filesystem"
|
116
|
-
}
|
117
|
-
]
|
118
|
-
};
|
119
|
-
if (!needModernServer) {
|
120
|
-
entrypoints.forEach((entry) => {
|
121
|
-
const isMain = (0, import_routes.isMainEntry)(entry.entryName, mainEntryName);
|
122
|
-
config.routes.push({
|
123
|
-
src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
|
124
|
-
headers: {
|
125
|
-
"cache-control": "s-maxage=0"
|
126
|
-
},
|
127
|
-
dest: `/html/${entry.entryName}/index.html`
|
128
|
-
});
|
129
|
-
});
|
130
|
-
} else {
|
131
|
-
config.routes.push({
|
132
|
-
src: "/(.*)",
|
133
|
-
dest: `/index`
|
134
|
-
});
|
135
|
-
}
|
136
|
-
await import_utils.fs.ensureDir(outputDirectory);
|
137
|
-
await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config, {
|
138
|
-
spaces: 2
|
139
|
-
});
|
140
|
-
staticDirectory = import_path.default.join(outputDirectory, "static/static");
|
141
|
-
await import_utils.fs.copy(import_path.default.join(distDirectory, "static"), staticDirectory);
|
142
|
-
if (!needModernServer) {
|
143
|
-
const destHtmlDirectory = import_path.default.join(distDirectory, "html");
|
144
|
-
const outputHtmlDirectory = import_path.default.join(import_path.default.join(outputDirectory, "static"), "html");
|
145
|
-
await import_utils.fs.copy(destHtmlDirectory, outputHtmlDirectory);
|
146
|
-
} else {
|
147
|
-
funcsDirectory = import_path.default.join(outputDirectory, "functions", "index.func");
|
148
|
-
await import_utils.fs.ensureDir(funcsDirectory);
|
149
|
-
await import_utils.fs.copy(distDirectory, funcsDirectory, {
|
150
|
-
filter: (src) => {
|
151
|
-
const distStaticDirectory = import_path.default.join(distDirectory, "static");
|
152
|
-
return !src.includes(distStaticDirectory);
|
153
|
-
}
|
154
|
-
});
|
155
|
-
await import_utils.fs.writeJSON(import_path.default.join(funcsDirectory, ".vc-config.json"), {
|
156
|
-
runtime: "nodejs16.x",
|
157
|
-
handler: "index.js",
|
158
|
-
launcherType: "Nodejs",
|
159
|
-
shouldAddHelpers: false,
|
160
|
-
supportsResponseStreaming: true
|
161
|
-
});
|
162
|
-
}
|
163
|
-
}
|
164
|
-
const plugins = (0, import_utils.getInternalPlugins)(appDirectory, serverInternalPlugins);
|
165
|
-
const serverAppContext = {
|
166
|
-
sharedDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, sharedDirectory)}")`,
|
167
|
-
apiDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, apiDirectory)}")`,
|
168
|
-
lambdaDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, lambdaDirectory)}")`,
|
169
|
-
metaName
|
170
|
-
};
|
171
|
-
console.log("serverAppContext", serverAppContext);
|
172
|
-
let code = ``;
|
173
|
-
console.log("deployTarget111111111", deployTarget);
|
174
|
-
switch (deployTarget) {
|
175
|
-
case "node": {
|
176
|
-
const { genNodeEntry } = await Promise.resolve().then(() => __toESM(require("./platforms/node")));
|
177
|
-
code = await genNodeEntry({
|
178
|
-
plugins,
|
179
|
-
config: modernConfig,
|
180
|
-
appContext: serverAppContext
|
181
|
-
});
|
182
|
-
break;
|
183
|
-
}
|
184
|
-
case "vercel": {
|
185
|
-
const { genVercelEntry } = await Promise.resolve().then(() => __toESM(require("./platforms/vercel")));
|
186
|
-
code = await genVercelEntry({
|
187
|
-
plugins,
|
188
|
-
config: modernConfig,
|
189
|
-
appContext: serverAppContext
|
190
|
-
});
|
191
|
-
break;
|
192
|
-
}
|
193
|
-
case "netlify": {
|
194
|
-
const { genNetlifyEntry } = await Promise.resolve().then(() => __toESM(require("./platforms/netlify")));
|
195
|
-
code = await genNetlifyEntry({
|
196
|
-
plugins,
|
197
|
-
config: modernConfig,
|
198
|
-
appContext: serverAppContext
|
199
|
-
});
|
200
|
-
break;
|
201
|
-
}
|
202
|
-
default: {
|
203
|
-
code = `throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");`;
|
204
|
-
}
|
205
|
-
}
|
206
|
-
const entryFilePath = import_path.default.join(funcsDirectory, "index.js");
|
207
|
-
if (needModernServer) {
|
208
|
-
await import_utils.fs.writeFile(entryFilePath, code);
|
209
|
-
await (0, import_dependencies.handleDependencies)(appDirectory, funcsDirectory, [
|
210
|
-
"@modern-js/prod-server"
|
211
|
-
]);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
};
|
215
|
-
}
|
216
|
-
});
|
@@ -1,367 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import path from "path";
|
4
|
-
import { fs as fse, getInternalPlugins } from "@modern-js/utils";
|
5
|
-
import { provider } from "std-env";
|
6
|
-
import { isMainEntry } from "../../utils/routes";
|
7
|
-
import { getProjectUsage } from "./utils";
|
8
|
-
import { handleDependencies } from "./dependencies";
|
9
|
-
function index_copy_default() {
|
10
|
-
return {
|
11
|
-
name: "@modern-js/plugin-deploy",
|
12
|
-
pre: [
|
13
|
-
"@modern-js/plugin-bff",
|
14
|
-
"@modern-js/plugin-server"
|
15
|
-
],
|
16
|
-
setup: function(api) {
|
17
|
-
var deployTarget = process.env.MODERNJS_DEPLOY || provider || "node";
|
18
|
-
return {
|
19
|
-
beforeDeploy: function beforeDeploy() {
|
20
|
-
return _async_to_generator(function() {
|
21
|
-
var appContext, modernConfig, mainEntryName, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, outputDirectory, funcsDirectory, staticDirectory, netlifyOutput, routes, redirectContent, redirectFilePath, vercelOutput, config, destHtmlDirectory, outputHtmlDirectory, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
|
22
|
-
return _ts_generator(this, function(_state) {
|
23
|
-
switch (_state.label) {
|
24
|
-
case 0:
|
25
|
-
appContext = api.useAppContext();
|
26
|
-
modernConfig = api.useResolvedConfigContext();
|
27
|
-
mainEntryName = modernConfig.source.mainEntryName;
|
28
|
-
appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
|
29
|
-
_getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
|
30
|
-
needModernServer = useSSR || useAPI || useWebServer;
|
31
|
-
outputDirectory = path.join(appDirectory, ".output");
|
32
|
-
funcsDirectory = outputDirectory;
|
33
|
-
staticDirectory = path.join(outputDirectory, "static");
|
34
|
-
if (!(deployTarget === "node"))
|
35
|
-
return [
|
36
|
-
3,
|
37
|
-
3
|
38
|
-
];
|
39
|
-
return [
|
40
|
-
4,
|
41
|
-
fse.remove(outputDirectory)
|
42
|
-
];
|
43
|
-
case 1:
|
44
|
-
_state.sent();
|
45
|
-
return [
|
46
|
-
4,
|
47
|
-
fse.copy(distDirectory, outputDirectory)
|
48
|
-
];
|
49
|
-
case 2:
|
50
|
-
_state.sent();
|
51
|
-
_state.label = 3;
|
52
|
-
case 3:
|
53
|
-
if (!(deployTarget === "netlify"))
|
54
|
-
return [
|
55
|
-
3,
|
56
|
-
8
|
57
|
-
];
|
58
|
-
netlifyOutput = path.join(appDirectory, ".netlify");
|
59
|
-
funcsDirectory = path.join(netlifyOutput, "functions");
|
60
|
-
routes = [];
|
61
|
-
if (!needModernServer) {
|
62
|
-
entrypoints.forEach(function(entry) {
|
63
|
-
var isMain = isMainEntry(entry.entryName, mainEntryName);
|
64
|
-
routes.push({
|
65
|
-
src: "/".concat(isMain ? "" : "".concat(entry.entryName, "/"), "*"),
|
66
|
-
dest: "/html/".concat(entry.entryName, "/index.html"),
|
67
|
-
status: 200
|
68
|
-
});
|
69
|
-
});
|
70
|
-
} else {
|
71
|
-
routes.push({
|
72
|
-
src: "/*",
|
73
|
-
dest: "/.netlify/functions/index",
|
74
|
-
status: 200
|
75
|
-
});
|
76
|
-
throw new Error("Currently on the Netlify platform, only CSR projects are supported, Support for SSR and BFF projects will be available later");
|
77
|
-
}
|
78
|
-
console.log("routes", routes, needModernServer);
|
79
|
-
redirectContent = routes.map(function(route) {
|
80
|
-
return "".concat(route.src, " ").concat(route.dest, " ").concat(route.status);
|
81
|
-
}).join("\n");
|
82
|
-
console.log("redirectContent", redirectContent);
|
83
|
-
return [
|
84
|
-
4,
|
85
|
-
fse.remove(outputDirectory)
|
86
|
-
];
|
87
|
-
case 4:
|
88
|
-
_state.sent();
|
89
|
-
return [
|
90
|
-
4,
|
91
|
-
fse.ensureDir(funcsDirectory)
|
92
|
-
];
|
93
|
-
case 5:
|
94
|
-
_state.sent();
|
95
|
-
return [
|
96
|
-
4,
|
97
|
-
fse.copy(distDirectory, funcsDirectory, {
|
98
|
-
filter: function(src) {
|
99
|
-
var distStaticDirectory = path.join(distDirectory, "static");
|
100
|
-
return !src.includes(distStaticDirectory);
|
101
|
-
}
|
102
|
-
})
|
103
|
-
];
|
104
|
-
case 6:
|
105
|
-
_state.sent();
|
106
|
-
redirectFilePath = path.join(distDirectory, "_redirects");
|
107
|
-
return [
|
108
|
-
4,
|
109
|
-
fse.writeFile(redirectFilePath, redirectContent)
|
110
|
-
];
|
111
|
-
case 7:
|
112
|
-
_state.sent();
|
113
|
-
_state.label = 8;
|
114
|
-
case 8:
|
115
|
-
if (!(deployTarget === "vercel"))
|
116
|
-
return [
|
117
|
-
3,
|
118
|
-
18
|
119
|
-
];
|
120
|
-
vercelOutput = path.join(appDirectory, ".vercel");
|
121
|
-
return [
|
122
|
-
4,
|
123
|
-
fse.remove(vercelOutput)
|
124
|
-
];
|
125
|
-
case 9:
|
126
|
-
_state.sent();
|
127
|
-
outputDirectory = path.join(vercelOutput, "output");
|
128
|
-
config = {
|
129
|
-
version: 3,
|
130
|
-
routes: [
|
131
|
-
{
|
132
|
-
src: "/static/(.*)",
|
133
|
-
headers: {
|
134
|
-
"cache-control": "s-maxage=31536000, immutable"
|
135
|
-
},
|
136
|
-
continue: true
|
137
|
-
},
|
138
|
-
{
|
139
|
-
handle: "filesystem"
|
140
|
-
}
|
141
|
-
]
|
142
|
-
};
|
143
|
-
if (!needModernServer) {
|
144
|
-
entrypoints.forEach(function(entry) {
|
145
|
-
var isMain = isMainEntry(entry.entryName, mainEntryName);
|
146
|
-
config.routes.push({
|
147
|
-
src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
|
148
|
-
headers: {
|
149
|
-
"cache-control": "s-maxage=0"
|
150
|
-
},
|
151
|
-
dest: "/html/".concat(entry.entryName, "/index.html")
|
152
|
-
});
|
153
|
-
});
|
154
|
-
} else {
|
155
|
-
config.routes.push({
|
156
|
-
src: "/(.*)",
|
157
|
-
dest: "/index"
|
158
|
-
});
|
159
|
-
}
|
160
|
-
return [
|
161
|
-
4,
|
162
|
-
fse.ensureDir(outputDirectory)
|
163
|
-
];
|
164
|
-
case 10:
|
165
|
-
_state.sent();
|
166
|
-
return [
|
167
|
-
4,
|
168
|
-
fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
|
169
|
-
spaces: 2
|
170
|
-
})
|
171
|
-
];
|
172
|
-
case 11:
|
173
|
-
_state.sent();
|
174
|
-
staticDirectory = path.join(outputDirectory, "static/static");
|
175
|
-
return [
|
176
|
-
4,
|
177
|
-
fse.copy(path.join(distDirectory, "static"), staticDirectory)
|
178
|
-
];
|
179
|
-
case 12:
|
180
|
-
_state.sent();
|
181
|
-
if (!!needModernServer)
|
182
|
-
return [
|
183
|
-
3,
|
184
|
-
14
|
185
|
-
];
|
186
|
-
destHtmlDirectory = path.join(distDirectory, "html");
|
187
|
-
outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
|
188
|
-
return [
|
189
|
-
4,
|
190
|
-
fse.copy(destHtmlDirectory, outputHtmlDirectory)
|
191
|
-
];
|
192
|
-
case 13:
|
193
|
-
_state.sent();
|
194
|
-
return [
|
195
|
-
3,
|
196
|
-
18
|
197
|
-
];
|
198
|
-
case 14:
|
199
|
-
funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
200
|
-
return [
|
201
|
-
4,
|
202
|
-
fse.ensureDir(funcsDirectory)
|
203
|
-
];
|
204
|
-
case 15:
|
205
|
-
_state.sent();
|
206
|
-
return [
|
207
|
-
4,
|
208
|
-
fse.copy(distDirectory, funcsDirectory, {
|
209
|
-
filter: function(src) {
|
210
|
-
var distStaticDirectory = path.join(distDirectory, "static");
|
211
|
-
return !src.includes(distStaticDirectory);
|
212
|
-
}
|
213
|
-
})
|
214
|
-
];
|
215
|
-
case 16:
|
216
|
-
_state.sent();
|
217
|
-
return [
|
218
|
-
4,
|
219
|
-
fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
|
220
|
-
runtime: "nodejs16.x",
|
221
|
-
handler: "index.js",
|
222
|
-
launcherType: "Nodejs",
|
223
|
-
shouldAddHelpers: false,
|
224
|
-
supportsResponseStreaming: true
|
225
|
-
})
|
226
|
-
];
|
227
|
-
case 17:
|
228
|
-
_state.sent();
|
229
|
-
_state.label = 18;
|
230
|
-
case 18:
|
231
|
-
plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
232
|
-
serverAppContext = {
|
233
|
-
sharedDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, sharedDirectory), '")'),
|
234
|
-
apiDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, apiDirectory), '")'),
|
235
|
-
lambdaDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, lambdaDirectory), '")'),
|
236
|
-
metaName
|
237
|
-
};
|
238
|
-
console.log("serverAppContext", serverAppContext);
|
239
|
-
code = "";
|
240
|
-
console.log("deployTarget111111111", deployTarget);
|
241
|
-
switch (deployTarget) {
|
242
|
-
case "node":
|
243
|
-
return [
|
244
|
-
3,
|
245
|
-
19
|
246
|
-
];
|
247
|
-
case "vercel":
|
248
|
-
return [
|
249
|
-
3,
|
250
|
-
22
|
251
|
-
];
|
252
|
-
case "netlify":
|
253
|
-
return [
|
254
|
-
3,
|
255
|
-
25
|
256
|
-
];
|
257
|
-
}
|
258
|
-
return [
|
259
|
-
3,
|
260
|
-
28
|
261
|
-
];
|
262
|
-
case 19:
|
263
|
-
return [
|
264
|
-
4,
|
265
|
-
import("./platforms/node")
|
266
|
-
];
|
267
|
-
case 20:
|
268
|
-
genNodeEntry = _state.sent().genNodeEntry;
|
269
|
-
return [
|
270
|
-
4,
|
271
|
-
genNodeEntry({
|
272
|
-
plugins,
|
273
|
-
config: modernConfig,
|
274
|
-
appContext: serverAppContext
|
275
|
-
})
|
276
|
-
];
|
277
|
-
case 21:
|
278
|
-
code = _state.sent();
|
279
|
-
return [
|
280
|
-
3,
|
281
|
-
29
|
282
|
-
];
|
283
|
-
case 22:
|
284
|
-
return [
|
285
|
-
4,
|
286
|
-
import("./platforms/vercel")
|
287
|
-
];
|
288
|
-
case 23:
|
289
|
-
genVercelEntry = _state.sent().genVercelEntry;
|
290
|
-
return [
|
291
|
-
4,
|
292
|
-
genVercelEntry({
|
293
|
-
plugins,
|
294
|
-
config: modernConfig,
|
295
|
-
appContext: serverAppContext
|
296
|
-
})
|
297
|
-
];
|
298
|
-
case 24:
|
299
|
-
code = _state.sent();
|
300
|
-
return [
|
301
|
-
3,
|
302
|
-
29
|
303
|
-
];
|
304
|
-
case 25:
|
305
|
-
return [
|
306
|
-
4,
|
307
|
-
import("./platforms/netlify")
|
308
|
-
];
|
309
|
-
case 26:
|
310
|
-
genNetlifyEntry = _state.sent().genNetlifyEntry;
|
311
|
-
return [
|
312
|
-
4,
|
313
|
-
genNetlifyEntry({
|
314
|
-
plugins,
|
315
|
-
config: modernConfig,
|
316
|
-
appContext: serverAppContext
|
317
|
-
})
|
318
|
-
];
|
319
|
-
case 27:
|
320
|
-
code = _state.sent();
|
321
|
-
return [
|
322
|
-
3,
|
323
|
-
29
|
324
|
-
];
|
325
|
-
case 28:
|
326
|
-
{
|
327
|
-
code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
|
328
|
-
}
|
329
|
-
_state.label = 29;
|
330
|
-
case 29:
|
331
|
-
entryFilePath = path.join(funcsDirectory, "index.js");
|
332
|
-
if (!needModernServer)
|
333
|
-
return [
|
334
|
-
3,
|
335
|
-
32
|
336
|
-
];
|
337
|
-
return [
|
338
|
-
4,
|
339
|
-
fse.writeFile(entryFilePath, code)
|
340
|
-
];
|
341
|
-
case 30:
|
342
|
-
_state.sent();
|
343
|
-
return [
|
344
|
-
4,
|
345
|
-
handleDependencies(appDirectory, funcsDirectory, [
|
346
|
-
"@modern-js/prod-server"
|
347
|
-
])
|
348
|
-
];
|
349
|
-
case 31:
|
350
|
-
_state.sent();
|
351
|
-
_state.label = 32;
|
352
|
-
case 32:
|
353
|
-
return [
|
354
|
-
2
|
355
|
-
];
|
356
|
-
}
|
357
|
-
});
|
358
|
-
})();
|
359
|
-
}
|
360
|
-
};
|
361
|
-
}
|
362
|
-
};
|
363
|
-
}
|
364
|
-
;
|
365
|
-
export {
|
366
|
-
index_copy_default as default
|
367
|
-
};
|