@vercel/build-utils 14.23.0 → 15.0.1

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/daemons.d.ts +20 -0
  3. package/dist/fs/node-version.js +0 -3
  4. package/dist/fs/stream-to-digest-async.d.ts +0 -1
  5. package/dist/fs/stream-to-digest-async.js +3 -8
  6. package/dist/index.d.ts +2 -29
  7. package/dist/index.js +11 -37
  8. package/dist/schedules.d.ts +4 -0
  9. package/dist/types.d.ts +5 -0
  10. package/package.json +3 -7
  11. package/dist/collect-build-result/file-to-build-output-file.d.ts +0 -26
  12. package/dist/collect-build-result/file-to-build-output-file.js +0 -54
  13. package/dist/collect-build-result/get-build-result-metadata.d.ts +0 -33
  14. package/dist/collect-build-result/get-build-result-metadata.js +0 -99
  15. package/dist/collect-build-result/get-content-type.d.ts +0 -1
  16. package/dist/collect-build-result/get-content-type.js +0 -45
  17. package/dist/collect-build-result/get-lambda-by-output-path.d.ts +0 -13
  18. package/dist/collect-build-result/get-lambda-by-output-path.js +0 -31
  19. package/dist/collect-build-result/get-prerender-chain.d.ts +0 -8
  20. package/dist/collect-build-result/get-prerender-chain.js +0 -44
  21. package/dist/collect-build-result/is-route-middleware.d.ts +0 -4
  22. package/dist/collect-build-result/is-route-middleware.js +0 -30
  23. package/dist/collect-build-result/prerender-to-build-output-file.d.ts +0 -23
  24. package/dist/collect-build-result/prerender-to-build-output-file.js +0 -85
  25. package/dist/collect-build-result/stream-with-extended-payload.d.ts +0 -5
  26. package/dist/collect-build-result/stream-with-extended-payload.js +0 -49
  27. package/dist/collect-build-result/validate-build-result.d.ts +0 -19
  28. package/dist/collect-build-result/validate-build-result.js +0 -139
  29. package/dist/collect-build-result/validate-prerender.d.ts +0 -8
  30. package/dist/collect-build-result/validate-prerender.js +0 -32
  31. package/dist/collect-build-result/validate-regular-file.d.ts +0 -8
  32. package/dist/collect-build-result/validate-regular-file.js +0 -42
  33. package/dist/collect-uncompressed-size.d.ts +0 -6
  34. package/dist/collect-uncompressed-size.js +0 -59
  35. package/dist/deserialize/create-functions-iterator.d.ts +0 -8
  36. package/dist/deserialize/create-functions-iterator.js +0 -52
  37. package/dist/deserialize/deserialize-build-output-types.d.ts +0 -56
  38. package/dist/deserialize/deserialize-build-output-types.js +0 -16
  39. package/dist/deserialize/deserialize-build-output.d.ts +0 -4
  40. package/dist/deserialize/deserialize-build-output.js +0 -296
  41. package/dist/deserialize/deserialize-edge-function.d.ts +0 -5
  42. package/dist/deserialize/deserialize-edge-function.js +0 -47
  43. package/dist/deserialize/deserialize-lambda.d.ts +0 -22
  44. package/dist/deserialize/deserialize-lambda.js +0 -56
  45. package/dist/deserialize/hydrate-files-map.d.ts +0 -3
  46. package/dist/deserialize/hydrate-files-map.js +0 -55
  47. package/dist/deserialize/maybe-read-json.d.ts +0 -5
  48. package/dist/deserialize/maybe-read-json.js +0 -37
  49. package/dist/deserialize/serialized-types.d.ts +0 -32
  50. package/dist/deserialize/serialized-types.js +0 -16
  51. package/dist/deserialize/validate-framework-version.d.ts +0 -6
  52. package/dist/deserialize/validate-framework-version.js +0 -63
  53. package/dist/finalize-lambda.d.ts +0 -77
  54. package/dist/finalize-lambda.js +0 -117
  55. package/dist/process-serverless/get-encrypted-env-file.d.ts +0 -11
  56. package/dist/process-serverless/get-encrypted-env-file.js +0 -47
  57. package/dist/process-serverless/get-lambda-environment.d.ts +0 -19
  58. package/dist/process-serverless/get-lambda-environment.js +0 -53
  59. package/dist/process-serverless/get-lambda-preload-scripts.d.ts +0 -22
  60. package/dist/process-serverless/get-lambda-preload-scripts.js +0 -43
  61. package/dist/process-serverless/get-lambda-supports-streaming.d.ts +0 -22
  62. package/dist/process-serverless/get-lambda-supports-streaming.js +0 -42
  63. package/dist/validate-lambda-size.d.ts +0 -45
  64. package/dist/validate-lambda-size.js +0 -117
@@ -1,77 +0,0 @@
1
- import type { Lambda } from './lambda';
2
- import type { NodejsLambda } from './nodejs-lambda';
3
- import type { BytecodeCachingOptions } from './process-serverless/get-lambda-preload-scripts';
4
- /**
5
- * Optional wrapper around async work, allowing callers to inject tracing
6
- * (e.g. dd-trace spans) without coupling the shared code to a tracer.
7
- */
8
- export type TraceFn = <T>(name: string, fn: () => Promise<T>, tags?: Record<string, string>) => Promise<T>;
9
- /**
10
- * Result of a custom ZIP creation strategy.
11
- */
12
- export interface CreateZipResult {
13
- /** The zip as a Buffer (in-memory), or null for disk-based paths. */
14
- buffer: Buffer | null;
15
- /** Path to the zip file on disk, or undefined for in-memory. */
16
- zipPath?: string;
17
- /** SHA-256 hex digest of the zip contents. */
18
- digest: string;
19
- /** Compressed size in bytes. */
20
- size: number;
21
- }
22
- /**
23
- * Custom ZIP creation strategy. When provided, replaces the default
24
- * in-memory `lambda.createZip()` + `sha256()` path. This allows callers
25
- * to stream large zips to disk instead.
26
- */
27
- export type CreateZipFn = (lambda: Lambda | NodejsLambda) => Promise<CreateZipResult>;
28
- export interface FinalizeLambdaParams {
29
- lambda: Lambda | NodejsLambda;
30
- encryptedEnvFilename?: string;
31
- encryptedEnvContent?: string;
32
- bytecodeCachingOptions: BytecodeCachingOptions;
33
- forceStreamingRuntime: boolean;
34
- /** When true, collect the uncompressed size of lambda files before zipping. */
35
- enableUncompressedLambdaSizeCheck?: boolean;
36
- /** Optional tracing wrapper for `collectUncompressedSize` and `createZip`. */
37
- trace?: TraceFn;
38
- /** Custom ZIP creation strategy. Defaults to in-memory lambda.createZip(). */
39
- createZip?: CreateZipFn;
40
- /**
41
- * Called after ZIP creation but before digest/environment/streaming.
42
- * Throw to abort (e.g. size validation). For the default in-memory path,
43
- * this runs before sha256.
44
- */
45
- validateZip?: (zip: {
46
- buffer: Buffer | null;
47
- zipPath?: string;
48
- size: number;
49
- }) => void;
50
- }
51
- export interface FinalizeLambdaResult {
52
- /** The zip as a Buffer, or null when a custom createZip returns a disk path. */
53
- buffer: Buffer | null;
54
- /** Path to zip on disk (set by custom createZip), null for in-memory. */
55
- zipPath: string | null;
56
- /** SHA-256 hex digest. */
57
- digest: string;
58
- /** Compressed size in bytes. */
59
- size: number;
60
- uncompressedBytes: number;
61
- }
62
- /**
63
- * Core Lambda finalization logic shared between BYOF and build-container.
64
- *
65
- * This function:
66
- * 1. Injects encrypted env file into lambda.files when provided
67
- * 2. Collects uncompressed size when enabled
68
- * 3. Creates the ZIP (in-memory or via custom strategy)
69
- * 4. Runs optional validateZip hook (e.g. size check)
70
- * 5. Computes SHA-256 digest (default path only; custom path provides its own)
71
- * 6. Merges environment variables (bytecode caching, helpers, etc.)
72
- * 7. Detects streaming support
73
- *
74
- * Note: This function mutates the `lambda` (files, environment,
75
- * supportsResponseStreaming).
76
- */
77
- export declare function finalizeLambda(params: FinalizeLambdaParams): Promise<FinalizeLambdaResult>;
@@ -1,117 +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 finalize_lambda_exports = {};
20
- __export(finalize_lambda_exports, {
21
- finalizeLambda: () => finalizeLambda
22
- });
23
- module.exports = __toCommonJS(finalize_lambda_exports);
24
- var import_get_encrypted_env_file = require("./process-serverless/get-encrypted-env-file");
25
- var import_get_lambda_environment = require("./process-serverless/get-lambda-environment");
26
- var import_get_lambda_supports_streaming = require("./process-serverless/get-lambda-supports-streaming");
27
- var import_stream_to_digest_async = require("./fs/stream-to-digest-async");
28
- var import_collect_uncompressed_size = require("./collect-uncompressed-size");
29
- const defaultTrace = (_name, fn) => fn();
30
- async function finalizeLambda(params) {
31
- const {
32
- lambda,
33
- encryptedEnvFilename,
34
- encryptedEnvContent,
35
- bytecodeCachingOptions,
36
- forceStreamingRuntime,
37
- enableUncompressedLambdaSizeCheck,
38
- trace = defaultTrace,
39
- createZip: createZipOverride,
40
- validateZip
41
- } = params;
42
- const encryptedEnv = (0, import_get_encrypted_env_file.getEncryptedEnv)(
43
- encryptedEnvFilename,
44
- encryptedEnvContent
45
- );
46
- if (encryptedEnv) {
47
- const [envFilename, envFile] = encryptedEnv;
48
- lambda.zipBuffer = void 0;
49
- lambda.files = {
50
- ...lambda.files,
51
- [envFilename]: envFile
52
- };
53
- }
54
- let uncompressedBytes = 0;
55
- if (enableUncompressedLambdaSizeCheck) {
56
- if (lambda.files) {
57
- uncompressedBytes = await trace(
58
- "collectUncompressedSize",
59
- () => (0, import_collect_uncompressed_size.collectUncompressedSize)(lambda.files ?? {})
60
- );
61
- }
62
- }
63
- const zipTags = {
64
- fileCount: String(Object.keys(lambda.files ?? {}).length),
65
- uncompressedBytes: String(uncompressedBytes)
66
- };
67
- let zipResult;
68
- if (createZipOverride) {
69
- zipResult = await trace(
70
- "createZip",
71
- () => createZipOverride(lambda),
72
- zipTags
73
- );
74
- } else {
75
- const buffer = lambda.zipBuffer || await trace("createZip", () => lambda.createZip(), zipTags);
76
- zipResult = {
77
- buffer,
78
- digest: "",
79
- // computed in step 5
80
- size: buffer.byteLength
81
- };
82
- }
83
- if (validateZip) {
84
- validateZip({
85
- buffer: zipResult.buffer,
86
- zipPath: zipResult.zipPath,
87
- size: zipResult.size
88
- });
89
- }
90
- if (!createZipOverride && zipResult.buffer) {
91
- zipResult.digest = (0, import_stream_to_digest_async.sha256)(zipResult.buffer);
92
- }
93
- lambda.environment = {
94
- ...lambda.environment,
95
- ...(0, import_get_lambda_environment.getLambdaEnvironment)(
96
- lambda,
97
- zipResult.buffer ?? { byteLength: zipResult.size },
98
- bytecodeCachingOptions
99
- )
100
- };
101
- const streamingResult = (0, import_get_lambda_supports_streaming.getLambdaSupportsStreaming)(
102
- lambda,
103
- forceStreamingRuntime
104
- );
105
- lambda.supportsResponseStreaming = streamingResult;
106
- return {
107
- buffer: zipResult.buffer,
108
- zipPath: zipResult.zipPath ?? null,
109
- digest: zipResult.digest,
110
- size: zipResult.size,
111
- uncompressedBytes
112
- };
113
- }
114
- // Annotate the CommonJS export names for ESM import in node:
115
- 0 && (module.exports = {
116
- finalizeLambda
117
- });
@@ -1,11 +0,0 @@
1
- import FileBlob from '../file-blob';
2
- /**
3
- * A type to represent the encrypted environment file that needs to be
4
- * attached to Lambdas with ENV > 4kb
5
- */
6
- export type EncryptedEnvFile = [string, FileBlob];
7
- /**
8
- * Get the encrypted environment file from the environment variables if it
9
- * exists and it is supported by the runtime.
10
- */
11
- export declare function getEncryptedEnv(envFilename: string | undefined, envContent: string | undefined): EncryptedEnvFile | undefined;
@@ -1,47 +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 get_encrypted_env_file_exports = {};
30
- __export(get_encrypted_env_file_exports, {
31
- getEncryptedEnv: () => getEncryptedEnv
32
- });
33
- module.exports = __toCommonJS(get_encrypted_env_file_exports);
34
- var import_file_blob = __toESM(require("../file-blob"));
35
- function getEncryptedEnv(envFilename, envContent) {
36
- if (!envFilename || !envContent) {
37
- return;
38
- }
39
- return [
40
- envFilename,
41
- new import_file_blob.default({ data: Buffer.from(envContent, "base64") })
42
- ];
43
- }
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- getEncryptedEnv
47
- });
@@ -1,19 +0,0 @@
1
- import { type BytecodeCachingOptions } from './get-lambda-preload-scripts';
2
- interface LambdaLike {
3
- awsLambdaHandler?: string;
4
- launcherType?: string;
5
- runtime: string;
6
- shouldAddHelpers?: boolean;
7
- shouldAddSourcemapSupport?: boolean;
8
- useWebApi?: boolean;
9
- shouldDisableAutomaticFetchInstrumentation?: boolean;
10
- }
11
- /**
12
- * Extract system environment variables that need to be injected in the Lambda.
13
- * Buffer is required just to determine if Bytecode Caching should be enabled
14
- * but it doesn't need to be super precise.
15
- */
16
- export declare function getLambdaEnvironment(lambda: LambdaLike, buffer: {
17
- byteLength: number;
18
- }, options: BytecodeCachingOptions): Record<string, string>;
19
- export {};
@@ -1,53 +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 get_lambda_environment_exports = {};
20
- __export(get_lambda_environment_exports, {
21
- getLambdaEnvironment: () => getLambdaEnvironment
22
- });
23
- module.exports = __toCommonJS(get_lambda_environment_exports);
24
- var import_get_lambda_preload_scripts = require("./get-lambda-preload-scripts");
25
- function getLambdaEnvironment(lambda, buffer, options) {
26
- const environment = {};
27
- if ("launcherType" in lambda && lambda.launcherType === "Nodejs") {
28
- if (lambda.awsLambdaHandler) {
29
- environment.AWS_LAMBDA_HANDLER = lambda.awsLambdaHandler;
30
- }
31
- if (lambda.shouldAddHelpers) {
32
- environment.VERCEL_SHOULD_ADD_HELPERS = "1";
33
- }
34
- if (lambda.useWebApi === true) {
35
- environment.VERCEL_USE_WEB_API = "1";
36
- }
37
- if (lambda.shouldAddSourcemapSupport) {
38
- environment.VERCEL_SOURCE_MAP = "1";
39
- }
40
- if (lambda.shouldDisableAutomaticFetchInstrumentation) {
41
- environment.VERCEL_TRACING_DISABLE_AUTOMATIC_FETCH_INSTRUMENTATION = "1";
42
- }
43
- const scripts = (0, import_get_lambda_preload_scripts.getLambdaPreloadScripts)(lambda, buffer, options);
44
- if (scripts.length > 0) {
45
- environment.VERCEL_NODE_PRELOAD_SCRIPTS = scripts.join(",");
46
- }
47
- }
48
- return environment;
49
- }
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- getLambdaEnvironment
53
- });
@@ -1,22 +0,0 @@
1
- export interface BytecodeCachingOptions {
2
- vercelEnv: string | undefined;
3
- useBytecodeCaching: string | undefined;
4
- useNativeBytecodeCaching: string | undefined;
5
- bytecodeCachingThreshold: string | undefined;
6
- }
7
- interface LambdaLike {
8
- framework?: {
9
- slug: string;
10
- };
11
- runtime: string;
12
- shouldAddSourcemapSupport?: boolean;
13
- }
14
- /**
15
- * Returns an array of scripts that should be preloaded in Node.js Lambdas.
16
- * The `buffer` parameter is needed to decide wether or not to enable Bytecode
17
- * Caching so it doesn't **need** to be exact (we can leave out the env layer)
18
- */
19
- export declare function getLambdaPreloadScripts(lambda: LambdaLike, buffer: {
20
- byteLength: number;
21
- }, options: BytecodeCachingOptions): string[];
22
- export {};
@@ -1,43 +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 get_lambda_preload_scripts_exports = {};
20
- __export(get_lambda_preload_scripts_exports, {
21
- getLambdaPreloadScripts: () => getLambdaPreloadScripts
22
- });
23
- module.exports = __toCommonJS(get_lambda_preload_scripts_exports);
24
- function getLambdaPreloadScripts(lambda, buffer, options) {
25
- const scripts = [];
26
- if (lambda.shouldAddSourcemapSupport) {
27
- scripts.push("/opt/rust/source-map-support.js");
28
- }
29
- const BYTECODE_MIN_SIZE_BYTES = (Number.parseInt(options.bytecodeCachingThreshold || "", 10) || 400) * 1024;
30
- if (options.vercelEnv === "production" && options.useBytecodeCaching === "1" && ["nodejs20.x", "nodejs22.x", "nodejs24.x"].includes(lambda.runtime) && buffer.byteLength >= BYTECODE_MIN_SIZE_BYTES) {
31
- scripts.push(
32
- ["nodejs22.x", "nodejs24.x"].includes(lambda.runtime) && options.useNativeBytecodeCaching === "1" ? "/opt/rust/bytecode-native.js" : "/opt/rust/bytecode.js"
33
- );
34
- }
35
- if (lambda.framework?.slug === "nextjs") {
36
- scripts.push("/opt/rust/next-data.js");
37
- }
38
- return scripts;
39
- }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- getLambdaPreloadScripts
43
- });
@@ -1,22 +0,0 @@
1
- interface LambdaLike {
2
- awsLambdaHandler?: string;
3
- handler: string;
4
- launcherType?: string;
5
- runtime: string;
6
- supportsResponseStreaming?: boolean;
7
- }
8
- /**
9
- * Determines if a Lambda should have streaming enabled.
10
- *
11
- * AWS custom handlers cannot stream — the handler contract returns a
12
- * response object, not a stream — so they always resolve to `false`,
13
- * even when `forceStreamingRuntime` is set. This mirrors
14
- * `deserializeLambda`, which also refuses to force streaming on lambdas
15
- * with an `awsLambdaHandler` set.
16
- *
17
- * Otherwise: if `forceStreamingRuntime` is true, streaming is always
18
- * enabled. If the setting is defined it will be honored. Enabled by
19
- * default for Node.js.
20
- */
21
- export declare function getLambdaSupportsStreaming(lambda: LambdaLike, forceStreamingRuntime: boolean): boolean | undefined;
22
- export {};
@@ -1,42 +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 get_lambda_supports_streaming_exports = {};
20
- __export(get_lambda_supports_streaming_exports, {
21
- getLambdaSupportsStreaming: () => getLambdaSupportsStreaming
22
- });
23
- module.exports = __toCommonJS(get_lambda_supports_streaming_exports);
24
- function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
25
- if (lambda.awsLambdaHandler) {
26
- return false;
27
- }
28
- if (forceStreamingRuntime) {
29
- return true;
30
- }
31
- if (typeof lambda.supportsResponseStreaming === "boolean") {
32
- return lambda.supportsResponseStreaming;
33
- }
34
- if ("launcherType" in lambda && lambda.launcherType === "Nodejs") {
35
- return true;
36
- }
37
- return void 0;
38
- }
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- getLambdaSupportsStreaming
42
- });
@@ -1,45 +0,0 @@
1
- import { NowBuildError } from './errors';
2
- /**
3
- * Max compressed ZIP size (300 MB).
4
- * Limit is 250 MB uncompressed; we set 300 MB compressed as a safety
5
- * buffer. Python is exempt because AI workloads commonly exceed this.
6
- */
7
- export declare const MAX_LAMBDA_SIZE: number;
8
- /**
9
- * Max uncompressed size (250 MB).
10
- */
11
- export declare const MAX_LAMBDA_UNCOMPRESSED_SIZE: number;
12
- /**
13
- * Error thrown when a Lambda's compressed ZIP exceeds the allowed size.
14
- */
15
- export declare class FunctionSizeError extends NowBuildError {
16
- size: number;
17
- maxSize: number;
18
- constructor(outputPath: string, size: number);
19
- }
20
- /**
21
- * Validates the compressed size of a Lambda function.
22
- * Python runtimes are exempt because AI workloads commonly exceed 300 MB.
23
- */
24
- export declare function validateLambdaSize(outputPath: string, runtime: string, size: number): void;
25
- /**
26
- * Validates the uncompressed size of a Lambda function.
27
- */
28
- export declare function validateUncompressedLambdaSize(outputPath: string, uncompressedBytes: number): void;
29
- /**
30
- * Runtimes that support env wrapper.
31
- */
32
- export declare const ENV_WRAPPER_SUPPORTED_FAMILIES: string[];
33
- interface LambdaLikeForEnvWrapper {
34
- createZip?: () => Promise<Buffer>;
35
- runtime: string;
36
- supportsWrapper?: boolean;
37
- }
38
- /**
39
- * When the function requires a file for the encrypted environment variables,
40
- * it needs to support wrappers. Also, the function must have a `createZip`
41
- * function since we need to "re-compress" to include the file in the final
42
- * lambda.
43
- */
44
- export declare function validateEnvWrapperSupport(encryptedEnvFilename: string | undefined, encryptedEnvContent: string | undefined, lambda: LambdaLikeForEnvWrapper): void;
45
- export {};
@@ -1,117 +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 validate_lambda_size_exports = {};
30
- __export(validate_lambda_size_exports, {
31
- ENV_WRAPPER_SUPPORTED_FAMILIES: () => ENV_WRAPPER_SUPPORTED_FAMILIES,
32
- FunctionSizeError: () => FunctionSizeError,
33
- MAX_LAMBDA_SIZE: () => MAX_LAMBDA_SIZE,
34
- MAX_LAMBDA_UNCOMPRESSED_SIZE: () => MAX_LAMBDA_UNCOMPRESSED_SIZE,
35
- validateEnvWrapperSupport: () => validateEnvWrapperSupport,
36
- validateLambdaSize: () => validateLambdaSize,
37
- validateUncompressedLambdaSize: () => validateUncompressedLambdaSize
38
- });
39
- module.exports = __toCommonJS(validate_lambda_size_exports);
40
- var import_errors = require("./errors");
41
- var import_bytes = __toESM(require("bytes"));
42
- const MAX_LAMBDA_SIZE = (0, import_bytes.default)("300mb");
43
- const MAX_LAMBDA_UNCOMPRESSED_SIZE = 250 * 1024 * 1024;
44
- class FunctionSizeError extends import_errors.NowBuildError {
45
- constructor(outputPath, size) {
46
- super({
47
- code: "NOW_SANDBOX_WORKER_MAX_LAMBDA_SIZE",
48
- message: `The Vercel Function "${outputPath}" is ${(0, import_bytes.default)(
49
- size
50
- ).toLowerCase()} which exceeds the maximum size limit of ${(0, import_bytes.default)(
51
- MAX_LAMBDA_SIZE
52
- ).toLowerCase()}.`,
53
- link: "https://vercel.link/serverless-function-size",
54
- action: "Learn More"
55
- });
56
- this.size = size;
57
- this.maxSize = MAX_LAMBDA_SIZE;
58
- }
59
- }
60
- function validateLambdaSize(outputPath, runtime, size) {
61
- if (runtime.startsWith("python")) {
62
- return;
63
- }
64
- if (size > MAX_LAMBDA_SIZE) {
65
- throw new FunctionSizeError(outputPath, size);
66
- }
67
- }
68
- function validateUncompressedLambdaSize(outputPath, uncompressedBytes) {
69
- if (uncompressedBytes >= MAX_LAMBDA_UNCOMPRESSED_SIZE) {
70
- throw new import_errors.NowBuildError({
71
- code: "NOW_SANDBOX_WORKER_MAX_UNCOMPRESSED_LAMBDA_SIZE",
72
- message: `The Vercel Function "${outputPath}" is ${(0, import_bytes.default)(
73
- uncompressedBytes
74
- ).toLowerCase()} uncompressed which exceeds the maximum uncompressed size limit of ${(0, import_bytes.default)(
75
- MAX_LAMBDA_UNCOMPRESSED_SIZE
76
- ).toLowerCase()}.`,
77
- link: "https://vercel.link/serverless-function-size",
78
- action: "Learn More"
79
- });
80
- }
81
- }
82
- const ENV_WRAPPER_SUPPORTED_FAMILIES = [
83
- "nodejs",
84
- "python",
85
- "ruby",
86
- "java",
87
- "dotnetcore",
88
- "bun",
89
- "executable"
90
- ];
91
- function validateEnvWrapperSupport(encryptedEnvFilename, encryptedEnvContent, lambda) {
92
- if (!encryptedEnvFilename || !encryptedEnvContent) {
93
- return;
94
- }
95
- if (!lambda.supportsWrapper && !ENV_WRAPPER_SUPPORTED_FAMILIES.some(
96
- (family) => lambda.runtime.startsWith(family)
97
- )) {
98
- throw new Error(
99
- `Serverless Function runtime ${lambda.runtime} does not support more than 4KB for environment variables`
100
- );
101
- }
102
- if (typeof lambda.createZip !== "function") {
103
- throw new Error(
104
- `Serverless Function with runtime ${lambda.runtime} has no createZip function`
105
- );
106
- }
107
- }
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
110
- ENV_WRAPPER_SUPPORTED_FAMILIES,
111
- FunctionSizeError,
112
- MAX_LAMBDA_SIZE,
113
- MAX_LAMBDA_UNCOMPRESSED_SIZE,
114
- validateEnvWrapperSupport,
115
- validateLambdaSize,
116
- validateUncompressedLambdaSize
117
- });