@vercel/build-utils 14.23.0 → 15.0.0
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/CHANGELOG.md +18 -0
- package/dist/fs/node-version.js +0 -3
- package/dist/fs/stream-to-digest-async.d.ts +0 -1
- package/dist/fs/stream-to-digest-async.js +3 -8
- package/dist/index.d.ts +1 -28
- package/dist/index.js +11 -37
- package/dist/schedules.d.ts +4 -0
- package/dist/types.d.ts +5 -0
- package/package.json +3 -7
- package/dist/collect-build-result/file-to-build-output-file.d.ts +0 -26
- package/dist/collect-build-result/file-to-build-output-file.js +0 -54
- package/dist/collect-build-result/get-build-result-metadata.d.ts +0 -33
- package/dist/collect-build-result/get-build-result-metadata.js +0 -99
- package/dist/collect-build-result/get-content-type.d.ts +0 -1
- package/dist/collect-build-result/get-content-type.js +0 -45
- package/dist/collect-build-result/get-lambda-by-output-path.d.ts +0 -13
- package/dist/collect-build-result/get-lambda-by-output-path.js +0 -31
- package/dist/collect-build-result/get-prerender-chain.d.ts +0 -8
- package/dist/collect-build-result/get-prerender-chain.js +0 -44
- package/dist/collect-build-result/is-route-middleware.d.ts +0 -4
- package/dist/collect-build-result/is-route-middleware.js +0 -30
- package/dist/collect-build-result/prerender-to-build-output-file.d.ts +0 -23
- package/dist/collect-build-result/prerender-to-build-output-file.js +0 -85
- package/dist/collect-build-result/stream-with-extended-payload.d.ts +0 -5
- package/dist/collect-build-result/stream-with-extended-payload.js +0 -49
- package/dist/collect-build-result/validate-build-result.d.ts +0 -19
- package/dist/collect-build-result/validate-build-result.js +0 -139
- package/dist/collect-build-result/validate-prerender.d.ts +0 -8
- package/dist/collect-build-result/validate-prerender.js +0 -32
- package/dist/collect-build-result/validate-regular-file.d.ts +0 -8
- package/dist/collect-build-result/validate-regular-file.js +0 -42
- package/dist/collect-uncompressed-size.d.ts +0 -6
- package/dist/collect-uncompressed-size.js +0 -59
- package/dist/deserialize/create-functions-iterator.d.ts +0 -8
- package/dist/deserialize/create-functions-iterator.js +0 -52
- package/dist/deserialize/deserialize-build-output-types.d.ts +0 -56
- package/dist/deserialize/deserialize-build-output-types.js +0 -16
- package/dist/deserialize/deserialize-build-output.d.ts +0 -4
- package/dist/deserialize/deserialize-build-output.js +0 -296
- package/dist/deserialize/deserialize-edge-function.d.ts +0 -5
- package/dist/deserialize/deserialize-edge-function.js +0 -47
- package/dist/deserialize/deserialize-lambda.d.ts +0 -22
- package/dist/deserialize/deserialize-lambda.js +0 -56
- package/dist/deserialize/hydrate-files-map.d.ts +0 -3
- package/dist/deserialize/hydrate-files-map.js +0 -55
- package/dist/deserialize/maybe-read-json.d.ts +0 -5
- package/dist/deserialize/maybe-read-json.js +0 -37
- package/dist/deserialize/serialized-types.d.ts +0 -32
- package/dist/deserialize/serialized-types.js +0 -16
- package/dist/deserialize/validate-framework-version.d.ts +0 -6
- package/dist/deserialize/validate-framework-version.js +0 -63
- package/dist/finalize-lambda.d.ts +0 -77
- package/dist/finalize-lambda.js +0 -117
- package/dist/process-serverless/get-encrypted-env-file.d.ts +0 -11
- package/dist/process-serverless/get-encrypted-env-file.js +0 -47
- package/dist/process-serverless/get-lambda-environment.d.ts +0 -19
- package/dist/process-serverless/get-lambda-environment.js +0 -53
- package/dist/process-serverless/get-lambda-preload-scripts.d.ts +0 -22
- package/dist/process-serverless/get-lambda-preload-scripts.js +0 -43
- package/dist/process-serverless/get-lambda-supports-streaming.d.ts +0 -22
- package/dist/process-serverless/get-lambda-supports-streaming.js +0 -42
- package/dist/validate-lambda-size.d.ts +0 -45
- package/dist/validate-lambda-size.js +0 -117
|
@@ -1,296 +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 deserialize_build_output_exports = {};
|
|
30
|
-
__export(deserialize_build_output_exports, {
|
|
31
|
-
deserializeBuildOutput: () => deserializeBuildOutput,
|
|
32
|
-
validateDeploymentId: () => validateDeploymentId
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(deserialize_build_output_exports);
|
|
35
|
-
var fs = __toESM(require("fs-extra"));
|
|
36
|
-
var import_path = require("path");
|
|
37
|
-
var import_errors = require("../errors");
|
|
38
|
-
var import_file_fs_ref = __toESM(require("../file-fs-ref"));
|
|
39
|
-
var import_glob = __toESM(require("../fs/glob"));
|
|
40
|
-
var import_prerender = require("../prerender");
|
|
41
|
-
var import_create_functions_iterator = require("./create-functions-iterator");
|
|
42
|
-
var import_deserialize_edge_function = require("./deserialize-edge-function");
|
|
43
|
-
var import_maybe_read_json = require("./maybe-read-json");
|
|
44
|
-
var import_validate_framework_version = require("./validate-framework-version");
|
|
45
|
-
const MAX_DEPLOYMENT_ID_LENGTH = 32;
|
|
46
|
-
const VALID_DEPLOYMENT_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
47
|
-
function validateDeploymentId(deploymentId) {
|
|
48
|
-
if (deploymentId && deploymentId.length > MAX_DEPLOYMENT_ID_LENGTH) {
|
|
49
|
-
throw new import_errors.NowBuildError({
|
|
50
|
-
message: `The configured deploymentId "${deploymentId}" exceeds the maximum length of ${MAX_DEPLOYMENT_ID_LENGTH} characters. Please use a shorter deploymentId.`,
|
|
51
|
-
code: "VC_BUILD_INVALID_DEPLOYMENT_ID_LENGTH"
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
if (deploymentId && !VALID_DEPLOYMENT_ID_PATTERN.test(deploymentId)) {
|
|
55
|
-
throw new import_errors.NowBuildError({
|
|
56
|
-
message: `The configured deploymentId "${deploymentId}" contains invalid characters. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_) are allowed.`,
|
|
57
|
-
code: "VC_BUILD_INVALID_DEPLOYMENT_ID_CHARACTERS"
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function applyOutputOverrides(output, overrides, warn) {
|
|
62
|
-
for (const [name, override] of Object.entries(overrides || {})) {
|
|
63
|
-
const entry = output[name];
|
|
64
|
-
if (entry) {
|
|
65
|
-
if (override.contentType) {
|
|
66
|
-
entry.contentType = override.contentType;
|
|
67
|
-
}
|
|
68
|
-
if (override.mode) {
|
|
69
|
-
entry.mode = override.mode;
|
|
70
|
-
}
|
|
71
|
-
if (override.path) {
|
|
72
|
-
output[override.path] = entry;
|
|
73
|
-
delete output[name];
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
warn?.(
|
|
77
|
-
`Warning: Override path "${name}" was not detected as an output path`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async function deserializePrerenderFallback(prerenderConfigPath, fallbackConfig) {
|
|
83
|
-
if (typeof fallbackConfig === "string") {
|
|
84
|
-
return import_file_fs_ref.default.fromFsPath({
|
|
85
|
-
fsPath: (0, import_path.join)((0, import_path.dirname)(prerenderConfigPath), fallbackConfig)
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (fallbackConfig) {
|
|
89
|
-
return import_file_fs_ref.default.fromFsPath({
|
|
90
|
-
mode: fallbackConfig.mode,
|
|
91
|
-
contentType: fallbackConfig.contentType,
|
|
92
|
-
fsPath: (0, import_path.join)((0, import_path.dirname)(prerenderConfigPath), fallbackConfig.fsPath)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
function applyFunctionSymlinks(output, prerenders, functionSymlinks) {
|
|
98
|
-
for (const [path, target] of functionSymlinks.entries()) {
|
|
99
|
-
const targetOutput = prerenders.get(target) || output[target];
|
|
100
|
-
let targetFunction;
|
|
101
|
-
if (targetOutput?.type === "Prerender") {
|
|
102
|
-
targetFunction = targetOutput.lambda;
|
|
103
|
-
} else if (targetOutput?.type === "Lambda" || targetOutput?.type === "EdgeFunction") {
|
|
104
|
-
targetFunction = targetOutput;
|
|
105
|
-
}
|
|
106
|
-
if (!targetFunction) {
|
|
107
|
-
throw new Error(
|
|
108
|
-
`Could not find target "${target}" Lambda or EdgeFunction for path "${path}"`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
const srcOutput = prerenders.get(path);
|
|
112
|
-
if (srcOutput) {
|
|
113
|
-
if (srcOutput.type === "Prerender") {
|
|
114
|
-
if (targetFunction.type === "Lambda") {
|
|
115
|
-
srcOutput.lambda = targetFunction;
|
|
116
|
-
} else {
|
|
117
|
-
throw new Error(
|
|
118
|
-
`Unexpected function type "${targetFunction.type}" at path "${path}"`
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
throw new Error(
|
|
123
|
-
`Unexpected output type "${srcOutput.type}" at path "${path}"`
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
output[path] = targetFunction;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function appendSortedPrerenders(output, prerenders) {
|
|
132
|
-
const sortedPrerenders = Array.from(prerenders.entries()).sort((a, b) => {
|
|
133
|
-
return (a[1].group ?? 0) - (b[1].group ?? 0);
|
|
134
|
-
}).reduce((o, [path, prerender]) => {
|
|
135
|
-
o[path] = prerender;
|
|
136
|
-
return o;
|
|
137
|
-
}, {});
|
|
138
|
-
Object.assign(output, sortedPrerenders);
|
|
139
|
-
}
|
|
140
|
-
function getBundleableLambdas(output) {
|
|
141
|
-
const bundleableLambdas = {};
|
|
142
|
-
for (const [outputName, curOutput] of Object.entries(output)) {
|
|
143
|
-
if (curOutput.type === "Lambda" && curOutput.experimentalAllowBundling) {
|
|
144
|
-
bundleableLambdas[outputName] = curOutput;
|
|
145
|
-
} else if (curOutput.type === "Prerender" && curOutput.lambda && curOutput.lambda.experimentalAllowBundling) {
|
|
146
|
-
bundleableLambdas[outputName] = curOutput.lambda;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return bundleableLambdas;
|
|
150
|
-
}
|
|
151
|
-
function applyGroupedLambdas(output, groupedLambdas) {
|
|
152
|
-
for (const outputName of Object.keys(groupedLambdas)) {
|
|
153
|
-
const groupedLambda = groupedLambdas[outputName];
|
|
154
|
-
const origOutput = output[outputName];
|
|
155
|
-
if (origOutput.type === "Lambda") {
|
|
156
|
-
output[outputName] = groupedLambda;
|
|
157
|
-
} else if (origOutput.type === "Prerender" && origOutput.lambda) {
|
|
158
|
-
origOutput.lambda = groupedLambda;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
async function deserializeBuildOutput(options) {
|
|
163
|
-
const {
|
|
164
|
-
outputDir,
|
|
165
|
-
repoRootPath,
|
|
166
|
-
maxBundleSizeMb,
|
|
167
|
-
debugGroupLambdas,
|
|
168
|
-
useOnlyStreamingLambda,
|
|
169
|
-
forceNodejsStreaming,
|
|
170
|
-
deserializeLambda,
|
|
171
|
-
groupLambdas,
|
|
172
|
-
inspectSerializedLambda,
|
|
173
|
-
warn,
|
|
174
|
-
includeDeploymentId,
|
|
175
|
-
getMeta
|
|
176
|
-
} = options;
|
|
177
|
-
let hasServerActions = false;
|
|
178
|
-
const configPath = (0, import_path.join)(outputDir, "config.json");
|
|
179
|
-
const config = await (0, import_maybe_read_json.maybeReadJSON)(configPath);
|
|
180
|
-
if (!config) {
|
|
181
|
-
throw new Error(`Config file was not found at "${configPath}"`);
|
|
182
|
-
}
|
|
183
|
-
if (config.version !== 3) {
|
|
184
|
-
throw new Error(
|
|
185
|
-
`Expected \`version: 3\` in "${configPath}" file (received \`${config.version}\`)`
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
validateDeploymentId(config.deploymentId);
|
|
189
|
-
const flags = await (0, import_maybe_read_json.maybeReadJSON)((0, import_path.join)(outputDir, "flags.json"));
|
|
190
|
-
const staticDir = (0, import_path.join)(outputDir, "static");
|
|
191
|
-
const output = await (0, import_glob.default)("**", {
|
|
192
|
-
cwd: staticDir,
|
|
193
|
-
follow: true
|
|
194
|
-
});
|
|
195
|
-
applyOutputOverrides(output, config.overrides, warn);
|
|
196
|
-
const fileFsRefsCache = /* @__PURE__ */ new Map();
|
|
197
|
-
const prerenders = /* @__PURE__ */ new Map();
|
|
198
|
-
const functionsDir = (0, import_path.join)(outputDir, "functions");
|
|
199
|
-
const functionSymlinks = /* @__PURE__ */ new Map();
|
|
200
|
-
for await (const path of (0, import_create_functions_iterator.createFunctionsIterator)(functionsDir)) {
|
|
201
|
-
let lambda = void 0;
|
|
202
|
-
const fnDir = (0, import_path.join)(functionsDir, `${path}.func`);
|
|
203
|
-
try {
|
|
204
|
-
const link = await fs.readlink(fnDir);
|
|
205
|
-
const target = (0, import_path.join)((0, import_path.dirname)(path), link).slice(0, -5);
|
|
206
|
-
functionSymlinks.set(path, target);
|
|
207
|
-
} catch (err) {
|
|
208
|
-
if (err.code !== "EINVAL")
|
|
209
|
-
throw err;
|
|
210
|
-
const funcConfigPath = (0, import_path.join)(fnDir, ".vc-config.json");
|
|
211
|
-
const funcConfig = await (0, import_maybe_read_json.maybeReadJSON)(
|
|
212
|
-
funcConfigPath
|
|
213
|
-
);
|
|
214
|
-
if (!funcConfig) {
|
|
215
|
-
throw new Error(`Could not load function config: "${funcConfigPath}"`);
|
|
216
|
-
}
|
|
217
|
-
const files = await (0, import_glob.default)("**", { cwd: fnDir, includeDirectories: true });
|
|
218
|
-
delete files[".vc-config.json"];
|
|
219
|
-
if (funcConfig.type === "EdgeFunction" || funcConfig.runtime === "edge") {
|
|
220
|
-
output[path] = await (0, import_deserialize_edge_function.deserializeEdgeFunction)(
|
|
221
|
-
files,
|
|
222
|
-
funcConfig,
|
|
223
|
-
repoRootPath,
|
|
224
|
-
fileFsRefsCache
|
|
225
|
-
);
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
lambda = await deserializeLambda(
|
|
229
|
-
files,
|
|
230
|
-
funcConfig,
|
|
231
|
-
repoRootPath,
|
|
232
|
-
fileFsRefsCache,
|
|
233
|
-
{ useOnlyStreamingLambda, forceNodejsStreaming }
|
|
234
|
-
);
|
|
235
|
-
if (inspectSerializedLambda) {
|
|
236
|
-
hasServerActions = await inspectSerializedLambda(
|
|
237
|
-
path,
|
|
238
|
-
funcConfig,
|
|
239
|
-
repoRootPath,
|
|
240
|
-
hasServerActions
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
const prerenderConfigPath = (0, import_path.join)(
|
|
245
|
-
functionsDir,
|
|
246
|
-
`${path}.prerender-config.json`
|
|
247
|
-
);
|
|
248
|
-
const prerenderConfig = await (0, import_maybe_read_json.maybeReadJSON)(
|
|
249
|
-
prerenderConfigPath
|
|
250
|
-
);
|
|
251
|
-
if (prerenderConfig) {
|
|
252
|
-
const fallback = await deserializePrerenderFallback(
|
|
253
|
-
prerenderConfigPath,
|
|
254
|
-
prerenderConfig.fallback
|
|
255
|
-
);
|
|
256
|
-
const prerender = new import_prerender.Prerender({
|
|
257
|
-
...prerenderConfig,
|
|
258
|
-
lambda,
|
|
259
|
-
fallback
|
|
260
|
-
});
|
|
261
|
-
prerenders.set(path, prerender);
|
|
262
|
-
} else if (lambda) {
|
|
263
|
-
output[path] = lambda;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
applyFunctionSymlinks(output, prerenders, functionSymlinks);
|
|
267
|
-
appendSortedPrerenders(output, prerenders);
|
|
268
|
-
const groupedLambdas = await groupLambdas(
|
|
269
|
-
getBundleableLambdas(output),
|
|
270
|
-
{
|
|
271
|
-
force: void 0,
|
|
272
|
-
maxBundleSizeMb,
|
|
273
|
-
debug: debugGroupLambdas
|
|
274
|
-
}
|
|
275
|
-
);
|
|
276
|
-
applyGroupedLambdas(output, groupedLambdas);
|
|
277
|
-
const framework = (0, import_validate_framework_version.validateFrameworkVersion)(config?.framework);
|
|
278
|
-
const meta = getMeta?.(hasServerActions);
|
|
279
|
-
return {
|
|
280
|
-
wildcard: config.wildcard,
|
|
281
|
-
images: config.images,
|
|
282
|
-
crons: config.crons,
|
|
283
|
-
flags: flags ? flags : config.flags,
|
|
284
|
-
routes: config.routes,
|
|
285
|
-
afterCacheBypass: config.afterCacheBypass,
|
|
286
|
-
output,
|
|
287
|
-
framework,
|
|
288
|
-
...includeDeploymentId ? { deploymentId: config.deploymentId } : {},
|
|
289
|
-
...meta !== void 0 ? { meta } : {}
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
293
|
-
0 && (module.exports = {
|
|
294
|
-
deserializeBuildOutput,
|
|
295
|
-
validateDeploymentId
|
|
296
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Files } from '../types';
|
|
2
|
-
import { EdgeFunction } from '../edge-function';
|
|
3
|
-
import type FileFsRef from '../file-fs-ref';
|
|
4
|
-
import type { SerializedEdgeFunction } from './serialized-types';
|
|
5
|
-
export declare function deserializeEdgeFunction(files: Files, config: SerializedEdgeFunction, repoRootPath: string, fileFsRefsCache: Map<string, FileFsRef>): Promise<EdgeFunction>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var deserialize_edge_function_exports = {};
|
|
20
|
-
__export(deserialize_edge_function_exports, {
|
|
21
|
-
deserializeEdgeFunction: () => deserializeEdgeFunction
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(deserialize_edge_function_exports);
|
|
24
|
-
var import_edge_function = require("../edge-function");
|
|
25
|
-
var import_hydrate_files_map = require("./hydrate-files-map");
|
|
26
|
-
async function deserializeEdgeFunction(files, config, repoRootPath, fileFsRefsCache) {
|
|
27
|
-
if (config.filePathMap) {
|
|
28
|
-
await (0, import_hydrate_files_map.hydrateFilesMap)(
|
|
29
|
-
files,
|
|
30
|
-
config.filePathMap,
|
|
31
|
-
repoRootPath,
|
|
32
|
-
fileFsRefsCache
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
const edgeFunction = new import_edge_function.EdgeFunction({
|
|
36
|
-
// "v8-worker" is currently the only supported target, so specify
|
|
37
|
-
// it implicitly here so that `.vc-config.json` does not need to.
|
|
38
|
-
deploymentTarget: "v8-worker",
|
|
39
|
-
...config,
|
|
40
|
-
files
|
|
41
|
-
});
|
|
42
|
-
return edgeFunction;
|
|
43
|
-
}
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
deserializeEdgeFunction
|
|
47
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Files } from '../types';
|
|
2
|
-
import { Lambda } from '../lambda';
|
|
3
|
-
import { NodejsLambda } from '../nodejs-lambda';
|
|
4
|
-
import type FileFsRef from '../file-fs-ref';
|
|
5
|
-
import type { SerializedLambda, SerializedNodejsLambda } from './serialized-types';
|
|
6
|
-
export interface DeserializeLambdaOptions {
|
|
7
|
-
useOnlyStreamingLambda?: boolean;
|
|
8
|
-
forceNodejsStreaming?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Custom Lambda class constructor. Defaults to the base Lambda class.
|
|
11
|
-
* Pass an extended class (e.g. with BYOC `external` property) to
|
|
12
|
-
* preserve extra properties through deserialization.
|
|
13
|
-
*/
|
|
14
|
-
LambdaClass?: typeof Lambda;
|
|
15
|
-
/**
|
|
16
|
-
* Custom NodejsLambda class constructor. Defaults to the base NodejsLambda class.
|
|
17
|
-
* Pass an extended class (e.g. with BYOC `external` property) to
|
|
18
|
-
* preserve extra properties through deserialization.
|
|
19
|
-
*/
|
|
20
|
-
NodejsLambdaClass?: typeof NodejsLambda;
|
|
21
|
-
}
|
|
22
|
-
export declare function deserializeLambda(files: Files, config: SerializedLambda | SerializedNodejsLambda, repoRootPath: string, fileFsRefsCache: Map<string, FileFsRef>, options?: DeserializeLambdaOptions): Promise<Lambda>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var deserialize_lambda_exports = {};
|
|
20
|
-
__export(deserialize_lambda_exports, {
|
|
21
|
-
deserializeLambda: () => deserializeLambda
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(deserialize_lambda_exports);
|
|
24
|
-
var import_lambda = require("../lambda");
|
|
25
|
-
var import_nodejs_lambda = require("../nodejs-lambda");
|
|
26
|
-
var import_hydrate_files_map = require("./hydrate-files-map");
|
|
27
|
-
async function deserializeLambda(files, config, repoRootPath, fileFsRefsCache, options) {
|
|
28
|
-
const LambdaCtor = options?.LambdaClass ?? import_lambda.Lambda;
|
|
29
|
-
const NodejsLambdaCtor = options?.NodejsLambdaClass ?? import_nodejs_lambda.NodejsLambda;
|
|
30
|
-
if (config.filePathMap) {
|
|
31
|
-
await (0, import_hydrate_files_map.hydrateFilesMap)(
|
|
32
|
-
files,
|
|
33
|
-
config.filePathMap,
|
|
34
|
-
repoRootPath,
|
|
35
|
-
fileFsRefsCache
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
const supportsResponseStreaming = config.supportsResponseStreaming ?? config.experimentalResponseStreaming;
|
|
39
|
-
if ("launcherType" in config && config.launcherType === "Nodejs") {
|
|
40
|
-
const overrideResponseStreaming = (options?.useOnlyStreamingLambda || options?.forceNodejsStreaming) && (config.awsLambdaHandler === void 0 || config.awsLambdaHandler === "");
|
|
41
|
-
return new NodejsLambdaCtor({
|
|
42
|
-
...config,
|
|
43
|
-
supportsResponseStreaming: overrideResponseStreaming || supportsResponseStreaming,
|
|
44
|
-
files
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return new LambdaCtor({
|
|
48
|
-
...config,
|
|
49
|
-
supportsResponseStreaming,
|
|
50
|
-
files
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
deserializeLambda
|
|
56
|
-
});
|
|
@@ -1,55 +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 hydrate_files_map_exports = {};
|
|
30
|
-
__export(hydrate_files_map_exports, {
|
|
31
|
-
hydrateFilesMap: () => hydrateFilesMap
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(hydrate_files_map_exports);
|
|
34
|
-
var import_file_fs_ref = __toESM(require("../file-fs-ref"));
|
|
35
|
-
var import_path = require("path");
|
|
36
|
-
async function hydrateFilesMap(files, filesMap, repoRootPath, fileFsRefsCache) {
|
|
37
|
-
for (const [funcPath, projectPath] of Object.entries(filesMap)) {
|
|
38
|
-
files[funcPath] = await fileFsRefCached(
|
|
39
|
-
(0, import_path.join)(repoRootPath, projectPath),
|
|
40
|
-
fileFsRefsCache
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function fileFsRefCached(fsPath, cache) {
|
|
45
|
-
let file = cache.get(fsPath);
|
|
46
|
-
if (!file) {
|
|
47
|
-
file = await import_file_fs_ref.default.fromFsPath({ fsPath });
|
|
48
|
-
cache.set(fsPath, file);
|
|
49
|
-
}
|
|
50
|
-
return file;
|
|
51
|
-
}
|
|
52
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
-
0 && (module.exports = {
|
|
54
|
-
hydrateFilesMap
|
|
55
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var maybe_read_json_exports = {};
|
|
20
|
-
__export(maybe_read_json_exports, {
|
|
21
|
-
maybeReadJSON: () => maybeReadJSON
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(maybe_read_json_exports);
|
|
24
|
-
var import_fs_extra = require("fs-extra");
|
|
25
|
-
async function maybeReadJSON(path) {
|
|
26
|
-
try {
|
|
27
|
-
return await (0, import_fs_extra.readJSON)(path);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
if (err.code !== "ENOENT")
|
|
30
|
-
throw err;
|
|
31
|
-
}
|
|
32
|
-
return void 0;
|
|
33
|
-
}
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
maybeReadJSON
|
|
37
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Lambda } from '../lambda';
|
|
2
|
-
import type { NodejsLambda } from '../nodejs-lambda';
|
|
3
|
-
import type { EdgeFunction } from '../edge-function';
|
|
4
|
-
import type { ContainerImage } from '../container-image';
|
|
5
|
-
import type FileFsRef from '../file-fs-ref';
|
|
6
|
-
import type { Prerender } from '../prerender';
|
|
7
|
-
/**
|
|
8
|
-
* Maps a type to a new type that does not contain any functions on it.
|
|
9
|
-
* Useful for typing serialized `class` types, which will not contain
|
|
10
|
-
* functions when serialized to JSON.
|
|
11
|
-
*/
|
|
12
|
-
export type Properties<T> = {
|
|
13
|
-
[P in keyof T as T[P] extends (...args: any[]) => any ? never : P]: T[P];
|
|
14
|
-
};
|
|
15
|
-
type FilesMapProp = {
|
|
16
|
-
filePathMap?: Record<string, string>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Type for the `.vc-config.json` file of a serialized
|
|
20
|
-
* `ServerlessFunction` instance.
|
|
21
|
-
*/
|
|
22
|
-
export type SerializedLambda<T extends Lambda = Lambda> = Properties<Omit<T, 'files' | 'zipBuffer'>> & FilesMapProp;
|
|
23
|
-
export type SerializedNodejsLambda<T extends NodejsLambda = NodejsLambda> = Properties<Omit<T, 'files' | 'zipBuffer'>> & FilesMapProp;
|
|
24
|
-
export type SerializedFileFsRef = Properties<FileFsRef>;
|
|
25
|
-
export type SerializedPrerender = Properties<Omit<Prerender, 'lambda' | 'fallback'>> & {
|
|
26
|
-
fallback: SerializedFileFsRef | null;
|
|
27
|
-
};
|
|
28
|
-
export type SerializedEdgeFunction = Properties<Omit<EdgeFunction, 'name' | 'files' | 'deploymentTarget'>> & FilesMapProp;
|
|
29
|
-
export type SerializedContainerImage = Omit<Properties<ContainerImage>, 'files' | 'type'> & {
|
|
30
|
-
type?: 'ContainerImage';
|
|
31
|
-
} & FilesMapProp;
|
|
32
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var serialized_types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(serialized_types_exports);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var validate_framework_version_exports = {};
|
|
20
|
-
__export(validate_framework_version_exports, {
|
|
21
|
-
validateFrameworkVersion: () => validateFrameworkVersion
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(validate_framework_version_exports);
|
|
24
|
-
var import_errors = require("../errors");
|
|
25
|
-
const MAX_SLUG_LENGTH = 50;
|
|
26
|
-
const MAX_FRAMEWORK_VERSION_LENGTH = 50;
|
|
27
|
-
function validateFrameworkVersion(framework) {
|
|
28
|
-
if (!framework) {
|
|
29
|
-
return void 0;
|
|
30
|
-
}
|
|
31
|
-
const { slug, version } = framework;
|
|
32
|
-
if (typeof slug !== "string") {
|
|
33
|
-
return void 0;
|
|
34
|
-
}
|
|
35
|
-
if (typeof version !== "string") {
|
|
36
|
-
throw new import_errors.NowBuildError({
|
|
37
|
-
message: `Invalid config.json: "version" type "${typeof version}" should be "string"`,
|
|
38
|
-
code: "VC_BUILD_INVALID_CONFIG_JSON_FRAMEWORK_VERSION_TYPE"
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (slug.length > MAX_SLUG_LENGTH) {
|
|
42
|
-
const trimmedFrameworkSlug = slug.slice(0, MAX_SLUG_LENGTH);
|
|
43
|
-
throw new import_errors.NowBuildError({
|
|
44
|
-
message: `Invalid config.json: "framework.slug" length ${slug.length} > ${MAX_SLUG_LENGTH}. "${trimmedFrameworkSlug}..."`,
|
|
45
|
-
code: "VC_BUILD_INVALID_CONFIG_JSON_FRAMEWORK_SLUG_LENGTH"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (version.length > MAX_FRAMEWORK_VERSION_LENGTH) {
|
|
49
|
-
const trimmedFrameworkVersion = version.slice(
|
|
50
|
-
0,
|
|
51
|
-
MAX_FRAMEWORK_VERSION_LENGTH
|
|
52
|
-
);
|
|
53
|
-
throw new import_errors.NowBuildError({
|
|
54
|
-
message: `Invalid config.json: "framework.version" length ${version.length} > ${MAX_FRAMEWORK_VERSION_LENGTH}. "${trimmedFrameworkVersion}..."`,
|
|
55
|
-
code: "VC_BUILD_INVALID_CONFIG_JSON_FRAMEWORK_VERSION_LENGTH"
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return framework;
|
|
59
|
-
}
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
validateFrameworkVersion
|
|
63
|
-
});
|