@vercel/backends 0.0.22 → 0.0.23
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/dist/index.mjs +63 -22
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -54346,8 +54346,9 @@ ${error.message}`;
|
|
|
54346
54346
|
NodeVersion: () => NodeVersion,
|
|
54347
54347
|
NodejsLambda: () => NodejsLambda$1,
|
|
54348
54348
|
NowBuildError: () => NowBuildError,
|
|
54349
|
+
PYTHON_FRAMEWORKS: () => PYTHON_FRAMEWORKS,
|
|
54349
54350
|
Prerender: () => Prerender,
|
|
54350
|
-
Span: () => Span,
|
|
54351
|
+
Span: () => Span$1,
|
|
54351
54352
|
Version: () => Version,
|
|
54352
54353
|
buildsSchema: () => buildsSchema,
|
|
54353
54354
|
cloneEnv: () => cloneEnv,
|
|
@@ -54358,6 +54359,7 @@ ${error.message}`;
|
|
|
54358
54359
|
download: () => download$1,
|
|
54359
54360
|
downloadFile: () => downloadFile,
|
|
54360
54361
|
execCommand: () => execCommand$1,
|
|
54362
|
+
findPackageJson: () => findPackageJson,
|
|
54361
54363
|
functionsSchema: () => functionsSchema,
|
|
54362
54364
|
generateNodeBuilderFunctions: () => generateNodeBuilderFunctions,
|
|
54363
54365
|
getDiscontinuedNodeVersions: () => getDiscontinuedNodeVersions,
|
|
@@ -54368,6 +54370,7 @@ ${error.message}`;
|
|
|
54368
54370
|
getLatestNodeVersion: () => getLatestNodeVersion,
|
|
54369
54371
|
getNodeBinPath: () => getNodeBinPath,
|
|
54370
54372
|
getNodeBinPaths: () => getNodeBinPaths$1,
|
|
54373
|
+
getNodeVersion: () => getNodeVersion$1,
|
|
54371
54374
|
getOsRelease: () => getOsRelease,
|
|
54372
54375
|
getPackageJson: () => getPackageJson$1,
|
|
54373
54376
|
getPathForPackageManager: () => getPathForPackageManager,
|
|
@@ -54375,7 +54378,6 @@ ${error.message}`;
|
|
|
54375
54378
|
getPrefixedEnvVars: () => getPrefixedEnvVars,
|
|
54376
54379
|
getPrettyError: () => getPrettyError,
|
|
54377
54380
|
getProvidedRuntime: () => getProvidedRuntime,
|
|
54378
|
-
getRuntimeNodeVersion: () => getRuntimeNodeVersion$1,
|
|
54379
54381
|
getScriptName: () => getScriptName$1,
|
|
54380
54382
|
getSpawnOptions: () => getSpawnOptions,
|
|
54381
54383
|
getSupportedBunVersion: () => getSupportedBunVersion,
|
|
@@ -54391,6 +54393,7 @@ ${error.message}`;
|
|
|
54391
54393
|
isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
|
|
54392
54394
|
isExperimentalBackendsWithoutIntrospectionEnabled: () => isExperimentalBackendsWithoutIntrospectionEnabled,
|
|
54393
54395
|
isPythonEntrypoint: () => isPythonEntrypoint,
|
|
54396
|
+
isPythonFramework: () => isPythonFramework,
|
|
54394
54397
|
isSymbolicLink: () => isSymbolicLink,
|
|
54395
54398
|
normalizePath: () => normalizePath,
|
|
54396
54399
|
readConfigFile: () => readConfigFile,
|
|
@@ -54856,7 +54859,7 @@ ${error.message}`;
|
|
|
54856
54859
|
(0, import_assert4.default)(typeof runtime === "string", "\"runtime\" is not a string");
|
|
54857
54860
|
(0, import_assert4.default)(typeof environment === "object", "\"environment\" is not an object");
|
|
54858
54861
|
if (architecture !== void 0) (0, import_assert4.default)(architecture === "x86_64" || architecture === "arm64", "\"architecture\" must be either \"x86_64\" or \"arm64\"");
|
|
54859
|
-
if (runtimeLanguage !== void 0) (0, import_assert4.default)(runtimeLanguage === "rust", "\"runtimeLanguage\"
|
|
54862
|
+
if (runtimeLanguage !== void 0) (0, import_assert4.default)(runtimeLanguage === "rust" || runtimeLanguage === "go", "\"runtimeLanguage\" is invalid. Valid options: \"rust\", \"go\"");
|
|
54860
54863
|
if ("experimentalAllowBundling" in opts && opts.experimentalAllowBundling !== void 0) (0, import_assert4.default)(typeof opts.experimentalAllowBundling === "boolean", "\"experimentalAllowBundling\" is not a boolean");
|
|
54861
54864
|
if (memory !== void 0) (0, import_assert4.default)(typeof memory === "number", "\"memory\" is not a number");
|
|
54862
54865
|
if (maxDuration !== void 0) (0, import_assert4.default)(typeof maxDuration === "number", "\"maxDuration\" is not a number");
|
|
@@ -55464,14 +55467,14 @@ ${error.message}`;
|
|
|
55464
55467
|
}
|
|
55465
55468
|
return opts;
|
|
55466
55469
|
}
|
|
55467
|
-
async function
|
|
55470
|
+
async function getNodeVersion$1(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = getAvailableNodeVersions()) {
|
|
55468
55471
|
if (config.bunVersion) return getSupportedBunVersion(config.bunVersion);
|
|
55469
55472
|
const latestVersion = getLatestNodeVersion(availableVersions);
|
|
55470
55473
|
if (meta.isDev) {
|
|
55471
55474
|
latestVersion.runtime = "nodejs";
|
|
55472
55475
|
return latestVersion;
|
|
55473
55476
|
}
|
|
55474
|
-
const { packageJson } = await
|
|
55477
|
+
const { packageJson } = await findPackageJson(destPath, true);
|
|
55475
55478
|
const configuredVersion = config.nodeVersion || fallbackVersion;
|
|
55476
55479
|
const packageJsonVersion = packageJson?.engines?.node;
|
|
55477
55480
|
const supportedNodeVersion = await getSupportedNodeVersion(packageJsonVersion || configuredVersion, !packageJsonVersion, availableVersions);
|
|
@@ -55483,7 +55486,7 @@ ${error.message}`;
|
|
|
55483
55486
|
}
|
|
55484
55487
|
return supportedNodeVersion;
|
|
55485
55488
|
}
|
|
55486
|
-
async function
|
|
55489
|
+
async function findPackageJson(destPath, readPackageJson = false, base = "/") {
|
|
55487
55490
|
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55488
55491
|
const pkgJsonPath = await walkParentDirs({
|
|
55489
55492
|
base,
|
|
@@ -55496,6 +55499,14 @@ ${error.message}`;
|
|
|
55496
55499
|
} catch (err) {
|
|
55497
55500
|
throw new Error(`Could not read ${pkgJsonPath}: ${err.message}.`);
|
|
55498
55501
|
}
|
|
55502
|
+
return {
|
|
55503
|
+
packageJsonPath: pkgJsonPath || void 0,
|
|
55504
|
+
packageJson
|
|
55505
|
+
};
|
|
55506
|
+
}
|
|
55507
|
+
async function scanParentDirs$1(destPath, readPackageJson = false, base = "/") {
|
|
55508
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55509
|
+
const { packageJsonPath: pkgJsonPath, packageJson } = await findPackageJson(destPath, readPackageJson, base);
|
|
55499
55510
|
const { paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockTextPath, bunLockBinPath, vltLockPath], packageJsonPackageManager } = await walkParentDirsMulti({
|
|
55500
55511
|
base,
|
|
55501
55512
|
start: destPath,
|
|
@@ -56043,19 +56054,26 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56043
56054
|
async function runPipInstall(destPath, args = [], spawnOpts, meta) {
|
|
56044
56055
|
if (meta && meta.isDev) {
|
|
56045
56056
|
debug$2("Skipping dependency installation because dev mode is enabled");
|
|
56046
|
-
return;
|
|
56057
|
+
return { installed: false };
|
|
56047
56058
|
}
|
|
56048
56059
|
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
56060
|
+
const targetDir = import_path6.default.join(destPath, ".vercel_python_packages");
|
|
56049
56061
|
const opts = {
|
|
56050
56062
|
...spawnOpts,
|
|
56051
56063
|
cwd: destPath,
|
|
56052
|
-
prettyCommand: "
|
|
56064
|
+
prettyCommand: "uv pip install"
|
|
56053
56065
|
};
|
|
56054
|
-
await spawnAsync("
|
|
56066
|
+
await spawnAsync("uv", [
|
|
56067
|
+
"pip",
|
|
56055
56068
|
"install",
|
|
56056
|
-
"--
|
|
56069
|
+
"--target",
|
|
56070
|
+
targetDir,
|
|
56057
56071
|
...args
|
|
56058
56072
|
], opts);
|
|
56073
|
+
return {
|
|
56074
|
+
installed: true,
|
|
56075
|
+
targetDir
|
|
56076
|
+
};
|
|
56059
56077
|
}
|
|
56060
56078
|
function getScriptName$1(pkg, possibleNames) {
|
|
56061
56079
|
if (pkg?.scripts) {
|
|
@@ -56333,7 +56351,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56333
56351
|
function mapUndefinedAttributes(attrs) {
|
|
56334
56352
|
return Object.fromEntries(Object.entries(attrs ?? {}).filter((attr) => !!attr[1]));
|
|
56335
56353
|
}
|
|
56336
|
-
var Span = class _Span {
|
|
56354
|
+
var Span$1 = class _Span {
|
|
56337
56355
|
constructor({ name, parentId, attrs, reporter }) {
|
|
56338
56356
|
this.name = name;
|
|
56339
56357
|
this.parentId = parentId;
|
|
@@ -56507,6 +56525,11 @@ ${entrypointsForMessage}`);
|
|
|
56507
56525
|
"fastify",
|
|
56508
56526
|
"elysia"
|
|
56509
56527
|
];
|
|
56528
|
+
var PYTHON_FRAMEWORKS = [
|
|
56529
|
+
"fastapi",
|
|
56530
|
+
"flask",
|
|
56531
|
+
"python"
|
|
56532
|
+
];
|
|
56510
56533
|
var BACKEND_BUILDERS = [
|
|
56511
56534
|
"@vercel/express",
|
|
56512
56535
|
"@vercel/hono",
|
|
@@ -56520,6 +56543,10 @@ ${entrypointsForMessage}`);
|
|
|
56520
56543
|
if (!framework) return false;
|
|
56521
56544
|
return BACKEND_FRAMEWORKS.includes(framework);
|
|
56522
56545
|
}
|
|
56546
|
+
function isPythonFramework(framework) {
|
|
56547
|
+
if (!framework) return false;
|
|
56548
|
+
return PYTHON_FRAMEWORKS.includes(framework);
|
|
56549
|
+
}
|
|
56523
56550
|
function isExperimentalBackendsWithoutIntrospectionEnabled() {
|
|
56524
56551
|
return process.env.VERCEL_BACKENDS_BUILDS === "1";
|
|
56525
56552
|
}
|
|
@@ -56770,18 +56797,32 @@ var import_dist = require_dist$1();
|
|
|
56770
56797
|
const version = 2;
|
|
56771
56798
|
const build = async (args) => {
|
|
56772
56799
|
const downloadResult = await downloadInstallAndBundle(args);
|
|
56773
|
-
const nodeVersion = await (0, import_dist.
|
|
56774
|
-
const
|
|
56800
|
+
const nodeVersion = await (0, import_dist.getNodeVersion)(args.workPath);
|
|
56801
|
+
const builderName = "@vercel/backends";
|
|
56802
|
+
const span = args.span ?? new import_dist.Span({ name: builderName });
|
|
56803
|
+
span.setAttributes({ "builder.name": builderName });
|
|
56804
|
+
const outputConfig = await span.child("vc.builder.backends.doBuild").trace(async (span$1) => {
|
|
56805
|
+
const result = await doBuild(args, downloadResult);
|
|
56806
|
+
span$1.setAttributes({
|
|
56807
|
+
"outputConfig.dir": result.dir,
|
|
56808
|
+
"outputConfig.handler": result.handler
|
|
56809
|
+
});
|
|
56810
|
+
return result;
|
|
56811
|
+
});
|
|
56775
56812
|
(0, import_dist.debug)("Node file trace starting..");
|
|
56776
|
-
const nftPromise = nodeFileTrace$1(args, nodeVersion, outputConfig);
|
|
56813
|
+
const nftPromise = span.child("vc.builder.backends.nodeFileTrace").trace(() => nodeFileTrace$1(args, nodeVersion, outputConfig));
|
|
56777
56814
|
(0, import_dist.debug)("Introspection starting..");
|
|
56778
|
-
const { routes, framework } = await introspectApp({
|
|
56779
|
-
|
|
56780
|
-
|
|
56781
|
-
|
|
56782
|
-
|
|
56783
|
-
|
|
56784
|
-
|
|
56815
|
+
const { routes, framework } = await span.child("vc.builder.backends.introspectApp").trace(async (span$1) => {
|
|
56816
|
+
const result = await introspectApp({
|
|
56817
|
+
...outputConfig,
|
|
56818
|
+
framework: args.config.framework,
|
|
56819
|
+
env: {
|
|
56820
|
+
...args.meta?.env ?? {},
|
|
56821
|
+
...args.meta?.buildEnv ?? {}
|
|
56822
|
+
}
|
|
56823
|
+
});
|
|
56824
|
+
span$1.setAttributes({ "introspectApp.routes": String(result.routes.length) });
|
|
56825
|
+
return result;
|
|
56785
56826
|
});
|
|
56786
56827
|
if (routes.length > 2) (0, import_dist.debug)(`Introspection completed successfully with ${routes.length} routes`);
|
|
56787
56828
|
else (0, import_dist.debug)(`Introspection failed to detect routes`);
|
|
@@ -56806,7 +56847,7 @@ const build = async (args) => {
|
|
|
56806
56847
|
if (route.dest === "/") continue;
|
|
56807
56848
|
output[route.dest] = lambda;
|
|
56808
56849
|
}
|
|
56809
|
-
if (outputConfig.tsPromise) await outputConfig.tsPromise;
|
|
56850
|
+
if (outputConfig.tsPromise) await span.child("vc.builder.backends.tsCompile").trace(() => outputConfig.tsPromise);
|
|
56810
56851
|
return {
|
|
56811
56852
|
routes,
|
|
56812
56853
|
output
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/backends",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@vercel/nft": "1.1.1",
|
|
25
25
|
"fs-extra": "11.1.0",
|
|
26
|
-
"@vercel/cervel": "0.0.9",
|
|
27
26
|
"@vercel/static-config": "3.1.2",
|
|
28
|
-
"@vercel/
|
|
27
|
+
"@vercel/cervel": "0.0.10",
|
|
28
|
+
"@vercel/introspection": "0.0.10"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/express": "5.0.3",
|
|
32
32
|
"@types/fs-extra": "11",
|
|
33
33
|
"@types/jest": "27.5.1",
|
|
34
|
-
"@types/node": "
|
|
34
|
+
"@types/node": "20.11.0",
|
|
35
35
|
"execa": "3.2.0",
|
|
36
36
|
"hono": "4.10.1",
|
|
37
37
|
"jest-junit": "16.0.0",
|
|
38
38
|
"tsdown": "0.16.3",
|
|
39
39
|
"vite": "^5.1.6",
|
|
40
40
|
"vitest": "^2.0.1",
|
|
41
|
-
"@vercel/build-utils": "13.2.
|
|
41
|
+
"@vercel/build-utils": "13.2.14"
|
|
42
42
|
},
|
|
43
43
|
"module": "./dist/index.mjs",
|
|
44
44
|
"types": "./dist/index.d.mts",
|