@vercel/build-utils 13.19.0 → 13.20.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 +16 -0
- package/dist/deserialize/deserialize-build-output-types.d.ts +57 -0
- package/dist/deserialize/deserialize-build-output-types.js +16 -0
- package/dist/deserialize/deserialize-build-output.d.ts +4 -0
- package/dist/deserialize/deserialize-build-output.js +297 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +637 -550
- package/dist/package-manifest.d.ts +1 -0
- package/dist/process-serverless/get-lambda-supports-streaming.d.ts +1 -4
- package/dist/process-serverless/get-lambda-supports-streaming.js +1 -60
- package/dist/schemas.d.ts +4 -0
- package/dist/schemas.js +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Files } from '../types';
|
|
2
1
|
interface LambdaLike {
|
|
3
|
-
files?: Files;
|
|
4
2
|
handler: string;
|
|
5
3
|
launcherType?: string;
|
|
6
4
|
runtime: string;
|
|
@@ -16,8 +14,7 @@ export interface SupportsStreamingResult {
|
|
|
16
14
|
/**
|
|
17
15
|
* Determines if a Lambda should have streaming enabled. If
|
|
18
16
|
* `forceStreamingRuntime` is true, streaming is always enabled. If the
|
|
19
|
-
* setting is defined it will be honored.
|
|
20
|
-
* exports which is why it needs to be asynchronous.
|
|
17
|
+
* setting is defined it will be honored. Enabled by default for Node.js.
|
|
21
18
|
*/
|
|
22
19
|
export declare function getLambdaSupportsStreaming(lambda: LambdaLike, forceStreamingRuntime: boolean): Promise<SupportsStreamingResult>;
|
|
23
20
|
export {};
|
|
@@ -21,8 +21,6 @@ __export(get_lambda_supports_streaming_exports, {
|
|
|
21
21
|
getLambdaSupportsStreaming: () => getLambdaSupportsStreaming
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(get_lambda_supports_streaming_exports);
|
|
24
|
-
var import_cjs_module_lexer = require("cjs-module-lexer");
|
|
25
|
-
var import_es_module_lexer = require("es-module-lexer");
|
|
26
24
|
async function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
|
|
27
25
|
if (forceStreamingRuntime) {
|
|
28
26
|
return { supportsStreaming: true };
|
|
@@ -31,67 +29,10 @@ async function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
|
|
|
31
29
|
return { supportsStreaming: lambda.supportsResponseStreaming };
|
|
32
30
|
}
|
|
33
31
|
if ("launcherType" in lambda && lambda.launcherType === "Nodejs") {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
return { supportsStreaming: void 0 };
|
|
37
|
-
}
|
|
38
|
-
const HTTP_METHODS = [
|
|
39
|
-
"GET",
|
|
40
|
-
"HEAD",
|
|
41
|
-
"OPTIONS",
|
|
42
|
-
"POST",
|
|
43
|
-
"PUT",
|
|
44
|
-
"DELETE",
|
|
45
|
-
"PATCH"
|
|
46
|
-
];
|
|
47
|
-
async function lambdaShouldStream(lambda) {
|
|
48
|
-
const stream = lambda.files?.[lambda.handler]?.toStream();
|
|
49
|
-
if (!stream) {
|
|
50
|
-
return { supportsStreaming: void 0 };
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
const buffer = await streamToBuffer(stream);
|
|
54
|
-
const names = await getFileExports(lambda.handler, buffer.toString("utf8"));
|
|
55
|
-
for (const name of names) {
|
|
56
|
-
if (HTTP_METHODS.includes(name)) {
|
|
57
|
-
return { supportsStreaming: true };
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} catch (err) {
|
|
61
|
-
return {
|
|
62
|
-
supportsStreaming: void 0,
|
|
63
|
-
error: { handler: lambda.handler, message: String(err) }
|
|
64
|
-
};
|
|
32
|
+
return { supportsStreaming: true };
|
|
65
33
|
}
|
|
66
34
|
return { supportsStreaming: void 0 };
|
|
67
35
|
}
|
|
68
|
-
async function getFileExports(filename, content) {
|
|
69
|
-
if (filename.endsWith(".mjs")) {
|
|
70
|
-
await import_es_module_lexer.init;
|
|
71
|
-
return (0, import_es_module_lexer.parse)(content)[1].map((specifier) => specifier.n);
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
await (0, import_cjs_module_lexer.init)();
|
|
75
|
-
return (0, import_cjs_module_lexer.parse)(content).exports;
|
|
76
|
-
} catch {
|
|
77
|
-
await import_es_module_lexer.init;
|
|
78
|
-
return (0, import_es_module_lexer.parse)(content)[1].map((specifier) => specifier.n);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function streamToBuffer(stream) {
|
|
82
|
-
return new Promise((resolve, reject) => {
|
|
83
|
-
const buffers = [];
|
|
84
|
-
stream.on("error", (err) => {
|
|
85
|
-
reject(err);
|
|
86
|
-
});
|
|
87
|
-
stream.on("data", (buffer) => {
|
|
88
|
-
buffers.push(buffer);
|
|
89
|
-
});
|
|
90
|
-
stream.on("end", () => {
|
|
91
|
-
resolve(Buffer.concat(buffers));
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
37
|
0 && (module.exports = {
|
|
97
38
|
getLambdaSupportsStreaming
|
package/dist/schemas.d.ts
CHANGED
|
@@ -140,6 +140,10 @@ export declare const packageManifestSchema: {
|
|
|
140
140
|
readonly type: "string";
|
|
141
141
|
readonly description: "Runtime identifier, e.g. \"python\", \"node\".";
|
|
142
142
|
};
|
|
143
|
+
readonly framework: {
|
|
144
|
+
readonly type: "string";
|
|
145
|
+
readonly description: "Detected framework slug, e.g. \"fastapi\", \"flask\", \"hono\".";
|
|
146
|
+
};
|
|
143
147
|
readonly runtimeVersion: {
|
|
144
148
|
readonly type: "object";
|
|
145
149
|
readonly additionalProperties: false;
|
package/dist/schemas.js
CHANGED
|
@@ -187,6 +187,10 @@ const packageManifestSchema = {
|
|
|
187
187
|
type: "string",
|
|
188
188
|
description: 'Runtime identifier, e.g. "python", "node".'
|
|
189
189
|
},
|
|
190
|
+
framework: {
|
|
191
|
+
type: "string",
|
|
192
|
+
description: 'Detected framework slug, e.g. "fastapi", "flask", "hono".'
|
|
193
|
+
},
|
|
190
194
|
runtimeVersion: {
|
|
191
195
|
type: "object",
|
|
192
196
|
additionalProperties: false,
|