🚨 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
2
Versions
427
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.15.0
to
13.16.0
+26
dist/collect-build-result/file-to-build-output-file.d.ts
import type { FileDigest } from '../fs/stream-to-digest-async';
import type FileFsRef from '../file-fs-ref';
import type FileRef from '../file-ref';
import type FileBlob from '../file-blob';
export interface BuildOutputFile {
contentType?: string;
digest: string;
lambda: null;
mode: number;
path: string;
paths?: string[];
size?: number;
type?: 'file';
prerenderPath?: string;
}
export declare function fileToBuildOutputFile(params: {
buildResult: FileBlob | FileFsRef | FileRef;
extendedBody?: {
prefix: string;
suffix: string;
};
outputPath: string;
}): Promise<{
output: BuildOutputFile;
digest: FileDigest;
}>;
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var file_to_build_output_file_exports = {};
__export(file_to_build_output_file_exports, {
fileToBuildOutputFile: () => fileToBuildOutputFile
});
module.exports = __toCommonJS(file_to_build_output_file_exports);
var import_stream_to_digest_async = require("../fs/stream-to-digest-async");
var import_stream_with_extended_payload = require("./stream-with-extended-payload");
var import_validate_regular_file = require("./validate-regular-file");
var import_get_content_type = require("./get-content-type");
async function fileToBuildOutputFile(params) {
await (0, import_validate_regular_file.validateRegularFile)(params.buildResult);
const digest = await (0, import_stream_to_digest_async.streamToDigestAsync)(
(0, import_stream_with_extended_payload.streamWithExtendedPayload)(
params.buildResult.toStreamAsync ? await params.buildResult.toStreamAsync() : params.buildResult.toStream(),
params.extendedBody
)
);
const contentType = params.buildResult.contentType ? params.buildResult.contentType : "fsPath" in params.buildResult ? (0, import_get_content_type.getContentType)(params.buildResult.fsPath) : void 0;
return {
digest,
output: {
type: "file",
path: params.outputPath,
prerenderPath: params.buildResult.prerenderPath,
digest: digest.sha256,
mode: params.buildResult.mode,
contentType,
size: digest.size,
lambda: null
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
fileToBuildOutputFile
});
export declare function getContentType(path: string): string;
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var get_content_type_exports = {};
__export(get_content_type_exports, {
getContentType: () => getContentType
});
module.exports = __toCommonJS(get_content_type_exports);
var import_path = require("path");
var import_mime_types = __toESM(require("mime-types"));
function getContentType(path) {
if (path.endsWith(".html")) {
return "text/html; charset=utf-8";
}
return import_mime_types.default.contentType((0, import_path.extname)(path)) || "application/octet-stream";
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getContentType
});
import type { FileDigest } from '../fs/stream-to-digest-async';
import type { Prerender } from '../prerender';
import type { File } from '../types';
import { type BuildOutputFile } from './file-to-build-output-file';
interface PrerenderToBuildOutputFileResult {
digest: FileDigest;
extended: ExtendedPayload;
file: File;
output: BuildOutputFile;
}
export declare function prerenderToBuildOutputFile(params: {
buildResult: Prerender;
outputPath: string;
}): Promise<PrerenderToBuildOutputFileResult | null>;
export interface ExtendedPayload {
extendedBody: {
prefix: string;
suffix: string;
} | undefined;
fallback?: File | null;
initialHeaders: Record<string, string> | undefined;
}
export {};
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var prerender_to_build_output_file_exports = {};
__export(prerender_to_build_output_file_exports, {
prerenderToBuildOutputFile: () => prerenderToBuildOutputFile
});
module.exports = __toCommonJS(prerender_to_build_output_file_exports);
var import_file_blob = __toESM(require("../file-blob"));
var import_crypto = require("crypto");
var import_file_to_build_output_file = require("./file-to-build-output-file");
async function prerenderToBuildOutputFile(params) {
const extended = getExtendedPayload(params.buildResult);
if (!extended.fallback) {
return null;
}
const filePath = params.outputPath + ".fallback";
const { output, digest } = await (0, import_file_to_build_output_file.fileToBuildOutputFile)({
outputPath: filePath,
buildResult: extended.fallback,
extendedBody: extended.extendedBody
});
return {
file: extended.fallback,
output,
digest,
extended
};
}
const CRLF = "\r\n";
const MULTIPART_HEADER = "multipart/x-nextjs-extended-payload";
function getExtendedPayload({
initialHeaders,
fallback
}) {
if (!initialHeaders || !Object.entries(initialHeaders).length) {
return { initialHeaders: void 0, fallback, extendedBody: void 0 };
}
const boundary = (0, import_crypto.randomBytes)(8).toString("hex");
return {
initialHeaders: {
...fallback ? {} : { "x-vercel-empty-fallback": "true" },
"content-type": `${MULTIPART_HEADER}; boundary=${boundary}`
},
fallback: fallback ?? new import_file_blob.default({ data: "" }),
extendedBody: {
suffix: `${CRLF}${CRLF}--${boundary}--${CRLF}`,
prefix: [
`--${boundary}`,
...Object.entries(initialHeaders).map(
([key, value]) => `${key}: ${value}`
)
].join(CRLF) + CRLF + CRLF
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
prerenderToBuildOutputFile
});
import type { Lambda } from '../lambda';
interface PrerenderLike {
lambda?: Lambda;
}
export declare function validatePrerender(prerender: PrerenderLike): asserts prerender is {
lambda: Lambda;
};
export {};
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var validate_prerender_exports = {};
__export(validate_prerender_exports, {
validatePrerender: () => validatePrerender
});
module.exports = __toCommonJS(validate_prerender_exports);
function validatePrerender(prerender) {
if (typeof prerender.lambda === "undefined") {
throw new Error(`Prerender "buildResult" is missing "lambda" property`);
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
validatePrerender
});
/// <reference types="node" />
import type FileFsRef from '../file-fs-ref';
import { type Stats } from 'fs-extra';
interface FileLike {
fsPath?: string;
}
export declare function validateRegularFile(file: FileFsRef): Promise<Stats>;
export declare function validateRegularFile<T extends object>(file: FileLike | T): Promise<Stats | null>;
export {};
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var validate_regular_file_exports = {};
__export(validate_regular_file_exports, {
validateRegularFile: () => validateRegularFile
});
module.exports = __toCommonJS(validate_regular_file_exports);
var import_errors = require("../errors");
var import_fs_extra = require("fs-extra");
async function validateRegularFile(file) {
if ("fsPath" in file && typeof file.fsPath === "string") {
const stat = await (0, import_fs_extra.lstat)(file.fsPath);
if (!stat.isFile() && !stat.isDirectory() && !stat.isSymbolicLink()) {
throw new import_errors.NowBuildError({
message: `Output file path is actually not a (regular) file: \`${file.fsPath}\``,
code: "OUTPUT_FILE_IS_NOT_REGULAR_FILE"
});
}
return stat;
}
return null;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
validateRegularFile
});
import type { Files } from '../types';
import { EdgeFunction } from '../edge-function';
import type FileFsRef from '../file-fs-ref';
import type { SerializedEdgeFunction } from './serialized-types';
export declare function deserializeEdgeFunction(files: Files, config: SerializedEdgeFunction, repoRootPath: string, fileFsRefsCache: Map<string, FileFsRef>): Promise<EdgeFunction>;
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var deserialize_edge_function_exports = {};
__export(deserialize_edge_function_exports, {
deserializeEdgeFunction: () => deserializeEdgeFunction
});
module.exports = __toCommonJS(deserialize_edge_function_exports);
var import_edge_function = require("../edge-function");
var import_hydrate_files_map = require("./hydrate-files-map");
async function deserializeEdgeFunction(files, config, repoRootPath, fileFsRefsCache) {
if (config.filePathMap) {
await (0, import_hydrate_files_map.hydrateFilesMap)(
files,
config.filePathMap,
repoRootPath,
fileFsRefsCache
);
}
const edgeFunction = new import_edge_function.EdgeFunction({
// "v8-worker" is currently the only supported target, so specify
// it implicitly here so that `.vc-config.json` does not need to.
deploymentTarget: "v8-worker",
...config,
files
});
return edgeFunction;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
deserializeEdgeFunction
});
import type { Files } from '../types';
import { Lambda } from '../lambda';
import { NodejsLambda } from '../nodejs-lambda';
import type FileFsRef from '../file-fs-ref';
import type { SerializedLambda, SerializedNodejsLambda } from './serialized-types';
export interface DeserializeLambdaOptions {
useOnlyStreamingLambda?: boolean;
forceNodejsStreaming?: boolean;
/**
* Custom Lambda class constructor. Defaults to the base Lambda class.
* Pass an extended class (e.g. with BYOC `external` property) to
* preserve extra properties through deserialization.
*/
LambdaClass?: typeof Lambda;
/**
* Custom NodejsLambda class constructor. Defaults to the base NodejsLambda class.
* Pass an extended class (e.g. with BYOC `external` property) to
* preserve extra properties through deserialization.
*/
NodejsLambdaClass?: typeof NodejsLambda;
}
export declare function deserializeLambda(files: Files, config: SerializedLambda | SerializedNodejsLambda, repoRootPath: string, fileFsRefsCache: Map<string, FileFsRef>, options?: DeserializeLambdaOptions): Promise<Lambda>;
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var deserialize_lambda_exports = {};
__export(deserialize_lambda_exports, {
deserializeLambda: () => deserializeLambda
});
module.exports = __toCommonJS(deserialize_lambda_exports);
var import_lambda = require("../lambda");
var import_nodejs_lambda = require("../nodejs-lambda");
var import_hydrate_files_map = require("./hydrate-files-map");
async function deserializeLambda(files, config, repoRootPath, fileFsRefsCache, options) {
const LambdaCtor = options?.LambdaClass ?? import_lambda.Lambda;
const NodejsLambdaCtor = options?.NodejsLambdaClass ?? import_nodejs_lambda.NodejsLambda;
if (config.filePathMap) {
await (0, import_hydrate_files_map.hydrateFilesMap)(
files,
config.filePathMap,
repoRootPath,
fileFsRefsCache
);
}
const supportsResponseStreaming = config.supportsResponseStreaming ?? config.experimentalResponseStreaming;
if ("launcherType" in config && config.launcherType === "Nodejs") {
const overrideResponseStreaming = (options?.useOnlyStreamingLambda || options?.forceNodejsStreaming) && (config.awsLambdaHandler === void 0 || config.awsLambdaHandler === "");
return new NodejsLambdaCtor({
...config,
supportsResponseStreaming: overrideResponseStreaming || supportsResponseStreaming,
files
});
}
return new LambdaCtor({
...config,
supportsResponseStreaming,
files
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
deserializeLambda
});
import type { Lambda } from '../lambda';
import type { NodejsLambda } from '../nodejs-lambda';
import type { EdgeFunction } from '../edge-function';
import type FileFsRef from '../file-fs-ref';
import type { Prerender } from '../prerender';
/**
* Maps a type to a new type that does not contain any functions on it.
* Useful for typing serialized `class` types, which will not contain
* functions when serialized to JSON.
*/
export type Properties<T> = {
[P in keyof T as T[P] extends (...args: any[]) => any ? never : P]: T[P];
};
type FilesMapProp = {
filePathMap?: Record<string, string>;
};
/**
* Type for the `.vc-config.json` file of a serialized
* `ServerlessFunction` instance.
*/
export type SerializedLambda = Properties<Omit<Lambda, 'files' | 'zipBuffer'>> & FilesMapProp;
export type SerializedNodejsLambda = Properties<Omit<NodejsLambda, 'files' | 'zipBuffer'>> & FilesMapProp;
export type SerializedFileFsRef = Properties<FileFsRef>;
export type SerializedPrerender = Properties<Omit<Prerender, 'lambda' | 'fallback'>> & {
fallback: SerializedFileFsRef | null;
};
export type SerializedEdgeFunction = Properties<Omit<EdgeFunction, 'name' | 'files' | 'deploymentTarget'>> & FilesMapProp;
export {};
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var serialized_types_exports = {};
module.exports = __toCommonJS(serialized_types_exports);
+10
-0
# @vercel/build-utils
## 13.16.0
### Minor Changes
- Add shared deserialization and build-result collection utilities. ([#15961](https://github.com/vercel/vercel/pull/15961))
- Add root to experimentalServices to set a service's working directory. ([#15929](https://github.com/vercel/vercel/pull/15929))
- Add a new flag to vercel deploy to let users deploy to hive ([#15892](https://github.com/vercel/vercel/pull/15892))
## 13.15.0

@@ -4,0 +14,0 @@

+1
-1

@@ -6,3 +6,3 @@ import { Builder } from '.';

export declare const BACKEND_FRAMEWORKS: readonly ["express", "hono", "h3", "koa", "nestjs", "fastify", "elysia"];
export declare const PYTHON_FRAMEWORKS: readonly ["fastapi", "flask", "django", "python"];
export declare const PYTHON_FRAMEWORKS: readonly ["fastapi", "flask", "django", "python", "fasthtml"];
export declare const RUNTIME_FRAMEWORKS: readonly ["python"];

@@ -9,0 +9,0 @@ /**

@@ -48,4 +48,5 @@ "use strict";

"django",
"python"
"python",
// Generic Python framework preset
"fasthtml"
];

@@ -52,0 +53,0 @@ const RUNTIME_FRAMEWORKS = ["python"];

@@ -57,1 +57,9 @@ import FileBlob from './file-blob';

export { maybeReadJSON } from './deserialize/maybe-read-json';
export { deserializeLambda, type DeserializeLambdaOptions, } from './deserialize/deserialize-lambda';
export { deserializeEdgeFunction } from './deserialize/deserialize-edge-function';
export type { Properties, SerializedLambda, SerializedNodejsLambda, SerializedEdgeFunction, SerializedFileFsRef, SerializedPrerender, } from './deserialize/serialized-types';
export { validateRegularFile } from './collect-build-result/validate-regular-file';
export { validatePrerender } from './collect-build-result/validate-prerender';
export { getContentType } from './collect-build-result/get-content-type';
export { fileToBuildOutputFile, type BuildOutputFile, } from './collect-build-result/file-to-build-output-file';
export { prerenderToBuildOutputFile, type ExtendedPayload, } from './collect-build-result/prerender-to-build-output-file';

@@ -674,3 +674,9 @@ /// <reference types="node" />

/**
* Service entrypoint, relative to the project root.
* Path to the service's root directory relative to the project root.
* Should contain a manifest file (package.json, pyproject.toml, etc.).
* Defaults to ".".
*/
root?: string;
/**
* Service entrypoint, relative to the service root directory.
* Can be either a file path (runtime entrypoint) or a directory path

@@ -677,0 +683,0 @@ * (service workspace for framework-based services).

{
"name": "@vercel/build-utils",
"version": "13.15.0",
"version": "13.16.0",
"license": "Apache-2.0",

@@ -29,2 +29,3 @@ "main": "./dist/index.js",

"@types/js-yaml": "3.12.1",
"@types/mime-types": "2.1.0",
"@types/minimatch": "^5.1.2",

@@ -49,2 +50,3 @@ "@types/ms": "0.7.31",

"js-yaml": "3.13.1",
"mime-types": "2.1.28",
"minimatch": "3.1.2",

@@ -51,0 +53,0 @@ "ms": "2.1.3",

Sorry, the diff of this file is too big to display