@vercel/build-utils
Advanced tools
+6
-0
| # @vercel/build-utils | ||
| ## 13.19.1 | ||
| ### Patch Changes | ||
| - [build-utils] simplify streaming lambda check ([#15795](https://github.com/vercel/vercel/pull/15795)) | ||
| ## 13.19.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,4 +0,2 @@ | ||
| import type { Files } from '../types'; | ||
| interface LambdaLike { | ||
| files?: Files; | ||
| handler: string; | ||
@@ -19,6 +17,5 @@ launcherType?: string; | ||
| * `forceStreamingRuntime` is true, streaming is always enabled. If the | ||
| * setting is defined it will be honored. For Node.js it checks the handler | ||
| * exports which is why it needs to be asynchronous. | ||
| * setting is defined it will be honored. Enabled by default for Node.js. | ||
| */ | ||
| export declare function getLambdaSupportsStreaming(lambda: LambdaLike, forceStreamingRuntime: boolean): Promise<SupportsStreamingResult>; | ||
| export {}; |
@@ -24,4 +24,2 @@ "use strict"; | ||
| module.exports = __toCommonJS(get_lambda_supports_streaming_exports); | ||
| var import_cjs_module_lexer = require("cjs-module-lexer"); | ||
| var import_es_module_lexer = require("es-module-lexer"); | ||
| async function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) { | ||
@@ -35,63 +33,6 @@ if (forceStreamingRuntime) { | ||
| if ("launcherType" in lambda && lambda.launcherType === "Nodejs") { | ||
| return lambdaShouldStream(lambda); | ||
| return { supportsStreaming: true }; | ||
| } | ||
| return { supportsStreaming: void 0 }; | ||
| } | ||
| const HTTP_METHODS = [ | ||
| "GET", | ||
| "HEAD", | ||
| "OPTIONS", | ||
| "POST", | ||
| "PUT", | ||
| "DELETE", | ||
| "PATCH" | ||
| ]; | ||
| async function lambdaShouldStream(lambda) { | ||
| const stream = lambda.files?.[lambda.handler]?.toStream(); | ||
| if (!stream) { | ||
| return { supportsStreaming: void 0 }; | ||
| } | ||
| try { | ||
| const buffer = await streamToBuffer(stream); | ||
| const names = await getFileExports(lambda.handler, buffer.toString("utf8")); | ||
| for (const name of names) { | ||
| if (HTTP_METHODS.includes(name)) { | ||
| return { supportsStreaming: true }; | ||
| } | ||
| } | ||
| } catch (err) { | ||
| return { | ||
| supportsStreaming: void 0, | ||
| error: { handler: lambda.handler, message: String(err) } | ||
| }; | ||
| } | ||
| return { supportsStreaming: void 0 }; | ||
| } | ||
| async function getFileExports(filename, content) { | ||
| if (filename.endsWith(".mjs")) { | ||
| await import_es_module_lexer.init; | ||
| return (0, import_es_module_lexer.parse)(content)[1].map((specifier) => specifier.n); | ||
| } | ||
| try { | ||
| await (0, import_cjs_module_lexer.init)(); | ||
| return (0, import_cjs_module_lexer.parse)(content).exports; | ||
| } catch { | ||
| await import_es_module_lexer.init; | ||
| return (0, import_es_module_lexer.parse)(content)[1].map((specifier) => specifier.n); | ||
| } | ||
| } | ||
| function streamToBuffer(stream) { | ||
| return new Promise((resolve, reject) => { | ||
| const buffers = []; | ||
| stream.on("error", (err) => { | ||
| reject(err); | ||
| }); | ||
| stream.on("data", (buffer) => { | ||
| buffers.push(buffer); | ||
| }); | ||
| stream.on("end", () => { | ||
| resolve(Buffer.concat(buffers)); | ||
| }); | ||
| }); | ||
| } | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
@@ -98,0 +39,0 @@ 0 && (module.exports = { |
+1
-1
| { | ||
| "name": "@vercel/build-utils", | ||
| "version": "13.19.0", | ||
| "version": "13.19.1", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 11 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 11 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1727328
-2.88%43218
-0.93%