@vercel/backends 0.0.22 → 0.0.24
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 +147 -108
- package/package.json +6 -8
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { delimiter, dirname, join
|
|
3
|
-
import { existsSync, lstatSync, readFileSync } from "fs";
|
|
2
|
+
import { delimiter, dirname, join } from "path";
|
|
4
3
|
import { introspectApp } from "@vercel/introspection";
|
|
5
|
-
import {
|
|
6
|
-
import { join as join$1, relative as relative$1 } from "node:path";
|
|
7
|
-
import { existsSync as existsSync$1 } from "node:fs";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
8
5
|
import { writeFile } from "node:fs/promises";
|
|
9
|
-
import {
|
|
6
|
+
import { join as join$1 } from "node:path";
|
|
7
|
+
import { build as build$1, findEntrypoint, getBuildSummary, nodeFileTrace } from "@vercel/cervel";
|
|
10
8
|
|
|
11
9
|
//#region rolldown:runtime
|
|
12
10
|
var __getOwnPropNames$1 = Object.getOwnPropertyNames;
|
|
@@ -3714,10 +3712,10 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
|
|
|
3714
3712
|
});
|
|
3715
3713
|
}
|
|
3716
3714
|
function _createSymlink(srcpath, dstpath, type, callback) {
|
|
3717
|
-
symlinkPaths(srcpath, dstpath, (err, relative
|
|
3715
|
+
symlinkPaths(srcpath, dstpath, (err, relative) => {
|
|
3718
3716
|
if (err) return callback(err);
|
|
3719
|
-
srcpath = relative
|
|
3720
|
-
symlinkType(relative
|
|
3717
|
+
srcpath = relative.toDst;
|
|
3718
|
+
symlinkType(relative.toCwd, type, (err2, type2) => {
|
|
3721
3719
|
if (err2) return callback(err2);
|
|
3722
3720
|
const dir = path7.dirname(dstpath);
|
|
3723
3721
|
pathExists(dir, (err3, dirExists) => {
|
|
@@ -3739,9 +3737,9 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
|
|
|
3739
3737
|
if (stats && stats.isSymbolicLink()) {
|
|
3740
3738
|
if (areIdentical(fs7.statSync(srcpath), fs7.statSync(dstpath))) return;
|
|
3741
3739
|
}
|
|
3742
|
-
const relative
|
|
3743
|
-
srcpath = relative
|
|
3744
|
-
type = symlinkTypeSync(relative
|
|
3740
|
+
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
3741
|
+
srcpath = relative.toDst;
|
|
3742
|
+
type = symlinkTypeSync(relative.toCwd, type);
|
|
3745
3743
|
const dir = path7.dirname(dstpath);
|
|
3746
3744
|
if (fs7.existsSync(dir)) return fs7.symlinkSync(srcpath, dstpath, type);
|
|
3747
3745
|
mkdirsSync(dir);
|
|
@@ -3812,7 +3810,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
|
|
|
3812
3810
|
return obj;
|
|
3813
3811
|
}
|
|
3814
3812
|
var readFile4 = universalify.fromPromise(_readFile);
|
|
3815
|
-
function readFileSync
|
|
3813
|
+
function readFileSync(file, options = {}) {
|
|
3816
3814
|
if (typeof options === "string") options = { encoding: options };
|
|
3817
3815
|
const fs7 = options.fs || _fs;
|
|
3818
3816
|
const shouldThrow = "throws" in options ? options.throws : true;
|
|
@@ -3840,7 +3838,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
|
|
|
3840
3838
|
}
|
|
3841
3839
|
module2.exports = {
|
|
3842
3840
|
readFile: readFile4,
|
|
3843
|
-
readFileSync
|
|
3841
|
+
readFileSync,
|
|
3844
3842
|
writeFile: writeFile$1,
|
|
3845
3843
|
writeFileSync
|
|
3846
3844
|
};
|
|
@@ -54338,7 +54336,7 @@ ${error.message}`;
|
|
|
54338
54336
|
BUILDER_INSTALLER_STEP: () => BUILDER_INSTALLER_STEP,
|
|
54339
54337
|
BunVersion: () => BunVersion,
|
|
54340
54338
|
EdgeFunction: () => EdgeFunction,
|
|
54341
|
-
FileBlob: () => FileBlob
|
|
54339
|
+
FileBlob: () => FileBlob,
|
|
54342
54340
|
FileFsRef: () => file_fs_ref_default,
|
|
54343
54341
|
FileRef: () => FileRef,
|
|
54344
54342
|
Lambda: () => Lambda,
|
|
@@ -54346,8 +54344,9 @@ ${error.message}`;
|
|
|
54346
54344
|
NodeVersion: () => NodeVersion,
|
|
54347
54345
|
NodejsLambda: () => NodejsLambda$1,
|
|
54348
54346
|
NowBuildError: () => NowBuildError,
|
|
54347
|
+
PYTHON_FRAMEWORKS: () => PYTHON_FRAMEWORKS,
|
|
54349
54348
|
Prerender: () => Prerender,
|
|
54350
|
-
Span: () => Span,
|
|
54349
|
+
Span: () => Span$1,
|
|
54351
54350
|
Version: () => Version,
|
|
54352
54351
|
buildsSchema: () => buildsSchema,
|
|
54353
54352
|
cloneEnv: () => cloneEnv,
|
|
@@ -54358,6 +54357,7 @@ ${error.message}`;
|
|
|
54358
54357
|
download: () => download$1,
|
|
54359
54358
|
downloadFile: () => downloadFile,
|
|
54360
54359
|
execCommand: () => execCommand$1,
|
|
54360
|
+
findPackageJson: () => findPackageJson,
|
|
54361
54361
|
functionsSchema: () => functionsSchema,
|
|
54362
54362
|
generateNodeBuilderFunctions: () => generateNodeBuilderFunctions,
|
|
54363
54363
|
getDiscontinuedNodeVersions: () => getDiscontinuedNodeVersions,
|
|
@@ -54368,6 +54368,7 @@ ${error.message}`;
|
|
|
54368
54368
|
getLatestNodeVersion: () => getLatestNodeVersion,
|
|
54369
54369
|
getNodeBinPath: () => getNodeBinPath,
|
|
54370
54370
|
getNodeBinPaths: () => getNodeBinPaths$1,
|
|
54371
|
+
getNodeVersion: () => getNodeVersion$1,
|
|
54371
54372
|
getOsRelease: () => getOsRelease,
|
|
54372
54373
|
getPackageJson: () => getPackageJson$1,
|
|
54373
54374
|
getPathForPackageManager: () => getPathForPackageManager,
|
|
@@ -54375,7 +54376,6 @@ ${error.message}`;
|
|
|
54375
54376
|
getPrefixedEnvVars: () => getPrefixedEnvVars,
|
|
54376
54377
|
getPrettyError: () => getPrettyError,
|
|
54377
54378
|
getProvidedRuntime: () => getProvidedRuntime,
|
|
54378
|
-
getRuntimeNodeVersion: () => getRuntimeNodeVersion$1,
|
|
54379
54379
|
getScriptName: () => getScriptName$1,
|
|
54380
54380
|
getSpawnOptions: () => getSpawnOptions,
|
|
54381
54381
|
getSupportedBunVersion: () => getSupportedBunVersion,
|
|
@@ -54386,11 +54386,12 @@ ${error.message}`;
|
|
|
54386
54386
|
installDependencies: () => installDependencies,
|
|
54387
54387
|
isBackendBuilder: () => isBackendBuilder,
|
|
54388
54388
|
isBackendFramework: () => isBackendFramework,
|
|
54389
|
-
isBunVersion: () => isBunVersion
|
|
54389
|
+
isBunVersion: () => isBunVersion,
|
|
54390
54390
|
isDirectory: () => isDirectory,
|
|
54391
54391
|
isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
|
|
54392
54392
|
isExperimentalBackendsWithoutIntrospectionEnabled: () => isExperimentalBackendsWithoutIntrospectionEnabled,
|
|
54393
54393
|
isPythonEntrypoint: () => isPythonEntrypoint,
|
|
54394
|
+
isPythonFramework: () => isPythonFramework,
|
|
54394
54395
|
isSymbolicLink: () => isSymbolicLink,
|
|
54395
54396
|
normalizePath: () => normalizePath,
|
|
54396
54397
|
readConfigFile: () => readConfigFile,
|
|
@@ -54417,7 +54418,7 @@ ${error.message}`;
|
|
|
54417
54418
|
module.exports = __toCommonJS(src_exports);
|
|
54418
54419
|
var import_assert = __toESM(__require("assert"));
|
|
54419
54420
|
var import_into_stream = __toESM(require_into_stream());
|
|
54420
|
-
var FileBlob
|
|
54421
|
+
var FileBlob = class _FileBlob {
|
|
54421
54422
|
constructor({ mode = 33188, contentType, data }) {
|
|
54422
54423
|
(0, import_assert.default)(typeof mode === "number");
|
|
54423
54424
|
(0, import_assert.default)(typeof data === "string" || Buffer.isBuffer(data));
|
|
@@ -54454,7 +54455,7 @@ ${error.message}`;
|
|
|
54454
54455
|
var import_path = __toESM(__require("path"));
|
|
54455
54456
|
var import_async_sema = __toESM(require_async_sema());
|
|
54456
54457
|
var semaToPreventEMFILE = new import_async_sema.default(20);
|
|
54457
|
-
var FileFsRef
|
|
54458
|
+
var FileFsRef = class _FileFsRef {
|
|
54458
54459
|
constructor({ mode = 33188, contentType, fsPath, size }) {
|
|
54459
54460
|
(0, import_assert2.default)(typeof mode === "number");
|
|
54460
54461
|
(0, import_assert2.default)(typeof fsPath === "string");
|
|
@@ -54518,7 +54519,7 @@ ${error.message}`;
|
|
|
54518
54519
|
});
|
|
54519
54520
|
}
|
|
54520
54521
|
};
|
|
54521
|
-
var file_fs_ref_default = FileFsRef
|
|
54522
|
+
var file_fs_ref_default = FileFsRef;
|
|
54522
54523
|
var import_assert3 = __toESM(__require("assert"));
|
|
54523
54524
|
var import_node_fetch = __toESM(require_lib3());
|
|
54524
54525
|
var import_multistream2 = __toESM(require_multistream());
|
|
@@ -54856,7 +54857,7 @@ ${error.message}`;
|
|
|
54856
54857
|
(0, import_assert4.default)(typeof runtime === "string", "\"runtime\" is not a string");
|
|
54857
54858
|
(0, import_assert4.default)(typeof environment === "object", "\"environment\" is not an object");
|
|
54858
54859
|
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\"
|
|
54860
|
+
if (runtimeLanguage !== void 0) (0, import_assert4.default)(runtimeLanguage === "rust" || runtimeLanguage === "go", "\"runtimeLanguage\" is invalid. Valid options: \"rust\", \"go\"");
|
|
54860
54861
|
if ("experimentalAllowBundling" in opts && opts.experimentalAllowBundling !== void 0) (0, import_assert4.default)(typeof opts.experimentalAllowBundling === "boolean", "\"experimentalAllowBundling\" is not a boolean");
|
|
54861
54862
|
if (memory !== void 0) (0, import_assert4.default)(typeof memory === "number", "\"memory\" is not a number");
|
|
54862
54863
|
if (maxDuration !== void 0) (0, import_assert4.default)(typeof maxDuration === "number", "\"maxDuration\" is not a number");
|
|
@@ -54898,6 +54899,10 @@ ${error.message}`;
|
|
|
54898
54899
|
(0, import_assert4.default)(typeof trigger.initialDelaySeconds === "number", `${prefix}.initialDelaySeconds must be a number`);
|
|
54899
54900
|
(0, import_assert4.default)(trigger.initialDelaySeconds >= 0, `${prefix}.initialDelaySeconds must be a non-negative number`);
|
|
54900
54901
|
}
|
|
54902
|
+
if (trigger.maxConcurrency !== void 0) {
|
|
54903
|
+
(0, import_assert4.default)(typeof trigger.maxConcurrency === "number", `${prefix}.maxConcurrency must be a number`);
|
|
54904
|
+
(0, import_assert4.default)(Number.isInteger(trigger.maxConcurrency) && trigger.maxConcurrency >= 1, `${prefix}.maxConcurrency must be at least 1`);
|
|
54905
|
+
}
|
|
54901
54906
|
}
|
|
54902
54907
|
}
|
|
54903
54908
|
if (supportsCancellation !== void 0) (0, import_assert4.default)(typeof supportsCancellation === "boolean", "\"supportsCancellation\" is not a boolean");
|
|
@@ -55229,13 +55234,10 @@ ${error.message}`;
|
|
|
55229
55234
|
return NODE_VERSIONS;
|
|
55230
55235
|
}
|
|
55231
55236
|
function isNodeVersionAvailable(version$1) {
|
|
55232
|
-
|
|
55233
|
-
return (0, import_fs.statSync)(`/node${version$1.major}`).isDirectory();
|
|
55234
|
-
} catch {}
|
|
55235
|
-
return false;
|
|
55237
|
+
return (0, import_fs.statSync)(`/node${version$1.major}`, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
55236
55238
|
}
|
|
55237
55239
|
function getAvailableNodeVersions() {
|
|
55238
|
-
return getOptions().filter(isNodeVersionAvailable).map((n) => n.major);
|
|
55240
|
+
return getOptions().filter((v) => v.major >= 18).filter(isNodeVersionAvailable).map((n) => n.major);
|
|
55239
55241
|
}
|
|
55240
55242
|
function getHint(isAuto = false, availableVersions) {
|
|
55241
55243
|
const { major, range } = getLatestNodeVersion(availableVersions);
|
|
@@ -55262,7 +55264,7 @@ ${error.message}`;
|
|
|
55262
55264
|
}))) throw new NowBuildError({
|
|
55263
55265
|
code: "BUILD_UTILS_NODE_VERSION_INVALID",
|
|
55264
55266
|
link: "https://vercel.link/node-version",
|
|
55265
|
-
message: `Found invalid Node.js Version: "${engineRange}". ${getHint(isAuto, availableVersions)}`
|
|
55267
|
+
message: `Found invalid or discontinued Node.js Version: "${engineRange}". ${getHint(isAuto, availableVersions)}`
|
|
55266
55268
|
});
|
|
55267
55269
|
}
|
|
55268
55270
|
if (!selection) selection = getLatestNodeVersion(availableVersions);
|
|
@@ -55295,7 +55297,7 @@ ${error.message}`;
|
|
|
55295
55297
|
code: "BUILD_UTILS_BUN_VERSION_INVALID"
|
|
55296
55298
|
});
|
|
55297
55299
|
}
|
|
55298
|
-
function isBunVersion
|
|
55300
|
+
function isBunVersion(version$1) {
|
|
55299
55301
|
return version$1.runtime.startsWith("bun");
|
|
55300
55302
|
}
|
|
55301
55303
|
var import_js_yaml = __toESM(require_js_yaml2());
|
|
@@ -55449,7 +55451,7 @@ ${error.message}`;
|
|
|
55449
55451
|
}
|
|
55450
55452
|
function getSpawnOptions(meta, nodeVersion) {
|
|
55451
55453
|
const opts = { env: cloneEnv(process.env) };
|
|
55452
|
-
if (isBunVersion
|
|
55454
|
+
if (isBunVersion(nodeVersion)) return opts;
|
|
55453
55455
|
if (!meta.isDev) {
|
|
55454
55456
|
let found = false;
|
|
55455
55457
|
const pathSegments = (opts.env.PATH || process.env.PATH || "").split(import_path6.default.delimiter).map((segment) => {
|
|
@@ -55464,14 +55466,14 @@ ${error.message}`;
|
|
|
55464
55466
|
}
|
|
55465
55467
|
return opts;
|
|
55466
55468
|
}
|
|
55467
|
-
async function
|
|
55469
|
+
async function getNodeVersion$1(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = getAvailableNodeVersions()) {
|
|
55468
55470
|
if (config.bunVersion) return getSupportedBunVersion(config.bunVersion);
|
|
55469
55471
|
const latestVersion = getLatestNodeVersion(availableVersions);
|
|
55470
55472
|
if (meta.isDev) {
|
|
55471
55473
|
latestVersion.runtime = "nodejs";
|
|
55472
55474
|
return latestVersion;
|
|
55473
55475
|
}
|
|
55474
|
-
const { packageJson } = await
|
|
55476
|
+
const { packageJson } = await findPackageJson(destPath, true);
|
|
55475
55477
|
const configuredVersion = config.nodeVersion || fallbackVersion;
|
|
55476
55478
|
const packageJsonVersion = packageJson?.engines?.node;
|
|
55477
55479
|
const supportedNodeVersion = await getSupportedNodeVersion(packageJsonVersion || configuredVersion, !packageJsonVersion, availableVersions);
|
|
@@ -55483,7 +55485,7 @@ ${error.message}`;
|
|
|
55483
55485
|
}
|
|
55484
55486
|
return supportedNodeVersion;
|
|
55485
55487
|
}
|
|
55486
|
-
async function
|
|
55488
|
+
async function findPackageJson(destPath, readPackageJson = false, base = "/") {
|
|
55487
55489
|
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55488
55490
|
const pkgJsonPath = await walkParentDirs({
|
|
55489
55491
|
base,
|
|
@@ -55496,6 +55498,14 @@ ${error.message}`;
|
|
|
55496
55498
|
} catch (err) {
|
|
55497
55499
|
throw new Error(`Could not read ${pkgJsonPath}: ${err.message}.`);
|
|
55498
55500
|
}
|
|
55501
|
+
return {
|
|
55502
|
+
packageJsonPath: pkgJsonPath || void 0,
|
|
55503
|
+
packageJson
|
|
55504
|
+
};
|
|
55505
|
+
}
|
|
55506
|
+
async function scanParentDirs$1(destPath, readPackageJson = false, base = "/") {
|
|
55507
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55508
|
+
const { packageJsonPath: pkgJsonPath, packageJson } = await findPackageJson(destPath, readPackageJson, base);
|
|
55499
55509
|
const { paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockTextPath, bunLockBinPath, vltLockPath], packageJsonPackageManager } = await walkParentDirsMulti({
|
|
55500
55510
|
base,
|
|
55501
55511
|
start: destPath,
|
|
@@ -56043,19 +56053,26 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56043
56053
|
async function runPipInstall(destPath, args = [], spawnOpts, meta) {
|
|
56044
56054
|
if (meta && meta.isDev) {
|
|
56045
56055
|
debug$2("Skipping dependency installation because dev mode is enabled");
|
|
56046
|
-
return;
|
|
56056
|
+
return { installed: false };
|
|
56047
56057
|
}
|
|
56048
56058
|
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
56059
|
+
const targetDir = import_path6.default.join(destPath, ".vercel_python_packages");
|
|
56049
56060
|
const opts = {
|
|
56050
56061
|
...spawnOpts,
|
|
56051
56062
|
cwd: destPath,
|
|
56052
|
-
prettyCommand: "
|
|
56063
|
+
prettyCommand: "uv pip install"
|
|
56053
56064
|
};
|
|
56054
|
-
await spawnAsync("
|
|
56065
|
+
await spawnAsync("uv", [
|
|
56066
|
+
"pip",
|
|
56055
56067
|
"install",
|
|
56056
|
-
"--
|
|
56068
|
+
"--target",
|
|
56069
|
+
targetDir,
|
|
56057
56070
|
...args
|
|
56058
56071
|
], opts);
|
|
56072
|
+
return {
|
|
56073
|
+
installed: true,
|
|
56074
|
+
targetDir
|
|
56075
|
+
};
|
|
56059
56076
|
}
|
|
56060
56077
|
function getScriptName$1(pkg, possibleNames) {
|
|
56061
56078
|
if (pkg?.scripts) {
|
|
@@ -56254,6 +56271,10 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56254
56271
|
initialDelaySeconds: {
|
|
56255
56272
|
type: "number",
|
|
56256
56273
|
minimum: 0
|
|
56274
|
+
},
|
|
56275
|
+
maxConcurrency: {
|
|
56276
|
+
type: "number",
|
|
56277
|
+
minimum: 1
|
|
56257
56278
|
}
|
|
56258
56279
|
},
|
|
56259
56280
|
required: [
|
|
@@ -56333,7 +56354,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56333
56354
|
function mapUndefinedAttributes(attrs) {
|
|
56334
56355
|
return Object.fromEntries(Object.entries(attrs ?? {}).filter((attr) => !!attr[1]));
|
|
56335
56356
|
}
|
|
56336
|
-
var Span = class _Span {
|
|
56357
|
+
var Span$1 = class _Span {
|
|
56337
56358
|
constructor({ name, parentId, attrs, reporter }) {
|
|
56338
56359
|
this.name = name;
|
|
56339
56360
|
this.parentId = parentId;
|
|
@@ -56507,6 +56528,11 @@ ${entrypointsForMessage}`);
|
|
|
56507
56528
|
"fastify",
|
|
56508
56529
|
"elysia"
|
|
56509
56530
|
];
|
|
56531
|
+
var PYTHON_FRAMEWORKS = [
|
|
56532
|
+
"fastapi",
|
|
56533
|
+
"flask",
|
|
56534
|
+
"python"
|
|
56535
|
+
];
|
|
56510
56536
|
var BACKEND_BUILDERS = [
|
|
56511
56537
|
"@vercel/express",
|
|
56512
56538
|
"@vercel/hono",
|
|
@@ -56520,6 +56546,10 @@ ${entrypointsForMessage}`);
|
|
|
56520
56546
|
if (!framework) return false;
|
|
56521
56547
|
return BACKEND_FRAMEWORKS.includes(framework);
|
|
56522
56548
|
}
|
|
56549
|
+
function isPythonFramework(framework) {
|
|
56550
|
+
if (!framework) return false;
|
|
56551
|
+
return PYTHON_FRAMEWORKS.includes(framework);
|
|
56552
|
+
}
|
|
56523
56553
|
function isExperimentalBackendsWithoutIntrospectionEnabled() {
|
|
56524
56554
|
return process.env.VERCEL_BACKENDS_BUILDS === "1";
|
|
56525
56555
|
}
|
|
@@ -56579,13 +56609,13 @@ ${entrypointsForMessage}`);
|
|
|
56579
56609
|
|
|
56580
56610
|
//#endregion
|
|
56581
56611
|
//#region src/utils.ts
|
|
56582
|
-
var import_dist$
|
|
56612
|
+
var import_dist$2 = require_dist$1();
|
|
56583
56613
|
async function downloadInstallAndBundle(args) {
|
|
56584
56614
|
const { entrypoint, files, workPath, meta, config, repoRootPath } = args;
|
|
56585
|
-
await (0, import_dist$
|
|
56615
|
+
await (0, import_dist$2.download)(files, workPath, meta);
|
|
56586
56616
|
const entrypointFsDirname = join(workPath, dirname(entrypoint));
|
|
56587
|
-
const { cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await (0, import_dist$
|
|
56588
|
-
const spawnEnv = (0, import_dist$
|
|
56617
|
+
const { cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await (0, import_dist$2.scanParentDirs)(entrypointFsDirname, true, repoRootPath);
|
|
56618
|
+
const spawnEnv = (0, import_dist$2.getEnvForPackageManager)({
|
|
56589
56619
|
cliType,
|
|
56590
56620
|
lockfileVersion,
|
|
56591
56621
|
packageJsonPackageManager,
|
|
@@ -56596,12 +56626,12 @@ async function downloadInstallAndBundle(args) {
|
|
|
56596
56626
|
const installCommand = config.projectSettings?.installCommand;
|
|
56597
56627
|
if (typeof installCommand === "string") if (installCommand.trim()) {
|
|
56598
56628
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
|
56599
|
-
await (0, import_dist$
|
|
56629
|
+
await (0, import_dist$2.execCommand)(installCommand, {
|
|
56600
56630
|
env: spawnEnv,
|
|
56601
56631
|
cwd: entrypointFsDirname
|
|
56602
56632
|
});
|
|
56603
56633
|
} else console.log(`Skipping "install" command...`);
|
|
56604
|
-
else await (0, import_dist$
|
|
56634
|
+
else await (0, import_dist$2.runNpmInstall)(entrypointFsDirname, [], { env: spawnEnv }, meta, config.projectSettings?.createdAt);
|
|
56605
56635
|
return {
|
|
56606
56636
|
entrypointFsDirname,
|
|
56607
56637
|
spawnEnv
|
|
@@ -56610,11 +56640,11 @@ async function downloadInstallAndBundle(args) {
|
|
|
56610
56640
|
async function maybeExecBuildCommand(args, { spawnEnv, entrypointFsDirname }) {
|
|
56611
56641
|
const projectBuildCommand = args.config.projectSettings?.buildCommand;
|
|
56612
56642
|
if (projectBuildCommand) {
|
|
56613
|
-
const nodeBinPath = (0, import_dist$
|
|
56643
|
+
const nodeBinPath = (0, import_dist$2.getNodeBinPaths)({
|
|
56614
56644
|
base: args.repoRootPath || args.workPath,
|
|
56615
56645
|
start: args.workPath
|
|
56616
56646
|
}).join(delimiter);
|
|
56617
|
-
return (0, import_dist$
|
|
56647
|
+
return (0, import_dist$2.execCommand)(projectBuildCommand, {
|
|
56618
56648
|
env: {
|
|
56619
56649
|
...spawnEnv,
|
|
56620
56650
|
PATH: `${nodeBinPath}${delimiter}${spawnEnv?.PATH || process.env.PATH}`
|
|
@@ -56622,43 +56652,9 @@ async function maybeExecBuildCommand(args, { spawnEnv, entrypointFsDirname }) {
|
|
|
56622
56652
|
cwd: args.workPath
|
|
56623
56653
|
});
|
|
56624
56654
|
}
|
|
56625
|
-
return (0, import_dist$
|
|
56655
|
+
return (0, import_dist$2.runPackageJsonScript)(entrypointFsDirname, ["build"], { env: spawnEnv }, args.config.projectSettings?.createdAt);
|
|
56626
56656
|
}
|
|
56627
56657
|
|
|
56628
|
-
//#endregion
|
|
56629
|
-
//#region src/node-file-trace.ts
|
|
56630
|
-
var import_dist$2 = require_dist$1();
|
|
56631
|
-
const nodeFileTrace$1 = async (args, nodeVersion, output) => {
|
|
56632
|
-
const { dir: outputDir, handler } = output;
|
|
56633
|
-
const entry = join(outputDir, handler);
|
|
56634
|
-
const files = {};
|
|
56635
|
-
const conditions = (0, import_dist$2.isBunVersion)(nodeVersion) ? ["bun"] : void 0;
|
|
56636
|
-
const nftResult = await nodeFileTrace([entry], {
|
|
56637
|
-
base: args.repoRootPath,
|
|
56638
|
-
ignore: args.config.excludeFiles,
|
|
56639
|
-
conditions,
|
|
56640
|
-
mixedModules: true
|
|
56641
|
-
});
|
|
56642
|
-
const packageJsonPath = join(args.workPath, "package.json");
|
|
56643
|
-
if (existsSync(packageJsonPath)) {
|
|
56644
|
-
const { mode } = lstatSync(packageJsonPath);
|
|
56645
|
-
const source = readFileSync(packageJsonPath);
|
|
56646
|
-
const relPath = relative(args.repoRootPath, packageJsonPath);
|
|
56647
|
-
files[relPath] = new import_dist$2.FileBlob({
|
|
56648
|
-
data: source,
|
|
56649
|
-
mode
|
|
56650
|
-
});
|
|
56651
|
-
}
|
|
56652
|
-
for (const file of nftResult.fileList) {
|
|
56653
|
-
const fullPath = join(args.repoRootPath, file);
|
|
56654
|
-
files[file] = new import_dist$2.FileFsRef({
|
|
56655
|
-
fsPath: fullPath,
|
|
56656
|
-
mode: lstatSync(fullPath, {}).mode
|
|
56657
|
-
});
|
|
56658
|
-
}
|
|
56659
|
-
return { files };
|
|
56660
|
-
};
|
|
56661
|
-
|
|
56662
56658
|
//#endregion
|
|
56663
56659
|
//#region src/build.ts
|
|
56664
56660
|
var import_dist$1 = require_dist$1();
|
|
@@ -56674,7 +56670,7 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56674
56670
|
if (isCervelCommand) {
|
|
56675
56671
|
(0, import_dist$1.debug)("Cervel command ran, using its default output location");
|
|
56676
56672
|
const cervelOutputDir = join$1(args.workPath, "dist");
|
|
56677
|
-
if (existsSync
|
|
56673
|
+
if (existsSync(join$1(cervelOutputDir, ".cervel.json"))) {
|
|
56678
56674
|
(0, import_dist$1.debug)("Cervel JSON file found, using its handler");
|
|
56679
56675
|
const { handler: handler$2 } = await getBuildSummary(cervelOutputDir);
|
|
56680
56676
|
return {
|
|
@@ -56686,10 +56682,10 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56686
56682
|
throw new Error(`Build command "${buildCommand}" completed, but no output was found at ${cervelOutputDir}. Make sure your cervel command is configured correctly.`);
|
|
56687
56683
|
}
|
|
56688
56684
|
const distDir = join$1(args.workPath, "dist");
|
|
56689
|
-
if (existsSync
|
|
56685
|
+
if (existsSync(distDir)) {
|
|
56690
56686
|
(0, import_dist$1.debug)("Dist directory found, checking for .cervel.json");
|
|
56691
56687
|
const cervelJsonPath$1 = join$1(distDir, ".cervel.json");
|
|
56692
|
-
if (existsSync
|
|
56688
|
+
if (existsSync(cervelJsonPath$1)) {
|
|
56693
56689
|
const { handler: handler$3 } = await getBuildSummary(distDir);
|
|
56694
56690
|
return {
|
|
56695
56691
|
dir: distDir,
|
|
@@ -56702,19 +56698,47 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56702
56698
|
(0, import_dist$1.debug)("Finding entrypoint in dist directory");
|
|
56703
56699
|
handler$2 = await findEntrypoint(distDir);
|
|
56704
56700
|
} catch (error) {
|
|
56705
|
-
|
|
56706
|
-
|
|
56701
|
+
try {
|
|
56702
|
+
(0, import_dist$1.debug)("Finding entrypoint in dist directory with ignoreRegex");
|
|
56703
|
+
handler$2 = await findEntrypoint(distDir, { ignoreRegex: true });
|
|
56704
|
+
(0, import_dist$1.debug)("Found entrypoint in dist directory with ignoreRegex", handler$2);
|
|
56705
|
+
} catch (error$1) {
|
|
56706
|
+
(0, import_dist$1.debug)("Unable to detect entrypoint, building ourselves");
|
|
56707
|
+
const buildResult$1 = await build$1({
|
|
56708
|
+
workPath: args.workPath,
|
|
56709
|
+
repoRootPath: args.repoRootPath,
|
|
56710
|
+
out: defaultOutputDirectory
|
|
56711
|
+
});
|
|
56712
|
+
tsPromise = buildResult$1.tsPromise ?? void 0;
|
|
56713
|
+
const { handler: handler$3 } = await getBuildSummary(buildResult$1.rolldownResult.outputDir);
|
|
56714
|
+
return {
|
|
56715
|
+
dir: buildResult$1.rolldownResult.outputDir,
|
|
56716
|
+
handler: handler$3,
|
|
56717
|
+
tsPromise,
|
|
56718
|
+
files: buildResult$1.rolldownResult.outputFiles
|
|
56719
|
+
};
|
|
56720
|
+
}
|
|
56707
56721
|
}
|
|
56708
56722
|
await writeFile(cervelJsonPath$1, JSON.stringify({ handler: handler$2 }, null, 2));
|
|
56723
|
+
const files = await nodeFileTrace({
|
|
56724
|
+
keepTracedPaths: true,
|
|
56725
|
+
tracedPaths: [join$1(distDir, handler$2)],
|
|
56726
|
+
repoRootPath: args.repoRootPath,
|
|
56727
|
+
workPath: args.workPath,
|
|
56728
|
+
context: { files: {} },
|
|
56729
|
+
outDir: distDir
|
|
56730
|
+
});
|
|
56709
56731
|
return {
|
|
56710
56732
|
dir: distDir,
|
|
56711
56733
|
handler: handler$2,
|
|
56712
|
-
tsPromise
|
|
56734
|
+
tsPromise,
|
|
56735
|
+
files
|
|
56713
56736
|
};
|
|
56714
56737
|
}
|
|
56715
|
-
(0, import_dist$1.debug)("No dist directory found, building ourselves");
|
|
56738
|
+
(0, import_dist$1.debug)("No dist directory found, or unable to detect entrypoint, building ourselves");
|
|
56716
56739
|
const buildResult = await build$1({
|
|
56717
|
-
|
|
56740
|
+
workPath: args.workPath,
|
|
56741
|
+
repoRootPath: args.repoRootPath,
|
|
56718
56742
|
out: defaultOutputDirectory
|
|
56719
56743
|
});
|
|
56720
56744
|
tsPromise = buildResult.tsPromise ?? void 0;
|
|
@@ -56722,7 +56746,8 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56722
56746
|
return {
|
|
56723
56747
|
dir: buildResult.rolldownResult.outputDir,
|
|
56724
56748
|
handler: handler$1,
|
|
56725
|
-
tsPromise
|
|
56749
|
+
tsPromise,
|
|
56750
|
+
files: buildResult.rolldownResult.outputFiles
|
|
56726
56751
|
};
|
|
56727
56752
|
}
|
|
56728
56753
|
const outputDir = join$1(args.workPath, outputSetting);
|
|
@@ -56730,7 +56755,8 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56730
56755
|
const monorepoWithoutBuildScript = args.config.projectSettings?.monorepoManager && !(0, import_dist$1.getScriptName)(packageJson, ["build"]);
|
|
56731
56756
|
if (!buildCommandResult || monorepoWithoutBuildScript) {
|
|
56732
56757
|
const buildResult = await build$1({
|
|
56733
|
-
|
|
56758
|
+
workPath: args.workPath,
|
|
56759
|
+
repoRootPath: args.repoRootPath,
|
|
56734
56760
|
out: outputDir
|
|
56735
56761
|
});
|
|
56736
56762
|
tsPromise = buildResult.tsPromise ?? void 0;
|
|
@@ -56738,11 +56764,12 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56738
56764
|
return {
|
|
56739
56765
|
dir: buildResult.rolldownResult.outputDir,
|
|
56740
56766
|
handler: handler$1,
|
|
56741
|
-
tsPromise
|
|
56767
|
+
tsPromise,
|
|
56768
|
+
files: buildResult.rolldownResult.outputFiles
|
|
56742
56769
|
};
|
|
56743
56770
|
}
|
|
56744
56771
|
const cervelJsonPath = join$1(outputDir, ".cervel.json");
|
|
56745
|
-
if (existsSync
|
|
56772
|
+
if (existsSync(cervelJsonPath)) {
|
|
56746
56773
|
const { handler: handler$1 } = await getBuildSummary(outputDir);
|
|
56747
56774
|
return {
|
|
56748
56775
|
dir: outputDir,
|
|
@@ -56770,24 +56797,36 @@ 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
|
|
56775
|
-
|
|
56776
|
-
|
|
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
|
+
});
|
|
56812
|
+
const files = outputConfig.files;
|
|
56777
56813
|
(0, import_dist.debug)("Introspection starting..");
|
|
56778
|
-
const { routes, framework } = await introspectApp({
|
|
56779
|
-
|
|
56780
|
-
|
|
56781
|
-
|
|
56782
|
-
|
|
56783
|
-
|
|
56784
|
-
|
|
56814
|
+
const { routes, framework } = await span.child("vc.builder.backends.introspectApp").trace(async (span$1) => {
|
|
56815
|
+
const result = await introspectApp({
|
|
56816
|
+
...outputConfig,
|
|
56817
|
+
framework: args.config.framework,
|
|
56818
|
+
env: {
|
|
56819
|
+
...args.meta?.env ?? {},
|
|
56820
|
+
...args.meta?.buildEnv ?? {}
|
|
56821
|
+
}
|
|
56822
|
+
});
|
|
56823
|
+
span$1.setAttributes({ "introspectApp.routes": String(result.routes.length) });
|
|
56824
|
+
return result;
|
|
56785
56825
|
});
|
|
56786
56826
|
if (routes.length > 2) (0, import_dist.debug)(`Introspection completed successfully with ${routes.length} routes`);
|
|
56787
56827
|
else (0, import_dist.debug)(`Introspection failed to detect routes`);
|
|
56788
|
-
const handler =
|
|
56789
|
-
|
|
56790
|
-
(0, import_dist.debug)("Node file trace complete");
|
|
56828
|
+
const handler = outputConfig.handler;
|
|
56829
|
+
if (!files) throw new Error("Unable to trace files for build");
|
|
56791
56830
|
const lambda = new import_dist.NodejsLambda({
|
|
56792
56831
|
runtime: nodeVersion.runtime,
|
|
56793
56832
|
handler,
|
|
@@ -56806,7 +56845,7 @@ const build = async (args) => {
|
|
|
56806
56845
|
if (route.dest === "/") continue;
|
|
56807
56846
|
output[route.dest] = lambda;
|
|
56808
56847
|
}
|
|
56809
|
-
if (outputConfig.tsPromise) await outputConfig.tsPromise;
|
|
56848
|
+
if (outputConfig.tsPromise) await span.child("vc.builder.backends.tsCompile").trace(() => outputConfig.tsPromise);
|
|
56810
56849
|
return {
|
|
56811
56850
|
routes,
|
|
56812
56851
|
output
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/backends",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -21,31 +21,29 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vercel/nft": "1.1.1",
|
|
25
24
|
"fs-extra": "11.1.0",
|
|
26
|
-
"@vercel/cervel": "0.0.
|
|
27
|
-
"@vercel/
|
|
28
|
-
"@vercel/introspection": "0.0.9"
|
|
25
|
+
"@vercel/cervel": "0.0.11",
|
|
26
|
+
"@vercel/introspection": "0.0.10"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"@types/express": "5.0.3",
|
|
32
30
|
"@types/fs-extra": "11",
|
|
33
31
|
"@types/jest": "27.5.1",
|
|
34
|
-
"@types/node": "
|
|
32
|
+
"@types/node": "20.11.0",
|
|
35
33
|
"execa": "3.2.0",
|
|
36
34
|
"hono": "4.10.1",
|
|
37
35
|
"jest-junit": "16.0.0",
|
|
38
36
|
"tsdown": "0.16.3",
|
|
39
37
|
"vite": "^5.1.6",
|
|
40
38
|
"vitest": "^2.0.1",
|
|
41
|
-
"@vercel/build-utils": "13.2.
|
|
39
|
+
"@vercel/build-utils": "13.2.16"
|
|
42
40
|
},
|
|
43
41
|
"module": "./dist/index.mjs",
|
|
44
42
|
"types": "./dist/index.d.mts",
|
|
45
43
|
"scripts": {
|
|
46
44
|
"build": "tsdown",
|
|
47
45
|
"vitest-run": "vitest -c ../../vitest.config.mts",
|
|
48
|
-
"vitest-unit": "glob --absolute 'test/unit
|
|
46
|
+
"vitest-unit": "glob --absolute 'test/unit.*test.ts'",
|
|
49
47
|
"type-check": "tsc --noEmit"
|
|
50
48
|
}
|
|
51
49
|
}
|