@vercel/build-utils 13.17.1 → 13.19.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 +22 -0
- package/dist/collect-build-result/validate-build-result.d.ts +21 -0
- package/dist/collect-build-result/validate-build-result.js +140 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +509 -345
- package/dist/package-manifest.d.ts +25 -0
- package/dist/package-manifest.js +71 -0
- package/dist/types.d.ts +33 -13
- package/dist/types.js +25 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [services] move Python workers to v2beta triggers with private routing ([#15920](https://github.com/vercel/vercel/pull/15920))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Added a shared build result validation helper in `@vercel/build-utils` for existing callers. ([#16030](https://github.com/vercel/vercel/pull/16030))
|
|
12
|
+
|
|
13
|
+
## 13.18.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- Generate PROJECTMANIFEST in @vercel/backends for Node deployments. ([#15991](https://github.com/vercel/vercel/pull/15991))
|
|
18
|
+
|
|
19
|
+
## 13.17.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [experimental-services] add new job service type support ([#15944](https://github.com/vercel/vercel/pull/15944))
|
|
24
|
+
|
|
3
25
|
## 13.17.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BuildResultV2Typical, BuildResultV3, BuilderFunctions, Config } from '../types';
|
|
2
|
+
export declare const SUPPORTED_AL2023_RUNTIMES: readonly ["nodejs20.x", "nodejs22.x", "nodejs24.x", "provided.al2023", "python3.12", "python3.13", "python3.14", "ruby3.3", "bun1.x", "executable"];
|
|
3
|
+
type BuildConfigWithVercelConfig = Config & {
|
|
4
|
+
vercelConfig?: {
|
|
5
|
+
functions?: BuilderFunctions;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export interface ValidateBuildResultParams {
|
|
9
|
+
allowInvalidRuntime?: boolean;
|
|
10
|
+
buildConfig?: BuildConfigWithVercelConfig;
|
|
11
|
+
buildResponse: BuildResultV2Typical | BuildResultV3;
|
|
12
|
+
osRelease?: OsRelease | null;
|
|
13
|
+
vercelBaseUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ValidateBuildResultResult {
|
|
16
|
+
buildOutputMap: BuildResultV2Typical['output'];
|
|
17
|
+
customFunctionConfiguration?: BuilderFunctions[string];
|
|
18
|
+
}
|
|
19
|
+
type OsRelease = Record<string, string>;
|
|
20
|
+
export declare function validateBuildResult({ allowInvalidRuntime, buildConfig, buildResponse, osRelease, vercelBaseUrl, }: ValidateBuildResultParams): Promise<ValidateBuildResultResult>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
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_build_result_exports = {};
|
|
30
|
+
__export(validate_build_result_exports, {
|
|
31
|
+
SUPPORTED_AL2023_RUNTIMES: () => SUPPORTED_AL2023_RUNTIMES,
|
|
32
|
+
validateBuildResult: () => validateBuildResult
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(validate_build_result_exports);
|
|
35
|
+
var import_minimatch = __toESM(require("minimatch"));
|
|
36
|
+
var import_errors = require("../errors");
|
|
37
|
+
const SUPPORTED_AL2023_RUNTIMES = [
|
|
38
|
+
"nodejs20.x",
|
|
39
|
+
"nodejs22.x",
|
|
40
|
+
"nodejs24.x",
|
|
41
|
+
"provided.al2023",
|
|
42
|
+
"python3.12",
|
|
43
|
+
"python3.13",
|
|
44
|
+
"python3.14",
|
|
45
|
+
"ruby3.3",
|
|
46
|
+
"bun1.x",
|
|
47
|
+
"executable"
|
|
48
|
+
];
|
|
49
|
+
const DEFAULT_ENTRYPOINT = ".";
|
|
50
|
+
const DEVELOPING_A_RUNTIME_URL = "https://github.com/vercel/vercel/blob/master/DEVELOPING_A_RUNTIME.md";
|
|
51
|
+
function isSupportedAl2023Runtime(runtime) {
|
|
52
|
+
return SUPPORTED_AL2023_RUNTIMES.some((supported) => supported === runtime);
|
|
53
|
+
}
|
|
54
|
+
async function validateBuildResult({
|
|
55
|
+
allowInvalidRuntime = false,
|
|
56
|
+
buildConfig,
|
|
57
|
+
buildResponse,
|
|
58
|
+
osRelease,
|
|
59
|
+
vercelBaseUrl
|
|
60
|
+
}) {
|
|
61
|
+
if (!("output" in buildResponse)) {
|
|
62
|
+
throw new import_errors.NowBuildError({
|
|
63
|
+
code: "NOW_SANDBOX_WORKER_BUILDER_ERROR",
|
|
64
|
+
message: 'The result of "builder.build" must include an `output` property for "@vercel/vc-build".'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (!buildResponse.output || typeof buildResponse.output !== "object") {
|
|
68
|
+
throw new import_errors.NowBuildError({
|
|
69
|
+
code: "NOW_SANDBOX_WORKER_BUILDER_ERROR",
|
|
70
|
+
message: 'The result of "builder.build" must be an object'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const buildOutputMap = getAndVerifyOutputLambdasOrEdgeFuncs(buildResponse);
|
|
74
|
+
if (osRelease?.VERSION === "2023") {
|
|
75
|
+
const invalidRuntimes = [];
|
|
76
|
+
for (const [name, entry] of Object.entries(buildOutputMap)) {
|
|
77
|
+
let lambda;
|
|
78
|
+
if (entry.type === "Prerender") {
|
|
79
|
+
lambda = entry.lambda;
|
|
80
|
+
} else if (entry.type === "Lambda") {
|
|
81
|
+
lambda = entry;
|
|
82
|
+
}
|
|
83
|
+
if (!lambda)
|
|
84
|
+
continue;
|
|
85
|
+
if (!isSupportedAl2023Runtime(lambda.runtime)) {
|
|
86
|
+
invalidRuntimes.push({ name, lambda });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (invalidRuntimes.length > 0 && !allowInvalidRuntime) {
|
|
90
|
+
throw new import_errors.NowBuildError({
|
|
91
|
+
code: "NOW_SANDBOX_WORKER_INVALID_RUNTIME",
|
|
92
|
+
message: `The following Serverless Functions contain an invalid "runtime":
|
|
93
|
+
${invalidRuntimes.map(({ name, lambda }) => ` - ${name} (${lambda.runtime})`).join("\n")}`,
|
|
94
|
+
link: getVercelUrl(
|
|
95
|
+
"/docs/functions/runtimes#official-runtimes",
|
|
96
|
+
vercelBaseUrl
|
|
97
|
+
)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const customFunctionConfiguration = getCustomFunctionConfigMaybe(buildConfig);
|
|
102
|
+
if (customFunctionConfiguration?.runtime) {
|
|
103
|
+
throw new import_errors.NowBuildError({
|
|
104
|
+
code: "NOW_SANDBOX_WORKER_FUNCTION_RUNTIME_VERSION",
|
|
105
|
+
message: `The Community Runtime ${customFunctionConfiguration.runtime} is not using version 3 of the Runtime API. If you are the Runtime author, see the docs by clicking "View Details" above.`,
|
|
106
|
+
link: DEVELOPING_A_RUNTIME_URL
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
buildOutputMap,
|
|
111
|
+
customFunctionConfiguration
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function getCustomFunctionConfigMaybe(buildConfig) {
|
|
115
|
+
const functions = buildConfig?.functions ?? buildConfig?.vercelConfig?.functions;
|
|
116
|
+
if (!functions) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
for (const [funcPath, config] of Object.entries(functions)) {
|
|
120
|
+
if (funcPath === DEFAULT_ENTRYPOINT || (0, import_minimatch.default)(DEFAULT_ENTRYPOINT, funcPath)) {
|
|
121
|
+
return config;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
function getVercelUrl(path, vercelBaseUrl = "https://vercel.com") {
|
|
127
|
+
const url = new URL(path, vercelBaseUrl);
|
|
128
|
+
if (url.pathname === "/") {
|
|
129
|
+
return url.href.slice(0, -1);
|
|
130
|
+
}
|
|
131
|
+
return url.href;
|
|
132
|
+
}
|
|
133
|
+
function getAndVerifyOutputLambdasOrEdgeFuncs(buildResponse) {
|
|
134
|
+
return buildResponse.output;
|
|
135
|
+
}
|
|
136
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
+
0 && (module.exports = {
|
|
138
|
+
SUPPORTED_AL2023_RUNTIMES,
|
|
139
|
+
validateBuildResult
|
|
140
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { normalizePath } from './fs/normalize-path';
|
|
|
27
27
|
export { getOsRelease, getProvidedRuntime } from './os';
|
|
28
28
|
export * from './should-serve';
|
|
29
29
|
export * from './schemas';
|
|
30
|
+
export * from './package-manifest';
|
|
30
31
|
export * from './types';
|
|
31
32
|
export * from './errors';
|
|
32
33
|
export * from './trace';
|
|
@@ -44,6 +45,7 @@ export { getLambdaPreloadScripts, type BytecodeCachingOptions, } from './process
|
|
|
44
45
|
export { getLambdaSupportsStreaming, type SupportsStreamingResult, } from './process-serverless/get-lambda-supports-streaming';
|
|
45
46
|
export { streamToDigestAsync, sha256, md5, type FileDigest, } from './fs/stream-to-digest-async';
|
|
46
47
|
export { getBuildResultMetadata, type BuildResultMetadata, } from './collect-build-result/get-build-result-metadata';
|
|
48
|
+
export { validateBuildResult, SUPPORTED_AL2023_RUNTIMES, type ValidateBuildResultParams, type ValidateBuildResultResult, } from './collect-build-result/validate-build-result';
|
|
47
49
|
export { getLambdaByOutputPath } from './collect-build-result/get-lambda-by-output-path';
|
|
48
50
|
export { isRouteMiddleware } from './collect-build-result/is-route-middleware';
|
|
49
51
|
export { getPrerenderChain } from './collect-build-result/get-prerender-chain';
|