@vercel/build-utils 13.3.0 → 13.3.2
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 +17 -0
- package/build.mjs +11 -1
- package/dist/file-blob.js +8 -1
- package/dist/get-service-url-env-vars.d.ts +28 -0
- package/dist/get-service-url-env-vars.js +76 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +71 -1942
- package/dist/python.d.ts +0 -13
- package/dist/python.js +4 -37
- package/package.json +6 -3
- package/lib/python/ast_parser.py +0 -72
- package/lib/python/tests/test_ast_parser.py +0 -72
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve memory efficiency in `FileBlob.fromStream()` by avoiding unnecessary buffer copies when chunks are already Buffers ([#14701](https://github.com/vercel/vercel/pull/14701))
|
|
8
|
+
|
|
9
|
+
- [services] build time service url env vars ([#14893](https://github.com/vercel/vercel/pull/14893))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`7a747344dfb778a650da2ee5f7fba8c974098b42`](https://github.com/vercel/vercel/commit/7a747344dfb778a650da2ee5f7fba8c974098b42)]:
|
|
12
|
+
- @vercel/python-analysis@0.3.1
|
|
13
|
+
|
|
14
|
+
## 13.3.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Replace Python-based AST parser with WASM-based `@vercel/python-analysis` for detecting Python entrypoints. This eliminates the need for a Python runtime when analyzing Python files for WSGI/ASGI application patterns. ([#14843](https://github.com/vercel/vercel/pull/14843))
|
|
19
|
+
|
|
3
20
|
## 13.3.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/build.mjs
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import { tsc, esbuild } from '../../utils/build.mjs';
|
|
2
2
|
|
|
3
|
-
await Promise.all([
|
|
3
|
+
await Promise.all([
|
|
4
|
+
tsc(),
|
|
5
|
+
esbuild().then(() =>
|
|
6
|
+
esbuild({
|
|
7
|
+
bundle: true,
|
|
8
|
+
// Keep @vercel/python-analysis external because its WASM module uses
|
|
9
|
+
// require.resolve.
|
|
10
|
+
external: ['@vercel/python-analysis'],
|
|
11
|
+
})
|
|
12
|
+
),
|
|
13
|
+
]);
|
package/dist/file-blob.js
CHANGED
|
@@ -51,7 +51,14 @@ class FileBlob {
|
|
|
51
51
|
(0, import_assert.default)(typeof stream.pipe === "function");
|
|
52
52
|
const chunks = [];
|
|
53
53
|
await new Promise((resolve, reject) => {
|
|
54
|
-
stream.on(
|
|
54
|
+
stream.on(
|
|
55
|
+
"data",
|
|
56
|
+
(chunk) => (
|
|
57
|
+
// Usually the chunks we receive here are already buffers, so we
|
|
58
|
+
// avoid the extra buffer copy in those cases to save memory
|
|
59
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))
|
|
60
|
+
)
|
|
61
|
+
);
|
|
55
62
|
stream.on("error", (error) => reject(error));
|
|
56
63
|
stream.on("end", () => resolve());
|
|
57
64
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Service } from './types';
|
|
2
|
+
type Envs = {
|
|
3
|
+
[key: string]: string | undefined;
|
|
4
|
+
};
|
|
5
|
+
interface FrameworkInfo {
|
|
6
|
+
slug: string | null;
|
|
7
|
+
envPrefix?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GetServiceUrlEnvVarsOptions {
|
|
10
|
+
services: Service[];
|
|
11
|
+
frameworkList: readonly FrameworkInfo[];
|
|
12
|
+
currentEnv?: Envs;
|
|
13
|
+
deploymentUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generate environment variables for service URLs.
|
|
17
|
+
*
|
|
18
|
+
* For each web service, generates:
|
|
19
|
+
* 1. A base env var (e.g., BACKEND_URL)
|
|
20
|
+
* 2. Framework-prefixed versions for each frontend framework in the deployment
|
|
21
|
+
* (e.g., VITE_BACKEND_URL, NEXT_PUBLIC_BACKEND_URL) so they can be accessed
|
|
22
|
+
* in client-side code.
|
|
23
|
+
*
|
|
24
|
+
* Environment variables that are already set in `currentEnv` will NOT be overwritten,
|
|
25
|
+
* allowing user-defined values to take precedence.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getServiceUrlEnvVars(options: GetServiceUrlEnvVarsOptions): Record<string, string>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
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_service_url_env_vars_exports = {};
|
|
20
|
+
__export(get_service_url_env_vars_exports, {
|
|
21
|
+
getServiceUrlEnvVars: () => getServiceUrlEnvVars
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_service_url_env_vars_exports);
|
|
24
|
+
function serviceNameToEnvVar(name) {
|
|
25
|
+
return `${name.replace(/-/g, "_").toUpperCase()}_URL`;
|
|
26
|
+
}
|
|
27
|
+
function computeServiceUrl(deploymentUrl, routePrefix) {
|
|
28
|
+
if (routePrefix === "/") {
|
|
29
|
+
return `https://${deploymentUrl}`;
|
|
30
|
+
}
|
|
31
|
+
const normalizedPrefix = routePrefix.startsWith("/") ? routePrefix.slice(1) : routePrefix;
|
|
32
|
+
return `https://${deploymentUrl}/${normalizedPrefix}`;
|
|
33
|
+
}
|
|
34
|
+
function getFrameworkEnvPrefix(frameworkSlug, frameworkList) {
|
|
35
|
+
if (!frameworkSlug)
|
|
36
|
+
return void 0;
|
|
37
|
+
const framework = frameworkList.find(
|
|
38
|
+
(f) => f.slug !== null && f.slug === frameworkSlug
|
|
39
|
+
);
|
|
40
|
+
return framework?.envPrefix;
|
|
41
|
+
}
|
|
42
|
+
function getServiceUrlEnvVars(options) {
|
|
43
|
+
const { services, frameworkList, currentEnv = {}, deploymentUrl } = options;
|
|
44
|
+
if (!deploymentUrl || !services || services.length === 0) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
const envVars = {};
|
|
48
|
+
const frameworkPrefixes = /* @__PURE__ */ new Set();
|
|
49
|
+
for (const service of services) {
|
|
50
|
+
const prefix = getFrameworkEnvPrefix(service.framework, frameworkList);
|
|
51
|
+
if (prefix) {
|
|
52
|
+
frameworkPrefixes.add(prefix);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const service of services) {
|
|
56
|
+
if (service.type !== "web" || !service.routePrefix) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const baseEnvVarName = serviceNameToEnvVar(service.name);
|
|
60
|
+
const url = computeServiceUrl(deploymentUrl, service.routePrefix);
|
|
61
|
+
if (!(baseEnvVarName in currentEnv)) {
|
|
62
|
+
envVars[baseEnvVarName] = url;
|
|
63
|
+
}
|
|
64
|
+
for (const prefix of frameworkPrefixes) {
|
|
65
|
+
const prefixedEnvVarName = `${prefix}${baseEnvVarName}`;
|
|
66
|
+
if (!(prefixedEnvVarName in currentEnv)) {
|
|
67
|
+
envVars[prefixedEnvVarName] = url;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return envVars;
|
|
72
|
+
}
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
getServiceUrlEnvVars
|
|
76
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,11 @@ import debug from './debug';
|
|
|
15
15
|
import getIgnoreFilter from './get-ignore-filter';
|
|
16
16
|
import { getPlatformEnv } from './get-platform-env';
|
|
17
17
|
import { getPrefixedEnvVars } from './get-prefixed-env-vars';
|
|
18
|
+
import { getServiceUrlEnvVars } from './get-service-url-env-vars';
|
|
18
19
|
import { cloneEnv } from './clone-env';
|
|
19
20
|
import { hardLinkDir } from './hard-link-dir';
|
|
20
21
|
import { validateNpmrc } from './validate-npmrc';
|
|
21
|
-
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, detectPackageManager, runNpmInstall, runBundleInstall, runPipInstall, PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
|
|
22
|
+
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, detectPackageManager, runNpmInstall, runBundleInstall, runPipInstall, PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
|
|
22
23
|
export { EdgeFunction } from './edge-function';
|
|
23
24
|
export { readConfigFile, getPackageJson } from './fs/read-config-file';
|
|
24
25
|
export { normalizePath } from './fs/normalize-path';
|