@vercel/build-utils 14.5.1 → 14.6.1

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 14.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - aad9541: Run on-disk JavaScript workers with a lazily resolved system Node.js executable in native CLI installations, and install the matching Build Utils preview tarball for dynamically installed Builders.
8
+
9
+ ## 14.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - e82de48: Add strict function affinity configuration and serialize it into function outputs.
14
+
3
15
  ## 14.5.1
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import type { LambdaOptionsBase } from './lambda';
2
2
  import type { Env, Files } from './types';
3
- export interface ContainerImageConfig extends Pick<LambdaOptionsBase, 'handler' | 'architecture' | 'memory' | 'maxDuration' | 'maxConcurrency' | 'environment' | 'regions' | 'functionFailoverRegions' | 'experimentalTriggers' | 'supportsCancellation'> {
3
+ export interface ContainerImageConfig extends Pick<LambdaOptionsBase, 'handler' | 'architecture' | 'memory' | 'maxDuration' | 'affinity' | 'maxConcurrency' | 'environment' | 'regions' | 'functionFailoverRegions' | 'experimentalTriggers' | 'supportsCancellation'> {
4
4
  /**
5
5
  * The OCI image reference, for example
6
6
  * `vcr.vercel.com/team/project/svc@sha256:...`.
@@ -20,6 +20,7 @@ export declare class ContainerImage implements ContainerImageConfig {
20
20
  architecture?: ContainerImageConfig['architecture'];
21
21
  memory?: ContainerImageConfig['memory'];
22
22
  maxDuration?: ContainerImageConfig['maxDuration'];
23
+ affinity?: ContainerImageConfig['affinity'];
23
24
  maxConcurrency?: ContainerImageConfig['maxConcurrency'];
24
25
  regions?: ContainerImageConfig['regions'];
25
26
  functionFailoverRegions?: ContainerImageConfig['functionFailoverRegions'];
@@ -32,6 +32,7 @@ class ContainerImage {
32
32
  this.architecture = params.architecture;
33
33
  this.memory = params.memory;
34
34
  this.maxDuration = params.maxDuration;
35
+ this.affinity = params.affinity;
35
36
  this.maxConcurrency = params.maxConcurrency;
36
37
  this.regions = params.regions;
37
38
  this.functionFailoverRegions = params.functionFailoverRegions;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the executable that should be used to run Node.js scripts.
3
+ *
4
+ * In the standalone Vercel CLI, `process.execPath` points to the CLI binary
5
+ * rather than Node.js. Resolve Node.js lazily from PATH so commands that do not
6
+ * execute on-disk JavaScript can still run when Node.js is unavailable.
7
+ */
8
+ export declare function getNodeExecPath(): string;
@@ -0,0 +1,57 @@
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_node_exec_path_exports = {};
20
+ __export(get_node_exec_path_exports, {
21
+ getNodeExecPath: () => getNodeExecPath
22
+ });
23
+ module.exports = __toCommonJS(get_node_exec_path_exports);
24
+ var import_node_fs = require("node:fs");
25
+ var import_node_path = require("node:path");
26
+ const NODE_EXEC_PATH_ENV = "VERCEL_NODE_EXEC_PATH";
27
+ const NATIVE_CLI_ENV = "VERCEL_VC_NATIVE";
28
+ function getNodeExecPath() {
29
+ const override = process.env[NODE_EXEC_PATH_ENV];
30
+ if (override)
31
+ return override;
32
+ if (!process.env[NATIVE_CLI_ENV])
33
+ return process.execPath;
34
+ const nodeExecPath = findNodeExecPath();
35
+ process.env[NODE_EXEC_PATH_ENV] = nodeExecPath;
36
+ return nodeExecPath;
37
+ }
38
+ function findNodeExecPath() {
39
+ const executableName = process.platform === "win32" ? "node.exe" : "node";
40
+ const cliPath = (0, import_node_fs.realpathSync)(process.execPath);
41
+ for (const directory of (process.env.PATH || "").split(import_node_path.delimiter)) {
42
+ if (!directory)
43
+ continue;
44
+ const candidate = (0, import_node_path.resolve)(directory, executableName);
45
+ try {
46
+ (0, import_node_fs.accessSync)(candidate, import_node_fs.constants.X_OK);
47
+ if ((0, import_node_fs.realpathSync)(candidate) !== cliPath)
48
+ return candidate;
49
+ } catch {
50
+ }
51
+ }
52
+ throw new Error("Could not find the Node.js executable in PATH.");
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ getNodeExecPath
57
+ });
package/dist/index.d.ts CHANGED
@@ -19,9 +19,11 @@ import { getPrefixedEnvVars } from './get-prefixed-env-vars';
19
19
  import { getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars } from './get-service-url-env-vars';
20
20
  import { cloneEnv } from './clone-env';
21
21
  import { hardLinkDir } from './hard-link-dir';
22
+ import { getNodeExecPath } from './get-node-exec-path';
22
23
  import { validateNpmrc } from './validate-npmrc';
23
24
  export type { NodejsLambdaOptions, PrerenderInitialMetadata };
24
- 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, getOrCreateBunBinary, detectPackageManager, runNpmInstall, NpmInstallOutput, runBundleInstall, runPipInstall, PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, type CliType, };
25
+ export type { LambdaAffinity } from './lambda';
26
+ export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getNodeExecPath, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, getOrCreateBunBinary, detectPackageManager, runNpmInstall, NpmInstallOutput, runBundleInstall, runPipInstall, PipInstallResult, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, getServiceUrlEnvVars, getExperimentalServiceUrlEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, isExternalSymlink, isExternalSymlinkTarget, getSymlinkTarget, getLambdaOptionsFromFunction, sanitizeConsumerName, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, type CliType, };
25
27
  export { EdgeFunction } from './edge-function';
26
28
  export { ContainerImage } from './container-image';
27
29
  export type { ContainerImageConfig } from './container-image';
package/dist/index.js CHANGED
@@ -2374,8 +2374,8 @@ var require_universalify = __commonJS({
2374
2374
  if (typeof args[args.length - 1] === "function")
2375
2375
  fn.apply(this, args);
2376
2376
  else {
2377
- return new Promise((resolve, reject) => {
2378
- args.push((err, res) => err != null ? reject(err) : resolve(res));
2377
+ return new Promise((resolve2, reject) => {
2378
+ args.push((err, res) => err != null ? reject(err) : resolve2(res));
2379
2379
  fn.apply(this, args);
2380
2380
  });
2381
2381
  }
@@ -2398,7 +2398,7 @@ var require_universalify = __commonJS({
2398
2398
  // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
2399
2399
  var require_polyfills = __commonJS({
2400
2400
  "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports, module2) {
2401
- var constants = require("constants");
2401
+ var constants2 = require("constants");
2402
2402
  var origCwd = process.cwd;
2403
2403
  var cwd = null;
2404
2404
  var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -2423,7 +2423,7 @@ var require_polyfills = __commonJS({
2423
2423
  var chdir;
2424
2424
  module2.exports = patch;
2425
2425
  function patch(fs11) {
2426
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
2426
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
2427
2427
  patchLchmod(fs11);
2428
2428
  }
2429
2429
  if (!fs11.lutimes) {
@@ -2530,7 +2530,7 @@ var require_polyfills = __commonJS({
2530
2530
  fs12.lchmod = function(path8, mode, callback) {
2531
2531
  fs12.open(
2532
2532
  path8,
2533
- constants.O_WRONLY | constants.O_SYMLINK,
2533
+ constants2.O_WRONLY | constants2.O_SYMLINK,
2534
2534
  mode,
2535
2535
  function(err, fd) {
2536
2536
  if (err) {
@@ -2548,7 +2548,7 @@ var require_polyfills = __commonJS({
2548
2548
  );
2549
2549
  };
2550
2550
  fs12.lchmodSync = function(path8, mode) {
2551
- var fd = fs12.openSync(path8, constants.O_WRONLY | constants.O_SYMLINK, mode);
2551
+ var fd = fs12.openSync(path8, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
2552
2552
  var threw = true;
2553
2553
  var ret;
2554
2554
  try {
@@ -2568,9 +2568,9 @@ var require_polyfills = __commonJS({
2568
2568
  };
2569
2569
  }
2570
2570
  function patchLutimes(fs12) {
2571
- if (constants.hasOwnProperty("O_SYMLINK") && fs12.futimes) {
2571
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs12.futimes) {
2572
2572
  fs12.lutimes = function(path8, at, mt, cb) {
2573
- fs12.open(path8, constants.O_SYMLINK, function(er, fd) {
2573
+ fs12.open(path8, constants2.O_SYMLINK, function(er, fd) {
2574
2574
  if (er) {
2575
2575
  if (cb)
2576
2576
  cb(er);
@@ -2585,7 +2585,7 @@ var require_polyfills = __commonJS({
2585
2585
  });
2586
2586
  };
2587
2587
  fs12.lutimesSync = function(path8, at, mt) {
2588
- var fd = fs12.openSync(path8, constants.O_SYMLINK);
2588
+ var fd = fs12.openSync(path8, constants2.O_SYMLINK);
2589
2589
  var ret;
2590
2590
  var threw = true;
2591
2591
  try {
@@ -3256,19 +3256,19 @@ var require_fs = __commonJS({
3256
3256
  if (typeof callback === "function") {
3257
3257
  return fs11.exists(filename, callback);
3258
3258
  }
3259
- return new Promise((resolve) => {
3260
- return fs11.exists(filename, resolve);
3259
+ return new Promise((resolve2) => {
3260
+ return fs11.exists(filename, resolve2);
3261
3261
  });
3262
3262
  };
3263
3263
  exports.read = function(fd, buffer, offset, length, position, callback) {
3264
3264
  if (typeof callback === "function") {
3265
3265
  return fs11.read(fd, buffer, offset, length, position, callback);
3266
3266
  }
3267
- return new Promise((resolve, reject) => {
3267
+ return new Promise((resolve2, reject) => {
3268
3268
  fs11.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
3269
3269
  if (err)
3270
3270
  return reject(err);
3271
- resolve({ bytesRead, buffer: buffer2 });
3271
+ resolve2({ bytesRead, buffer: buffer2 });
3272
3272
  });
3273
3273
  });
3274
3274
  };
@@ -3276,11 +3276,11 @@ var require_fs = __commonJS({
3276
3276
  if (typeof args[args.length - 1] === "function") {
3277
3277
  return fs11.write(fd, buffer, ...args);
3278
3278
  }
3279
- return new Promise((resolve, reject) => {
3279
+ return new Promise((resolve2, reject) => {
3280
3280
  fs11.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
3281
3281
  if (err)
3282
3282
  return reject(err);
3283
- resolve({ bytesWritten, buffer: buffer2 });
3283
+ resolve2({ bytesWritten, buffer: buffer2 });
3284
3284
  });
3285
3285
  });
3286
3286
  };
@@ -3289,11 +3289,11 @@ var require_fs = __commonJS({
3289
3289
  if (typeof args[args.length - 1] === "function") {
3290
3290
  return fs11.writev(fd, buffers, ...args);
3291
3291
  }
3292
- return new Promise((resolve, reject) => {
3292
+ return new Promise((resolve2, reject) => {
3293
3293
  fs11.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
3294
3294
  if (err)
3295
3295
  return reject(err);
3296
- resolve({ bytesWritten, buffers: buffers2 });
3296
+ resolve2({ bytesWritten, buffers: buffers2 });
3297
3297
  });
3298
3298
  });
3299
3299
  };
@@ -5405,12 +5405,12 @@ var require_async_sema = __commonJS({
5405
5405
  if (token) {
5406
5406
  return token;
5407
5407
  }
5408
- return new Promise((resolve, reject) => {
5408
+ return new Promise((resolve2, reject) => {
5409
5409
  if (this.pauseFn && !this.paused) {
5410
5410
  this.paused = true;
5411
5411
  this.pauseFn();
5412
5412
  }
5413
- this.waiting.push({ resolve, reject });
5413
+ this.waiting.push({ resolve: resolve2, reject });
5414
5414
  });
5415
5415
  }
5416
5416
  async v() {
@@ -5668,7 +5668,7 @@ var require_lib2 = __commonJS({
5668
5668
  "../../node_modules/.pnpm/async-retry@1.2.3/node_modules/async-retry/lib/index.js"(exports, module2) {
5669
5669
  var retrier = require_retry2();
5670
5670
  function retry2(fn, opts) {
5671
- function run(resolve, reject) {
5671
+ function run(resolve2, reject) {
5672
5672
  var options = opts || {};
5673
5673
  var op = retrier.operation(options);
5674
5674
  function bail(err) {
@@ -5693,7 +5693,7 @@ var require_lib2 = __commonJS({
5693
5693
  onError(err, num);
5694
5694
  return;
5695
5695
  }
5696
- Promise.resolve(val).then(resolve).catch(function catchIt(err) {
5696
+ Promise.resolve(val).then(resolve2).catch(function catchIt(err) {
5697
5697
  onError(err, num);
5698
5698
  });
5699
5699
  }
@@ -7670,7 +7670,7 @@ var require_old = __commonJS({
7670
7670
  splitRootRe = /^[\/]*/;
7671
7671
  }
7672
7672
  var splitRootRe;
7673
- exports.realpathSync = function realpathSync(p, cache) {
7673
+ exports.realpathSync = function realpathSync2(p, cache) {
7674
7674
  p = pathModule.resolve(p);
7675
7675
  if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
7676
7676
  return cache[p];
@@ -7835,8 +7835,8 @@ var require_fs2 = __commonJS({
7835
7835
  "../../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js"(exports, module2) {
7836
7836
  module2.exports = realpath;
7837
7837
  realpath.realpath = realpath;
7838
- realpath.sync = realpathSync;
7839
- realpath.realpathSync = realpathSync;
7838
+ realpath.sync = realpathSync2;
7839
+ realpath.realpathSync = realpathSync2;
7840
7840
  realpath.monkeypatch = monkeypatch;
7841
7841
  realpath.unmonkeypatch = unmonkeypatch;
7842
7842
  var fs11 = require("fs");
@@ -7864,7 +7864,7 @@ var require_fs2 = __commonJS({
7864
7864
  }
7865
7865
  });
7866
7866
  }
7867
- function realpathSync(p, cache) {
7867
+ function realpathSync2(p, cache) {
7868
7868
  if (ok) {
7869
7869
  return origRealpathSync(p, cache);
7870
7870
  }
@@ -7880,7 +7880,7 @@ var require_fs2 = __commonJS({
7880
7880
  }
7881
7881
  function monkeypatch() {
7882
7882
  fs11.realpath = realpath;
7883
- fs11.realpathSync = realpathSync;
7883
+ fs11.realpathSync = realpathSync2;
7884
7884
  }
7885
7885
  function unmonkeypatch() {
7886
7886
  fs11.realpath = origRealpath;
@@ -9849,12 +9849,12 @@ var require_isexe = __commonJS({
9849
9849
  if (typeof Promise !== "function") {
9850
9850
  throw new TypeError("callback not provided");
9851
9851
  }
9852
- return new Promise(function(resolve, reject) {
9852
+ return new Promise(function(resolve2, reject) {
9853
9853
  isexe(path8, options || {}, function(er, is) {
9854
9854
  if (er) {
9855
9855
  reject(er);
9856
9856
  } else {
9857
- resolve(is);
9857
+ resolve2(is);
9858
9858
  }
9859
9859
  });
9860
9860
  });
@@ -23415,7 +23415,7 @@ var require_dist2 = __commonJS({
23415
23415
  return x;
23416
23416
  } : _d;
23417
23417
  var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
23418
- var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
23418
+ var delimiter2 = "[" + escapeString(options.delimiter || "/#?") + "]";
23419
23419
  var route = start ? "^" : "";
23420
23420
  for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
23421
23421
  var token = tokens_1[_i];
@@ -23444,19 +23444,19 @@ var require_dist2 = __commonJS({
23444
23444
  }
23445
23445
  if (end) {
23446
23446
  if (!strict)
23447
- route += delimiter + "?";
23447
+ route += delimiter2 + "?";
23448
23448
  route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
23449
23449
  } else {
23450
23450
  var endToken = tokens[tokens.length - 1];
23451
- var isEndDelimited = typeof endToken === "string" ? delimiter.indexOf(endToken[endToken.length - 1]) > -1 : (
23451
+ var isEndDelimited = typeof endToken === "string" ? delimiter2.indexOf(endToken[endToken.length - 1]) > -1 : (
23452
23452
  // tslint:disable-next-line
23453
23453
  endToken === void 0
23454
23454
  );
23455
23455
  if (!strict) {
23456
- route += "(?:" + delimiter + "(?=" + endsWith + "))?";
23456
+ route += "(?:" + delimiter2 + "(?=" + endsWith + "))?";
23457
23457
  }
23458
23458
  if (!isEndDelimited) {
23459
- route += "(?=" + delimiter + "|" + endsWith + ")";
23459
+ route += "(?=" + delimiter2 + "|" + endsWith + ")";
23460
23460
  }
23461
23461
  }
23462
23462
  return new RegExp(route, flags(options));
@@ -23567,7 +23567,7 @@ var require_dist3 = __commonJS({
23567
23567
  options = {};
23568
23568
  }
23569
23569
  var tokens = lexer(str);
23570
- var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
23570
+ var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter2 = _b === void 0 ? "/#?" : _b;
23571
23571
  var result = [];
23572
23572
  var key = 0;
23573
23573
  var i = 0;
@@ -23592,7 +23592,7 @@ var require_dist3 = __commonJS({
23592
23592
  return result2;
23593
23593
  };
23594
23594
  var isSafe = function(value2) {
23595
- for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
23595
+ for (var _i = 0, delimiter_1 = delimiter2; _i < delimiter_1.length; _i++) {
23596
23596
  var char2 = delimiter_1[_i];
23597
23597
  if (value2.indexOf(char2) > -1)
23598
23598
  return true;
@@ -23606,8 +23606,8 @@ var require_dist3 = __commonJS({
23606
23606
  throw new TypeError('Must have text between two parameters, missing text after "'.concat(prev.name, '"'));
23607
23607
  }
23608
23608
  if (!prevText || isSafe(prevText))
23609
- return "[^".concat(escapeString(delimiter), "]+?");
23610
- return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
23609
+ return "[^".concat(escapeString(delimiter2), "]+?");
23610
+ return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter2), "])+?");
23611
23611
  };
23612
23612
  while (i < tokens.length) {
23613
23613
  var char = tryConsume("CHAR");
@@ -23803,9 +23803,9 @@ var require_dist3 = __commonJS({
23803
23803
  }
23804
23804
  var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
23805
23805
  return x;
23806
- } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
23806
+ } : _d, _e = options.delimiter, delimiter2 = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
23807
23807
  var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
23808
- var delimiterRe = "[".concat(escapeString(delimiter), "]");
23808
+ var delimiterRe = "[".concat(escapeString(delimiter2), "]");
23809
23809
  var route = start ? "^" : "";
23810
23810
  for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
23811
23811
  var token = tokens_1[_i];
@@ -34387,6 +34387,7 @@ __export(src_exports, {
34387
34387
  getMaxDurationSchema: () => getMaxDurationSchema,
34388
34388
  getNodeBinPath: () => getNodeBinPath,
34389
34389
  getNodeBinPaths: () => getNodeBinPaths,
34390
+ getNodeExecPath: () => getNodeExecPath,
34390
34391
  getNodeVersion: () => getNodeVersion,
34391
34392
  getOrCreateBunBinary: () => getOrCreateBunBinary,
34392
34393
  getPackageJson: () => getPackageJson,
@@ -34494,7 +34495,7 @@ var FileBlob = class _FileBlob {
34494
34495
  (0, import_assert.default)(typeof mode === "number");
34495
34496
  (0, import_assert.default)(typeof stream.pipe === "function");
34496
34497
  const chunks = [];
34497
- await new Promise((resolve, reject) => {
34498
+ await new Promise((resolve2, reject) => {
34498
34499
  stream.on(
34499
34500
  "data",
34500
34501
  (chunk) => (
@@ -34506,7 +34507,7 @@ var FileBlob = class _FileBlob {
34506
34507
  )
34507
34508
  );
34508
34509
  stream.on("error", (error) => reject(error));
34509
- stream.on("end", () => resolve());
34510
+ stream.on("end", () => resolve2());
34510
34511
  });
34511
34512
  const data = Buffer.concat(chunks);
34512
34513
  return new _FileBlob({ mode, contentType, data });
@@ -34567,13 +34568,13 @@ var FileFsRef = class _FileFsRef {
34567
34568
  (0, import_assert2.default)(typeof stream.pipe === "function");
34568
34569
  (0, import_assert2.default)(typeof fsPath === "string");
34569
34570
  await import_fs_extra.default.mkdirp(import_path.default.dirname(fsPath));
34570
- await new Promise((resolve, reject) => {
34571
+ await new Promise((resolve2, reject) => {
34571
34572
  const dest = import_fs_extra.default.createWriteStream(fsPath, {
34572
34573
  mode: mode & 511
34573
34574
  });
34574
34575
  stream.pipe(dest);
34575
34576
  stream.on("error", reject);
34576
- dest.on("finish", resolve);
34577
+ dest.on("finish", resolve2);
34577
34578
  dest.on("error", reject);
34578
34579
  });
34579
34580
  return _FileFsRef.fromFsPath({ mode, contentType, fsPath });
@@ -34830,7 +34831,7 @@ var import_fs_extra2 = __toESM(require_lib());
34830
34831
  // src/fs/stream-to-buffer.ts
34831
34832
  var import_end_of_stream = __toESM(require_end_of_stream());
34832
34833
  function streamToBuffer(stream) {
34833
- return new Promise((resolve, reject) => {
34834
+ return new Promise((resolve2, reject) => {
34834
34835
  const buffers = [];
34835
34836
  stream.on("data", (chunk) => {
34836
34837
  const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
@@ -34844,13 +34845,13 @@ function streamToBuffer(stream) {
34844
34845
  try {
34845
34846
  switch (buffers.length) {
34846
34847
  case 0:
34847
- resolve(Buffer.allocUnsafe(0));
34848
+ resolve2(Buffer.allocUnsafe(0));
34848
34849
  break;
34849
34850
  case 1:
34850
- resolve(Buffer.from(buffers[0]));
34851
+ resolve2(Buffer.from(buffers[0]));
34851
34852
  break;
34852
34853
  default:
34853
- resolve(Buffer.concat(buffers));
34854
+ resolve2(Buffer.concat(buffers));
34854
34855
  }
34855
34856
  } catch (concatErr) {
34856
34857
  reject(concatErr);
@@ -35053,6 +35054,7 @@ var Lambda = class {
35053
35054
  runtime,
35054
35055
  runtimeLanguage,
35055
35056
  maxDuration,
35057
+ affinity,
35056
35058
  maxConcurrency,
35057
35059
  architecture,
35058
35060
  memory,
@@ -35106,6 +35108,12 @@ var Lambda = class {
35106
35108
  '"maxDuration" is not a number or "max"'
35107
35109
  );
35108
35110
  }
35111
+ if (affinity !== void 0) {
35112
+ (0, import_assert4.default)(
35113
+ typeof affinity === "object" && affinity !== null && affinity.mode === "strict" && Object.keys(affinity).length === 1,
35114
+ '"affinity" must be an object with only `mode: "strict"`'
35115
+ );
35116
+ }
35109
35117
  if (maxConcurrency !== void 0) {
35110
35118
  (0, import_assert4.default)(
35111
35119
  Number.isInteger(maxConcurrency) && maxConcurrency >= 1,
@@ -35247,6 +35255,7 @@ var Lambda = class {
35247
35255
  this.architecture = getDefaultLambdaArchitecture(architecture);
35248
35256
  this.memory = memory;
35249
35257
  this.maxDuration = maxDuration;
35258
+ this.affinity = affinity;
35250
35259
  this.maxConcurrency = maxConcurrency;
35251
35260
  this.environment = environment;
35252
35261
  this.allowQuery = allowQuery;
@@ -35305,7 +35314,7 @@ async function createZip(files) {
35305
35314
  }
35306
35315
  }
35307
35316
  const zipFile = new import_yazl.ZipFile();
35308
- const zipBuffer = await new Promise((resolve, reject) => {
35317
+ const zipBuffer = await new Promise((resolve2, reject) => {
35309
35318
  for (const name of names) {
35310
35319
  const file = files[name];
35311
35320
  const opts = { mode: file.mode, mtime };
@@ -35321,7 +35330,7 @@ async function createZip(files) {
35321
35330
  }
35322
35331
  }
35323
35332
  zipFile.end();
35324
- streamToBuffer(zipFile.outputStream).then(resolve).catch(reject);
35333
+ streamToBuffer(zipFile.outputStream).then(resolve2).catch(reject);
35325
35334
  });
35326
35335
  return zipBuffer;
35327
35336
  }
@@ -35356,6 +35365,7 @@ async function getLambdaOptionsFromFunction({
35356
35365
  architecture: fn.architecture,
35357
35366
  memory: fn.memory,
35358
35367
  maxDuration: fn.maxDuration,
35368
+ affinity: fn.affinity,
35359
35369
  maxConcurrency: fn.maxConcurrency,
35360
35370
  regions: fn.regions,
35361
35371
  functionFailoverRegions: fn.functionFailoverRegions,
@@ -36705,7 +36715,7 @@ var NO_OVERRIDE = {
36705
36715
  path: void 0
36706
36716
  };
36707
36717
  function spawnAsync(command, args, opts = {}) {
36708
- return new Promise((resolve, reject) => {
36718
+ return new Promise((resolve2, reject) => {
36709
36719
  const stderrLogs = [];
36710
36720
  const hasCustomStreams = opts.outputStream || opts.errorStream;
36711
36721
  if (hasCustomStreams) {
@@ -36727,7 +36737,7 @@ function spawnAsync(command, args, opts = {}) {
36727
36737
  child.on("error", reject);
36728
36738
  child.on("close", (code, signal) => {
36729
36739
  if (code === 0 || opts.ignoreNon0Exit) {
36730
- return resolve();
36740
+ return resolve2();
36731
36741
  }
36732
36742
  const cmd = opts.prettyCommand ? `Command "${opts.prettyCommand}"` : "Command";
36733
36743
  reject(
@@ -37976,10 +37986,10 @@ var import_os2 = require("os");
37976
37986
  var import_path7 = require("path");
37977
37987
  var import_child_process = require("child_process");
37978
37988
  function spawnAsync2(command, args, options) {
37979
- return new Promise((resolve, reject) => {
37989
+ return new Promise((resolve2, reject) => {
37980
37990
  const child = (0, import_child_process.spawn)(command, args, options);
37981
37991
  child.once("error", reject);
37982
- child.once("close", resolve);
37992
+ child.once("close", resolve2);
37983
37993
  });
37984
37994
  }
37985
37995
  async function getOrCreateBunBinary() {
@@ -38289,6 +38299,38 @@ async function linkOrCopy(srcFile, destFile) {
38289
38299
  }
38290
38300
  }
38291
38301
 
38302
+ // src/get-node-exec-path.ts
38303
+ var import_node_fs = require("fs");
38304
+ var import_node_path = require("path");
38305
+ var NODE_EXEC_PATH_ENV = "VERCEL_NODE_EXEC_PATH";
38306
+ var NATIVE_CLI_ENV = "VERCEL_VC_NATIVE";
38307
+ function getNodeExecPath() {
38308
+ const override = process.env[NODE_EXEC_PATH_ENV];
38309
+ if (override)
38310
+ return override;
38311
+ if (!process.env[NATIVE_CLI_ENV])
38312
+ return process.execPath;
38313
+ const nodeExecPath = findNodeExecPath();
38314
+ process.env[NODE_EXEC_PATH_ENV] = nodeExecPath;
38315
+ return nodeExecPath;
38316
+ }
38317
+ function findNodeExecPath() {
38318
+ const executableName = process.platform === "win32" ? "node.exe" : "node";
38319
+ const cliPath = (0, import_node_fs.realpathSync)(process.execPath);
38320
+ for (const directory of (process.env.PATH || "").split(import_node_path.delimiter)) {
38321
+ if (!directory)
38322
+ continue;
38323
+ const candidate = (0, import_node_path.resolve)(directory, executableName);
38324
+ try {
38325
+ (0, import_node_fs.accessSync)(candidate, import_node_fs.constants.X_OK);
38326
+ if ((0, import_node_fs.realpathSync)(candidate) !== cliPath)
38327
+ return candidate;
38328
+ } catch {
38329
+ }
38330
+ }
38331
+ throw new Error("Could not find the Node.js executable in PATH.");
38332
+ }
38333
+
38292
38334
  // src/validate-npmrc.ts
38293
38335
  var import_path10 = require("path");
38294
38336
  var import_promises = require("fs/promises");
@@ -38332,6 +38374,7 @@ var ContainerImage = class {
38332
38374
  this.architecture = params.architecture;
38333
38375
  this.memory = params.memory;
38334
38376
  this.maxDuration = params.maxDuration;
38377
+ this.affinity = params.affinity;
38335
38378
  this.maxConcurrency = params.maxConcurrency;
38336
38379
  this.regions = params.regions;
38337
38380
  this.functionFailoverRegions = params.functionFailoverRegions;
@@ -38483,6 +38526,17 @@ var getFunctionsSchema = () => ({
38483
38526
  maximum: 10240
38484
38527
  },
38485
38528
  maxDuration: getMaxDurationSchema(),
38529
+ affinity: {
38530
+ type: "object",
38531
+ additionalProperties: false,
38532
+ required: ["mode"],
38533
+ properties: {
38534
+ mode: {
38535
+ type: "string",
38536
+ const: "strict"
38537
+ }
38538
+ }
38539
+ },
38486
38540
  maxConcurrency: {
38487
38541
  type: "integer",
38488
38542
  minimum: 1
@@ -39386,8 +39440,8 @@ async function isPackageInstalled(packageName, path8) {
39386
39440
  var defaultCachePathGlob = "**/{node_modules,.yarn/cache}/**";
39387
39441
 
39388
39442
  // src/generate-node-builder-functions.ts
39389
- var import_node_path = require("path");
39390
- var import_node_fs = __toESM(require("fs"));
39443
+ var import_node_path2 = require("path");
39444
+ var import_node_fs2 = __toESM(require("fs"));
39391
39445
  var import_node_module = require("module");
39392
39446
  function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, validExtensions, nodeBuild, opts) {
39393
39447
  const entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n");
@@ -39459,9 +39513,9 @@ function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, vali
39459
39513
  const {
39460
39514
  entrypoint: entrypointFromOutputDir,
39461
39515
  entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2
39462
- } = findEntrypoint(await glob(entrypointGlob, (0, import_node_path.join)(args.workPath, dir)));
39516
+ } = findEntrypoint(await glob(entrypointGlob, (0, import_node_path2.join)(args.workPath, dir)));
39463
39517
  if (entrypointFromOutputDir) {
39464
- return (0, import_node_path.join)(dir, entrypointFromOutputDir);
39518
+ return (0, import_node_path2.join)(dir, entrypointFromOutputDir);
39465
39519
  }
39466
39520
  if (entrypointsNotMatchingRegex2.length > 0) {
39467
39521
  throw new Error(
@@ -39533,7 +39587,7 @@ ${entrypointsForMessage}`
39533
39587
  };
39534
39588
  };
39535
39589
  const checkMatchesRegex = (file) => {
39536
- const content = import_node_fs.default.readFileSync(file.fsPath, "utf-8");
39590
+ const content = import_node_fs2.default.readFileSync(file.fsPath, "utf-8");
39537
39591
  const matchesContent = content.match(regex);
39538
39592
  return matchesContent !== null;
39539
39593
  };
@@ -39541,7 +39595,7 @@ ${entrypointsForMessage}`
39541
39595
  const packageJson = files["package.json"];
39542
39596
  if (packageJson) {
39543
39597
  if (packageJson.type === "FileFsRef") {
39544
- const packageJsonContent = import_node_fs.default.readFileSync(packageJson.fsPath, "utf-8");
39598
+ const packageJsonContent = import_node_fs2.default.readFileSync(packageJson.fsPath, "utf-8");
39545
39599
  let packageJsonJson;
39546
39600
  try {
39547
39601
  packageJsonJson = JSON.parse(packageJsonContent);
@@ -39959,7 +40013,7 @@ function getLambdaSupportsStreaming(lambda, forceStreamingRuntime) {
39959
40013
  // src/fs/stream-to-digest-async.ts
39960
40014
  var import_crypto = require("crypto");
39961
40015
  async function streamToDigestAsync(stream) {
39962
- return await new Promise((resolve, reject) => {
40016
+ return await new Promise((resolve2, reject) => {
39963
40017
  stream.once("error", reject);
39964
40018
  let count = 0;
39965
40019
  const sha2562 = (0, import_crypto.createHash)("sha256");
@@ -39970,7 +40024,7 @@ async function streamToDigestAsync(stream) {
39970
40024
  md5: md52.digest("hex"),
39971
40025
  size: count
39972
40026
  };
39973
- resolve(res);
40027
+ resolve2(res);
39974
40028
  });
39975
40029
  stream.on("readable", () => {
39976
40030
  let chunk;
@@ -40984,6 +41038,7 @@ function getExtendedPayload({
40984
41038
  getMaxDurationSchema,
40985
41039
  getNodeBinPath,
40986
41040
  getNodeBinPaths,
41041
+ getNodeExecPath,
40987
41042
  getNodeVersion,
40988
41043
  getOrCreateBunBinary,
40989
41044
  getPackageJson,
package/dist/lambda.d.ts CHANGED
@@ -20,6 +20,9 @@ export declare function sanitizeConsumerName(functionPath: string): string;
20
20
  export type LambdaOptions = LambdaOptionsWithFiles | LambdaOptionsWithZipBuffer;
21
21
  export type LambdaExecutableRuntimeLanguages = 'rust' | 'go';
22
22
  export type LambdaArchitecture = 'x86_64' | 'arm64';
23
+ export interface LambdaAffinity {
24
+ mode: 'strict';
25
+ }
23
26
  export interface LambdaOptionsBase {
24
27
  handler: string;
25
28
  runtime: string;
@@ -27,6 +30,7 @@ export interface LambdaOptionsBase {
27
30
  architecture?: LambdaArchitecture;
28
31
  memory?: number;
29
32
  maxDuration?: MaxDuration;
33
+ affinity?: LambdaAffinity;
30
34
  maxConcurrency?: number;
31
35
  environment?: Env;
32
36
  allowQuery?: string[];
@@ -103,6 +107,7 @@ export declare class Lambda {
103
107
  architecture: LambdaArchitecture;
104
108
  memory?: number;
105
109
  maxDuration?: MaxDuration;
110
+ affinity?: LambdaAffinity;
106
111
  /** Maximum number of requests that one function instance can process concurrently. */
107
112
  maxConcurrency?: number;
108
113
  environment: Env;
@@ -156,4 +161,4 @@ export declare class Lambda {
156
161
  */
157
162
  export declare function createLambda(opts: LambdaOptions): Promise<Lambda>;
158
163
  export declare function createZip(files: Files): Promise<Buffer>;
159
- export declare function getLambdaOptionsFromFunction({ sourceFile, config, }: GetLambdaOptionsFromFunctionOptions): Promise<Pick<LambdaOptions, 'architecture' | 'memory' | 'maxDuration' | 'maxConcurrency' | 'regions' | 'functionFailoverRegions' | 'experimentalTriggers' | 'supportsCancellation'>>;
164
+ export declare function getLambdaOptionsFromFunction({ sourceFile, config, }: GetLambdaOptionsFromFunctionOptions): Promise<Pick<LambdaOptions, 'architecture' | 'memory' | 'maxDuration' | 'affinity' | 'maxConcurrency' | 'regions' | 'functionFailoverRegions' | 'experimentalTriggers' | 'supportsCancellation'>>;
package/dist/lambda.js CHANGED
@@ -80,6 +80,7 @@ class Lambda {
80
80
  runtime,
81
81
  runtimeLanguage,
82
82
  maxDuration,
83
+ affinity,
83
84
  maxConcurrency,
84
85
  architecture,
85
86
  memory,
@@ -133,6 +134,12 @@ class Lambda {
133
134
  '"maxDuration" is not a number or "max"'
134
135
  );
135
136
  }
137
+ if (affinity !== void 0) {
138
+ (0, import_assert.default)(
139
+ typeof affinity === "object" && affinity !== null && affinity.mode === "strict" && Object.keys(affinity).length === 1,
140
+ '"affinity" must be an object with only `mode: "strict"`'
141
+ );
142
+ }
136
143
  if (maxConcurrency !== void 0) {
137
144
  (0, import_assert.default)(
138
145
  Number.isInteger(maxConcurrency) && maxConcurrency >= 1,
@@ -274,6 +281,7 @@ class Lambda {
274
281
  this.architecture = getDefaultLambdaArchitecture(architecture);
275
282
  this.memory = memory;
276
283
  this.maxDuration = maxDuration;
284
+ this.affinity = affinity;
277
285
  this.maxConcurrency = maxConcurrency;
278
286
  this.environment = environment;
279
287
  this.allowQuery = allowQuery;
@@ -383,6 +391,7 @@ async function getLambdaOptionsFromFunction({
383
391
  architecture: fn.architecture,
384
392
  memory: fn.memory,
385
393
  maxDuration: fn.maxDuration,
394
+ affinity: fn.affinity,
386
395
  maxConcurrency: fn.maxConcurrency,
387
396
  regions: fn.regions,
388
397
  functionFailoverRegions: fn.functionFailoverRegions,
package/dist/schemas.d.ts CHANGED
@@ -31,6 +31,17 @@ export declare const getFunctionsSchema: () => {
31
31
  enum: string[];
32
32
  })[];
33
33
  };
34
+ affinity: {
35
+ type: string;
36
+ additionalProperties: boolean;
37
+ required: string[];
38
+ properties: {
39
+ mode: {
40
+ type: string;
41
+ const: string;
42
+ };
43
+ };
44
+ };
34
45
  maxConcurrency: {
35
46
  type: string;
36
47
  minimum: number;
@@ -137,6 +148,17 @@ export declare const functionsSchema: {
137
148
  enum: string[];
138
149
  })[];
139
150
  };
151
+ affinity: {
152
+ type: string;
153
+ additionalProperties: boolean;
154
+ required: string[];
155
+ properties: {
156
+ mode: {
157
+ type: string;
158
+ const: string;
159
+ };
160
+ };
161
+ };
140
162
  maxConcurrency: {
141
163
  type: string;
142
164
  minimum: number;
package/dist/schemas.js CHANGED
@@ -117,6 +117,17 @@ const getFunctionsSchema = () => ({
117
117
  maximum: 10240
118
118
  },
119
119
  maxDuration: (0, import_max_duration.getMaxDurationSchema)(),
120
+ affinity: {
121
+ type: "object",
122
+ additionalProperties: false,
123
+ required: ["mode"],
124
+ properties: {
125
+ mode: {
126
+ type: "string",
127
+ const: "strict"
128
+ }
129
+ }
130
+ },
120
131
  maxConcurrency: {
121
132
  type: "integer",
122
133
  minimum: 1
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type FileRef from './file-ref';
2
2
  import type FileFsRef from './file-fs-ref';
3
3
  import type FileBlob from './file-blob';
4
- import type { Lambda, LambdaArchitecture } from './lambda';
4
+ import type { Lambda, LambdaAffinity, LambdaArchitecture } from './lambda';
5
5
  import type { Prerender } from './prerender';
6
6
  import type { EdgeFunction } from './edge-function';
7
7
  import type { ContainerImage } from './container-image';
@@ -415,6 +415,7 @@ export interface BuilderFunctions {
415
415
  architecture?: LambdaArchitecture;
416
416
  memory?: number;
417
417
  maxDuration?: MaxDuration;
418
+ affinity?: LambdaAffinity;
418
419
  maxConcurrency?: number;
419
420
  regions?: string[];
420
421
  functionFailoverRegions?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "14.5.1",
3
+ "version": "14.6.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",