@vercel/backends 0.0.20 → 0.0.22

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 (2) hide show
  1. package/dist/index.mjs +53 -47
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -54352,7 +54352,7 @@ ${error.message}`;
54352
54352
  buildsSchema: () => buildsSchema,
54353
54353
  cloneEnv: () => cloneEnv,
54354
54354
  createLambda: () => createLambda,
54355
- debug: () => debug$1,
54355
+ debug: () => debug$2,
54356
54356
  defaultCachePathGlob: () => defaultCachePathGlob$1,
54357
54357
  detectPackageManager: () => detectPackageManager,
54358
54358
  download: () => download$1,
@@ -54377,7 +54377,7 @@ ${error.message}`;
54377
54377
  getProvidedRuntime: () => getProvidedRuntime,
54378
54378
  getRuntimeNodeVersion: () => getRuntimeNodeVersion$1,
54379
54379
  getScriptName: () => getScriptName$1,
54380
- getSpawnOptions: () => getSpawnOptions$1,
54380
+ getSpawnOptions: () => getSpawnOptions,
54381
54381
  getSupportedBunVersion: () => getSupportedBunVersion,
54382
54382
  getSupportedNodeVersion: () => getSupportedNodeVersion,
54383
54383
  getWriteableDirectory: () => getWritableDirectory,
@@ -54708,7 +54708,7 @@ ${error.message}`;
54708
54708
  }
54709
54709
  return n;
54710
54710
  };
54711
- function debug$1(message, ...additional) {
54711
+ function debug$2(message, ...additional) {
54712
54712
  if (getPlatformEnv("BUILDER_DEBUG")) console.log(message, ...additional);
54713
54713
  else if (process.env.VERCEL_DEBUG_PREFIX) console.log(`${process.env.VERCEL_DEBUG_PREFIX}${message}`, ...additional);
54714
54714
  }
@@ -54813,7 +54813,7 @@ ${error.message}`;
54813
54813
  async function download$1(files, basePath, meta) {
54814
54814
  const { isDev = false, skipDownload = false, filesChanged = null, filesRemoved = null } = meta || {};
54815
54815
  if (isDev || skipDownload) return files;
54816
- debug$1("Downloading deployment source files...");
54816
+ debug$2("Downloading deployment source files...");
54817
54817
  const start = Date.now();
54818
54818
  const files2 = {};
54819
54819
  const filenames = Object.keys(files);
@@ -54836,7 +54836,7 @@ ${error.message}`;
54836
54836
  files2[name] = await downloadFile(file, import_path2.default.join(basePath, name));
54837
54837
  }));
54838
54838
  const duration = Date.now() - start;
54839
- debug$1(`Downloaded ${filenames.length} source files: ${duration}ms`);
54839
+ debug$2(`Downloaded ${filenames.length} source files: ${duration}ms`);
54840
54840
  return files2;
54841
54841
  }
54842
54842
  function getDefaultLambdaArchitecture(architecture) {
@@ -55271,7 +55271,7 @@ ${error.message}`;
55271
55271
  link: "https://vercel.link/node-version",
55272
55272
  message: `${`Node.js Version "${selection.range}" is discontinued and must be upgraded.`} ${getHint(isAuto)}`
55273
55273
  });
55274
- debug$1(`Selected Node.js ${selection.range}`);
55274
+ debug$2(`Selected Node.js ${selection.range}`);
55275
55275
  if (selection.state === "deprecated") {
55276
55276
  const d = selection.formattedDate;
55277
55277
  if (d) console.warn(`Error: Node.js version ${selection.range} is deprecated. Deployments created on or after ${d} will fail to build. ${getHint(isAuto)}`);
@@ -55447,7 +55447,7 @@ ${error.message}`;
55447
55447
  });
55448
55448
  return true;
55449
55449
  }
55450
- function getSpawnOptions$1(meta, nodeVersion) {
55450
+ function getSpawnOptions(meta, nodeVersion) {
55451
55451
  const opts = { env: cloneEnv(process.env) };
55452
55452
  if (isBunVersion$1(nodeVersion)) return opts;
55453
55453
  if (!meta.isDev) {
@@ -55700,7 +55700,7 @@ ${error.message}`;
55700
55700
  }
55701
55701
  async function runNpmInstall$1(destPath, args = [], spawnOpts, meta, projectCreatedAt) {
55702
55702
  if (meta?.isDev) {
55703
- debug$1("Skipping dependency installation because dev mode is enabled");
55703
+ debug$2("Skipping dependency installation because dev mode is enabled");
55704
55704
  return false;
55705
55705
  }
55706
55706
  (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
@@ -55708,7 +55708,7 @@ ${error.message}`;
55708
55708
  await runNpmInstallSema.acquire();
55709
55709
  const { cliType, packageJsonPath, packageJson, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs$1(destPath, true);
55710
55710
  if (!packageJsonPath) {
55711
- debug$1(`Skipping dependency installation because no package.json was found for ${destPath}`);
55711
+ debug$2(`Skipping dependency installation because no package.json was found for ${destPath}`);
55712
55712
  return false;
55713
55713
  }
55714
55714
  const defaultInstall = args.length === 0;
@@ -55716,7 +55716,7 @@ ${error.message}`;
55716
55716
  const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(meta.runNpmInstallSet, packageJsonPath);
55717
55717
  if (alreadyInstalled) return false;
55718
55718
  if (process.env.VERCEL_INSTALL_COMPLETED === "1") {
55719
- debug$1(`Skipping dependency installation for ${packageJsonPath} because VERCEL_INSTALL_COMPLETED is set`);
55719
+ debug$2(`Skipping dependency installation for ${packageJsonPath} because VERCEL_INSTALL_COMPLETED is set`);
55720
55720
  runNpmInstallSet.add(packageJsonPath);
55721
55721
  meta.runNpmInstallSet = runNpmInstallSet;
55722
55722
  return false;
@@ -55734,7 +55734,7 @@ ${error.message}`;
55734
55734
  }
55735
55735
  const installTime = Date.now();
55736
55736
  console.log("Installing dependencies...");
55737
- debug$1(`Installing to ${destPath}`);
55737
+ debug$2(`Installing to ${destPath}`);
55738
55738
  const opts = {
55739
55739
  cwd: destPath,
55740
55740
  ...spawnOpts
@@ -55756,7 +55756,7 @@ ${error.message}`;
55756
55756
  args,
55757
55757
  opts
55758
55758
  });
55759
- debug$1(`Install complete [${Date.now() - installTime}ms]`);
55759
+ debug$2(`Install complete [${Date.now() - installTime}ms]`);
55760
55760
  return true;
55761
55761
  } finally {
55762
55762
  runNpmInstallSema.release();
@@ -55772,8 +55772,8 @@ ${error.message}`;
55772
55772
  packageJsonEngines,
55773
55773
  projectCreatedAt
55774
55774
  });
55775
- if (corepackEnabled) debug$1(`Detected corepack use for "${packageJsonPackageManager}". Not overriding package manager version.`);
55776
- else debug$1(`Detected ${detectedPackageManager}. Added "${newPath}" to path. Based on assumed package manager "${cliType}", lockfile "${detectedLockfile}", and lockfileVersion "${lockfileVersion}"`);
55775
+ if (corepackEnabled) debug$2(`Detected corepack use for "${packageJsonPackageManager}". Not overriding package manager version.`);
55776
+ else debug$2(`Detected ${detectedPackageManager}. Added "${newPath}" to path. Based on assumed package manager "${cliType}", lockfile "${detectedLockfile}", and lockfileVersion "${lockfileVersion}"`);
55777
55777
  const newEnv = { ...env };
55778
55778
  const alreadyInPath = (newPath2) => {
55779
55779
  return (env.PATH ?? "").split(import_path6.default.delimiter).includes(newPath2);
@@ -55971,11 +55971,11 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
55971
55971
  const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(customInstallCommandSet, normalizedPath);
55972
55972
  customInstallCommandSet = runNpmInstallSet;
55973
55973
  if (alreadyInstalled) {
55974
- debug$1(`Skipping custom install command for ${normalizedPath} because it was already run`);
55974
+ debug$2(`Skipping custom install command for ${normalizedPath} because it was already run`);
55975
55975
  return false;
55976
55976
  }
55977
55977
  if (process.env.VERCEL_INSTALL_COMPLETED === "1") {
55978
- debug$1(`Skipping custom install command for ${normalizedPath} because VERCEL_INSTALL_COMPLETED is set`);
55978
+ debug$2(`Skipping custom install command for ${normalizedPath} because VERCEL_INSTALL_COMPLETED is set`);
55979
55979
  return false;
55980
55980
  }
55981
55981
  console.log(`Running "install" command: \`${installCommand}\`...`);
@@ -55989,7 +55989,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
55989
55989
  turboSupportsCorepackHome,
55990
55990
  projectCreatedAt
55991
55991
  });
55992
- debug$1(`Running with $PATH:`, env?.PATH || "");
55992
+ debug$2(`Running with $PATH:`, env?.PATH || "");
55993
55993
  await execCommand$1(installCommand, {
55994
55994
  ...spawnOpts,
55995
55995
  env,
@@ -56002,7 +56002,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56002
56002
  const { packageJson, cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs$1(destPath, true);
56003
56003
  const scriptName = getScriptName$1(packageJson, typeof scriptNames === "string" ? [scriptNames] : scriptNames);
56004
56004
  if (!scriptName) return false;
56005
- debug$1("Running user script...");
56005
+ debug$2("Running user script...");
56006
56006
  const runScriptTime = Date.now();
56007
56007
  const opts = {
56008
56008
  cwd: destPath,
@@ -56024,12 +56024,12 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56024
56024
  else opts.prettyCommand = `yarn run ${scriptName}`;
56025
56025
  console.log(`Running "${opts.prettyCommand}"`);
56026
56026
  await spawnAsync(cliType, ["run", scriptName], opts);
56027
- debug$1(`Script complete [${Date.now() - runScriptTime}ms]`);
56027
+ debug$2(`Script complete [${Date.now() - runScriptTime}ms]`);
56028
56028
  return true;
56029
56029
  }
56030
56030
  async function runBundleInstall(destPath, args = [], spawnOpts, meta) {
56031
56031
  if (meta && meta.isDev) {
56032
- debug$1("Skipping dependency installation because dev mode is enabled");
56032
+ debug$2("Skipping dependency installation because dev mode is enabled");
56033
56033
  return;
56034
56034
  }
56035
56035
  (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
@@ -56042,7 +56042,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56042
56042
  }
56043
56043
  async function runPipInstall(destPath, args = [], spawnOpts, meta) {
56044
56044
  if (meta && meta.isDev) {
56045
- debug$1("Skipping dependency installation because dev mode is enabled");
56045
+ debug$2("Skipping dependency installation because dev mode is enabled");
56046
56046
  return;
56047
56047
  }
56048
56048
  (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
@@ -56387,7 +56387,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56387
56387
  const resolved = __require.resolve(`${packageName}/package.json`, { paths: path7 ? Array.isArray(path7) ? path7 : [path7] : [process.cwd()] });
56388
56388
  return __require(resolved).version;
56389
56389
  } catch (err) {
56390
- debug$1(`Could not resolve package "${packageName}". Package is not installed.`, err);
56390
+ debug$2(`Could not resolve package "${packageName}". Package is not installed.`, err);
56391
56391
  return;
56392
56392
  }
56393
56393
  }
@@ -56543,7 +56543,7 @@ ${entrypointsForMessage}`);
56543
56543
  const scriptPath = (0, import_path11.join)(__dirname, "..", "lib", "python", `${scriptName}.py`);
56544
56544
  if (!import_fs3.default.existsSync(scriptPath)) throw new Error(`Python script not found: ${scriptPath}`);
56545
56545
  const pythonCmd = pythonPath ?? (isWin2 ? "python" : "python3");
56546
- debug$1(`Running stdlib Python script: ${pythonCmd} ${scriptPath} ${args.join(" ")}`);
56546
+ debug$2(`Running stdlib Python script: ${pythonCmd} ${scriptPath} ${args.join(" ")}`);
56547
56547
  try {
56548
56548
  const result = await (0, import_execa.default)(pythonCmd, [scriptPath, ...args], { cwd });
56549
56549
  return {
@@ -56571,7 +56571,7 @@ ${entrypointsForMessage}`);
56571
56571
  args: [fsPath]
56572
56572
  })).exitCode === 0;
56573
56573
  } catch (err) {
56574
- debug$1(`Failed to check Python entrypoint: ${err}`);
56574
+ debug$2(`Failed to check Python entrypoint: ${err}`);
56575
56575
  return false;
56576
56576
  }
56577
56577
  }
@@ -56584,14 +56584,12 @@ async function downloadInstallAndBundle(args) {
56584
56584
  const { entrypoint, files, workPath, meta, config, repoRootPath } = args;
56585
56585
  await (0, import_dist$3.download)(files, workPath, meta);
56586
56586
  const entrypointFsDirname = join(workPath, dirname(entrypoint));
56587
- const nodeVersion = await (0, import_dist$3.getRuntimeNodeVersion)(entrypointFsDirname, void 0, config, meta);
56588
- const spawnOpts = (0, import_dist$3.getSpawnOptions)(meta || {}, nodeVersion);
56589
56587
  const { cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await (0, import_dist$3.scanParentDirs)(entrypointFsDirname, true, repoRootPath);
56590
- spawnOpts.env = (0, import_dist$3.getEnvForPackageManager)({
56588
+ const spawnEnv = (0, import_dist$3.getEnvForPackageManager)({
56591
56589
  cliType,
56592
56590
  lockfileVersion,
56593
56591
  packageJsonPackageManager,
56594
- env: spawnOpts.env || {},
56592
+ env: process.env,
56595
56593
  turboSupportsCorepackHome,
56596
56594
  projectCreatedAt: config.projectSettings?.createdAt
56597
56595
  });
@@ -56599,45 +56597,42 @@ async function downloadInstallAndBundle(args) {
56599
56597
  if (typeof installCommand === "string") if (installCommand.trim()) {
56600
56598
  console.log(`Running "install" command: \`${installCommand}\`...`);
56601
56599
  await (0, import_dist$3.execCommand)(installCommand, {
56602
- ...spawnOpts,
56600
+ env: spawnEnv,
56603
56601
  cwd: entrypointFsDirname
56604
56602
  });
56605
56603
  } else console.log(`Skipping "install" command...`);
56606
- else await (0, import_dist$3.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, config.projectSettings?.createdAt);
56604
+ else await (0, import_dist$3.runNpmInstall)(entrypointFsDirname, [], { env: spawnEnv }, meta, config.projectSettings?.createdAt);
56607
56605
  return {
56608
56606
  entrypointFsDirname,
56609
- nodeVersion,
56610
- spawnOpts
56607
+ spawnEnv
56611
56608
  };
56612
56609
  }
56613
- async function maybeExecBuildCommand(args, options) {
56610
+ async function maybeExecBuildCommand(args, { spawnEnv, entrypointFsDirname }) {
56614
56611
  const projectBuildCommand = args.config.projectSettings?.buildCommand;
56615
56612
  if (projectBuildCommand) {
56616
56613
  const nodeBinPath = (0, import_dist$3.getNodeBinPaths)({
56617
56614
  base: args.repoRootPath || args.workPath,
56618
56615
  start: args.workPath
56619
56616
  }).join(delimiter);
56620
- const env = {
56621
- ...options.spawnOpts.env,
56622
- PATH: `${nodeBinPath}${delimiter}${options.spawnOpts.env?.PATH || process.env.PATH}`
56623
- };
56624
56617
  return (0, import_dist$3.execCommand)(projectBuildCommand, {
56625
- ...options.spawnOpts,
56626
- env,
56618
+ env: {
56619
+ ...spawnEnv,
56620
+ PATH: `${nodeBinPath}${delimiter}${spawnEnv?.PATH || process.env.PATH}`
56621
+ },
56627
56622
  cwd: args.workPath
56628
56623
  });
56629
56624
  }
56630
- return (0, import_dist$3.runPackageJsonScript)(options.entrypointFsDirname, ["build"], options.spawnOpts, args.config.projectSettings?.createdAt);
56625
+ return (0, import_dist$3.runPackageJsonScript)(entrypointFsDirname, ["build"], { env: spawnEnv }, args.config.projectSettings?.createdAt);
56631
56626
  }
56632
56627
 
56633
56628
  //#endregion
56634
56629
  //#region src/node-file-trace.ts
56635
56630
  var import_dist$2 = require_dist$1();
56636
- const nodeFileTrace$1 = async (args, downloadResult, output) => {
56631
+ const nodeFileTrace$1 = async (args, nodeVersion, output) => {
56637
56632
  const { dir: outputDir, handler } = output;
56638
56633
  const entry = join(outputDir, handler);
56639
56634
  const files = {};
56640
- const conditions = (0, import_dist$2.isBunVersion)(downloadResult.nodeVersion) ? ["bun"] : void 0;
56635
+ const conditions = (0, import_dist$2.isBunVersion)(nodeVersion) ? ["bun"] : void 0;
56641
56636
  const nftResult = await nodeFileTrace([entry], {
56642
56637
  base: args.repoRootPath,
56643
56638
  ignore: args.config.excludeFiles,
@@ -56675,9 +56670,12 @@ const doBuild = async (args, downloadResult) => {
56675
56670
  let tsPromise;
56676
56671
  const isCervelCommand = buildCommand?.trim().startsWith("cervel");
56677
56672
  if (!outputSetting) {
56673
+ (0, import_dist$1.debug)("No output directory configured, using default output directory");
56678
56674
  if (isCervelCommand) {
56675
+ (0, import_dist$1.debug)("Cervel command ran, using its default output location");
56679
56676
  const cervelOutputDir = join$1(args.workPath, "dist");
56680
56677
  if (existsSync$1(join$1(cervelOutputDir, ".cervel.json"))) {
56678
+ (0, import_dist$1.debug)("Cervel JSON file found, using its handler");
56681
56679
  const { handler: handler$2 } = await getBuildSummary(cervelOutputDir);
56682
56680
  return {
56683
56681
  dir: cervelOutputDir,
@@ -56689,6 +56687,7 @@ const doBuild = async (args, downloadResult) => {
56689
56687
  }
56690
56688
  const distDir = join$1(args.workPath, "dist");
56691
56689
  if (existsSync$1(distDir)) {
56690
+ (0, import_dist$1.debug)("Dist directory found, checking for .cervel.json");
56692
56691
  const cervelJsonPath$1 = join$1(distDir, ".cervel.json");
56693
56692
  if (existsSync$1(cervelJsonPath$1)) {
56694
56693
  const { handler: handler$3 } = await getBuildSummary(distDir);
@@ -56700,8 +56699,10 @@ const doBuild = async (args, downloadResult) => {
56700
56699
  }
56701
56700
  let handler$2;
56702
56701
  try {
56702
+ (0, import_dist$1.debug)("Finding entrypoint in dist directory");
56703
56703
  handler$2 = await findEntrypoint(distDir);
56704
56704
  } catch (error) {
56705
+ (0, import_dist$1.debug)("Finding entrypoint in dist directory with ignoreRegex");
56705
56706
  handler$2 = await findEntrypoint(distDir, { ignoreRegex: true });
56706
56707
  }
56707
56708
  await writeFile(cervelJsonPath$1, JSON.stringify({ handler: handler$2 }, null, 2));
@@ -56711,6 +56712,7 @@ const doBuild = async (args, downloadResult) => {
56711
56712
  tsPromise
56712
56713
  };
56713
56714
  }
56715
+ (0, import_dist$1.debug)("No dist directory found, building ourselves");
56714
56716
  const buildResult = await build$1({
56715
56717
  cwd: args.workPath,
56716
56718
  out: defaultOutputDirectory
@@ -56768,9 +56770,11 @@ var import_dist = require_dist$1();
56768
56770
  const version = 2;
56769
56771
  const build = async (args) => {
56770
56772
  const downloadResult = await downloadInstallAndBundle(args);
56773
+ const nodeVersion = await (0, import_dist.getRuntimeNodeVersion)(args.workPath);
56771
56774
  const outputConfig = await doBuild(args, downloadResult);
56772
- const { files } = await nodeFileTrace$1(args, downloadResult, outputConfig);
56773
- (0, import_dist.debug)("Building route mapping..");
56775
+ (0, import_dist.debug)("Node file trace starting..");
56776
+ const nftPromise = nodeFileTrace$1(args, nodeVersion, outputConfig);
56777
+ (0, import_dist.debug)("Introspection starting..");
56774
56778
  const { routes, framework } = await introspectApp({
56775
56779
  ...outputConfig,
56776
56780
  framework: args.config.framework,
@@ -56779,11 +56783,13 @@ const build = async (args) => {
56779
56783
  ...args.meta?.buildEnv ?? {}
56780
56784
  }
56781
56785
  });
56782
- if (routes.length > 2) (0, import_dist.debug)(`Route mapping built successfully with ${routes.length} routes`);
56783
- else (0, import_dist.debug)(`Route mapping failed to detect routes`);
56786
+ if (routes.length > 2) (0, import_dist.debug)(`Introspection completed successfully with ${routes.length} routes`);
56787
+ else (0, import_dist.debug)(`Introspection failed to detect routes`);
56784
56788
  const handler = relative$1(args.repoRootPath, join$1(outputConfig.dir, outputConfig.handler));
56789
+ const { files } = await nftPromise;
56790
+ (0, import_dist.debug)("Node file trace complete");
56785
56791
  const lambda = new import_dist.NodejsLambda({
56786
- runtime: downloadResult.nodeVersion.runtime,
56792
+ runtime: nodeVersion.runtime,
56787
56793
  handler,
56788
56794
  files,
56789
56795
  shouldAddHelpers: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/backends",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.mjs",
6
6
  "homepage": "https://vercel.com/docs",
@@ -25,7 +25,7 @@
25
25
  "fs-extra": "11.1.0",
26
26
  "@vercel/cervel": "0.0.9",
27
27
  "@vercel/static-config": "3.1.2",
28
- "@vercel/introspection": "0.0.8"
28
+ "@vercel/introspection": "0.0.9"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/express": "5.0.3",
@@ -38,7 +38,7 @@
38
38
  "tsdown": "0.16.3",
39
39
  "vite": "^5.1.6",
40
40
  "vitest": "^2.0.1",
41
- "@vercel/build-utils": "13.2.7"
41
+ "@vercel/build-utils": "13.2.8"
42
42
  },
43
43
  "module": "./dist/index.mjs",
44
44
  "types": "./dist/index.d.mts",