🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@vercel/build-utils

Package Overview
Dependencies
Maintainers
3
Versions
426
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/build-utils - npm Package Compare versions

Comparing version
13.19.0
to
13.19.1
+6
-0
CHANGELOG.md
# @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

@@ -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 {};
+1
-60

@@ -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 = {

{
"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