@vercel/build-utils 8.4.12 → 8.6.0

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
+ ## 8.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add support for `NOW_EPHEMERAL_FILES_S3_URL`, `NOW_FILES_CLOUDFRONT_URL` and `NOW_FILES_S3_URL` environment variables ([#12643](https://github.com/vercel/vercel/pull/12643))
8
+
9
+ ## 8.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Remove `VERCEL_ALLOW_NODEJS22` env var check ([#12614](https://github.com/vercel/vercel/pull/12614))
14
+
3
15
  ## 8.4.12
4
16
 
5
17
  ### Patch Changes
@@ -13,6 +13,25 @@ export default class FileRef implements FileBase {
13
13
  contentType: string | undefined;
14
14
  private mutable;
15
15
  constructor({ mode, digest, contentType, mutable, }: FileRefOptions);
16
+ /**
17
+ * Retrieves the URL of the CloudFront distribution for the S3
18
+ * bucket represented by {@link getNowFilesS3Url}.
19
+ *
20
+ * @returns The URL of the CloudFront distribution
21
+ */
22
+ private getNowFilesCloudfrontUrl;
23
+ /**
24
+ * Retrieves the URL of the S3 bucket for storing ephemeral files.
25
+ *
26
+ * @returns The URL of the S3 bucket
27
+ */
28
+ private getNowEphemeralFilesS3Url;
29
+ /**
30
+ * Retrieves the URL of the S3 bucket for storing files.
31
+ *
32
+ * @returns The URL of the S3 bucket
33
+ */
34
+ private getNowFilesS3Url;
16
35
  toStreamAsync(): Promise<NodeJS.ReadableStream>;
17
36
  toStream(): NodeJS.ReadableStream;
18
37
  }
package/dist/file-ref.js CHANGED
@@ -58,13 +58,38 @@ class FileRef {
58
58
  this.contentType = contentType;
59
59
  this.mutable = mutable;
60
60
  }
61
+ /**
62
+ * Retrieves the URL of the CloudFront distribution for the S3
63
+ * bucket represented by {@link getNowFilesS3Url}.
64
+ *
65
+ * @returns The URL of the CloudFront distribution
66
+ */
67
+ getNowFilesCloudfrontUrl() {
68
+ return getEnvAsUrlOrThrow("NOW_FILES_CLOUDFRONT_URL") || "https://dmmcy0pwk6bqi.cloudfront.net";
69
+ }
70
+ /**
71
+ * Retrieves the URL of the S3 bucket for storing ephemeral files.
72
+ *
73
+ * @returns The URL of the S3 bucket
74
+ */
75
+ getNowEphemeralFilesS3Url() {
76
+ return getEnvAsUrlOrThrow("NOW_EPHEMERAL_FILES_S3_URL") || "https://now-ephemeral-files.s3.amazonaws.com";
77
+ }
78
+ /**
79
+ * Retrieves the URL of the S3 bucket for storing files.
80
+ *
81
+ * @returns The URL of the S3 bucket
82
+ */
83
+ getNowFilesS3Url() {
84
+ return getEnvAsUrlOrThrow("NOW_FILES_S3_URL") || "https://now-files.s3.amazonaws.com";
85
+ }
61
86
  async toStreamAsync() {
62
87
  let url = "";
63
88
  const [digestType, digestHash] = this.digest.split(":");
64
89
  if (digestType === "sha") {
65
- url = this.mutable ? `https://now-files.s3.amazonaws.com/${digestHash}` : `https://dmmcy0pwk6bqi.cloudfront.net/${digestHash}`;
90
+ url = this.mutable ? `${this.getNowFilesS3Url()}/${digestHash}` : `${this.getNowFilesCloudfrontUrl()}/${digestHash}`;
66
91
  } else if (digestType === "sha+ephemeral") {
67
- url = `https://now-ephemeral-files.s3.amazonaws.com/${digestHash}`;
92
+ url = `${this.getNowEphemeralFilesS3Url()}/${digestHash}`;
68
93
  } else {
69
94
  throw new Error("Expected digest to be sha");
70
95
  }
@@ -103,3 +128,20 @@ class FileRef {
103
128
  });
104
129
  }
105
130
  }
131
+ function getEnvAsUrlOrThrow(key) {
132
+ const value = process.env[key];
133
+ if (value === void 0)
134
+ return void 0;
135
+ try {
136
+ new URL(value);
137
+ return value;
138
+ } catch (e) {
139
+ if (e instanceof TypeError && "code" in e && e.code === "ERR_INVALID_URL") {
140
+ throw new Error(
141
+ `A non-URL value was supplied to the ${key} environment variable`
142
+ );
143
+ } else {
144
+ throw e;
145
+ }
146
+ }
147
+ }
@@ -40,6 +40,7 @@ var import_semver = require("semver");
40
40
  var import_errors = require("../errors");
41
41
  var import_debug = __toESM(require("../debug"));
42
42
  const NODE_VERSIONS = [
43
+ { major: 22, range: "22.x", runtime: "nodejs22.x" },
43
44
  { major: 20, range: "20.x", runtime: "nodejs20.x" },
44
45
  { major: 18, range: "18.x", runtime: "nodejs18.x" },
45
46
  {
@@ -74,12 +75,6 @@ const NODE_VERSIONS = [
74
75
  }
75
76
  ];
76
77
  function getOptions() {
77
- if (process.env.VERCEL_ALLOW_NODEJS22 === "1") {
78
- return [
79
- { major: 22, range: "22.x", runtime: "nodejs22.x" },
80
- ...NODE_VERSIONS
81
- ];
82
- }
83
78
  return NODE_VERSIONS;
84
79
  }
85
80
  function isNodeVersionAvailable(version) {
package/dist/index.js CHANGED
@@ -8619,8 +8619,8 @@ var require_URL = __commonJS({
8619
8619
  var utils = require_utils3();
8620
8620
  var Impl = require_URL_impl();
8621
8621
  var impl = utils.implSymbol;
8622
- function URL(url) {
8623
- if (!this || this[impl] || !(this instanceof URL)) {
8622
+ function URL2(url) {
8623
+ if (!this || this[impl] || !(this instanceof URL2)) {
8624
8624
  throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
8625
8625
  }
8626
8626
  if (arguments.length < 1) {
@@ -8636,7 +8636,7 @@ var require_URL = __commonJS({
8636
8636
  }
8637
8637
  module2.exports.setup(this, args);
8638
8638
  }
8639
- URL.prototype.toJSON = function toJSON() {
8639
+ URL2.prototype.toJSON = function toJSON() {
8640
8640
  if (!this || !module2.exports.is(this)) {
8641
8641
  throw new TypeError("Illegal invocation");
8642
8642
  }
@@ -8646,7 +8646,7 @@ var require_URL = __commonJS({
8646
8646
  }
8647
8647
  return this[impl].toJSON.apply(this[impl], args);
8648
8648
  };
8649
- Object.defineProperty(URL.prototype, "href", {
8649
+ Object.defineProperty(URL2.prototype, "href", {
8650
8650
  get() {
8651
8651
  return this[impl].href;
8652
8652
  },
@@ -8657,20 +8657,20 @@ var require_URL = __commonJS({
8657
8657
  enumerable: true,
8658
8658
  configurable: true
8659
8659
  });
8660
- URL.prototype.toString = function() {
8660
+ URL2.prototype.toString = function() {
8661
8661
  if (!this || !module2.exports.is(this)) {
8662
8662
  throw new TypeError("Illegal invocation");
8663
8663
  }
8664
8664
  return this.href;
8665
8665
  };
8666
- Object.defineProperty(URL.prototype, "origin", {
8666
+ Object.defineProperty(URL2.prototype, "origin", {
8667
8667
  get() {
8668
8668
  return this[impl].origin;
8669
8669
  },
8670
8670
  enumerable: true,
8671
8671
  configurable: true
8672
8672
  });
8673
- Object.defineProperty(URL.prototype, "protocol", {
8673
+ Object.defineProperty(URL2.prototype, "protocol", {
8674
8674
  get() {
8675
8675
  return this[impl].protocol;
8676
8676
  },
@@ -8681,7 +8681,7 @@ var require_URL = __commonJS({
8681
8681
  enumerable: true,
8682
8682
  configurable: true
8683
8683
  });
8684
- Object.defineProperty(URL.prototype, "username", {
8684
+ Object.defineProperty(URL2.prototype, "username", {
8685
8685
  get() {
8686
8686
  return this[impl].username;
8687
8687
  },
@@ -8692,7 +8692,7 @@ var require_URL = __commonJS({
8692
8692
  enumerable: true,
8693
8693
  configurable: true
8694
8694
  });
8695
- Object.defineProperty(URL.prototype, "password", {
8695
+ Object.defineProperty(URL2.prototype, "password", {
8696
8696
  get() {
8697
8697
  return this[impl].password;
8698
8698
  },
@@ -8703,7 +8703,7 @@ var require_URL = __commonJS({
8703
8703
  enumerable: true,
8704
8704
  configurable: true
8705
8705
  });
8706
- Object.defineProperty(URL.prototype, "host", {
8706
+ Object.defineProperty(URL2.prototype, "host", {
8707
8707
  get() {
8708
8708
  return this[impl].host;
8709
8709
  },
@@ -8714,7 +8714,7 @@ var require_URL = __commonJS({
8714
8714
  enumerable: true,
8715
8715
  configurable: true
8716
8716
  });
8717
- Object.defineProperty(URL.prototype, "hostname", {
8717
+ Object.defineProperty(URL2.prototype, "hostname", {
8718
8718
  get() {
8719
8719
  return this[impl].hostname;
8720
8720
  },
@@ -8725,7 +8725,7 @@ var require_URL = __commonJS({
8725
8725
  enumerable: true,
8726
8726
  configurable: true
8727
8727
  });
8728
- Object.defineProperty(URL.prototype, "port", {
8728
+ Object.defineProperty(URL2.prototype, "port", {
8729
8729
  get() {
8730
8730
  return this[impl].port;
8731
8731
  },
@@ -8736,7 +8736,7 @@ var require_URL = __commonJS({
8736
8736
  enumerable: true,
8737
8737
  configurable: true
8738
8738
  });
8739
- Object.defineProperty(URL.prototype, "pathname", {
8739
+ Object.defineProperty(URL2.prototype, "pathname", {
8740
8740
  get() {
8741
8741
  return this[impl].pathname;
8742
8742
  },
@@ -8747,7 +8747,7 @@ var require_URL = __commonJS({
8747
8747
  enumerable: true,
8748
8748
  configurable: true
8749
8749
  });
8750
- Object.defineProperty(URL.prototype, "search", {
8750
+ Object.defineProperty(URL2.prototype, "search", {
8751
8751
  get() {
8752
8752
  return this[impl].search;
8753
8753
  },
@@ -8758,7 +8758,7 @@ var require_URL = __commonJS({
8758
8758
  enumerable: true,
8759
8759
  configurable: true
8760
8760
  });
8761
- Object.defineProperty(URL.prototype, "hash", {
8761
+ Object.defineProperty(URL2.prototype, "hash", {
8762
8762
  get() {
8763
8763
  return this[impl].hash;
8764
8764
  },
@@ -8774,7 +8774,7 @@ var require_URL = __commonJS({
8774
8774
  return !!obj && obj[impl] instanceof Impl.implementation;
8775
8775
  },
8776
8776
  create(constructorArgs, privateData) {
8777
- let obj = Object.create(URL.prototype);
8777
+ let obj = Object.create(URL2.prototype);
8778
8778
  this.setup(obj, constructorArgs, privateData);
8779
8779
  return obj;
8780
8780
  },
@@ -8785,10 +8785,10 @@ var require_URL = __commonJS({
8785
8785
  obj[impl] = new Impl.implementation(constructorArgs, privateData);
8786
8786
  obj[impl][utils.wrapperSymbol] = obj;
8787
8787
  },
8788
- interface: URL,
8788
+ interface: URL2,
8789
8789
  expose: {
8790
- Window: { URL },
8791
- Worker: { URL }
8790
+ Window: { URL: URL2 },
8791
+ Worker: { URL: URL2 }
8792
8792
  }
8793
8793
  };
8794
8794
  }
@@ -9639,12 +9639,12 @@ var require_lib3 = __commonJS({
9639
9639
  configurable: true
9640
9640
  });
9641
9641
  var INTERNALS$2 = Symbol("Request internals");
9642
- var URL = Url.URL || whatwgUrl.URL;
9642
+ var URL2 = Url.URL || whatwgUrl.URL;
9643
9643
  var parse_url = Url.parse;
9644
9644
  var format_url = Url.format;
9645
9645
  function parseURL(urlStr) {
9646
9646
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
9647
- urlStr = new URL(urlStr).toString();
9647
+ urlStr = new URL2(urlStr).toString();
9648
9648
  }
9649
9649
  return parse_url(urlStr);
9650
9650
  }
@@ -23651,13 +23651,38 @@ var FileRef = class {
23651
23651
  this.contentType = contentType;
23652
23652
  this.mutable = mutable;
23653
23653
  }
23654
+ /**
23655
+ * Retrieves the URL of the CloudFront distribution for the S3
23656
+ * bucket represented by {@link getNowFilesS3Url}.
23657
+ *
23658
+ * @returns The URL of the CloudFront distribution
23659
+ */
23660
+ getNowFilesCloudfrontUrl() {
23661
+ return getEnvAsUrlOrThrow("NOW_FILES_CLOUDFRONT_URL") || "https://dmmcy0pwk6bqi.cloudfront.net";
23662
+ }
23663
+ /**
23664
+ * Retrieves the URL of the S3 bucket for storing ephemeral files.
23665
+ *
23666
+ * @returns The URL of the S3 bucket
23667
+ */
23668
+ getNowEphemeralFilesS3Url() {
23669
+ return getEnvAsUrlOrThrow("NOW_EPHEMERAL_FILES_S3_URL") || "https://now-ephemeral-files.s3.amazonaws.com";
23670
+ }
23671
+ /**
23672
+ * Retrieves the URL of the S3 bucket for storing files.
23673
+ *
23674
+ * @returns The URL of the S3 bucket
23675
+ */
23676
+ getNowFilesS3Url() {
23677
+ return getEnvAsUrlOrThrow("NOW_FILES_S3_URL") || "https://now-files.s3.amazonaws.com";
23678
+ }
23654
23679
  async toStreamAsync() {
23655
23680
  let url = "";
23656
23681
  const [digestType, digestHash] = this.digest.split(":");
23657
23682
  if (digestType === "sha") {
23658
- url = this.mutable ? `https://now-files.s3.amazonaws.com/${digestHash}` : `https://dmmcy0pwk6bqi.cloudfront.net/${digestHash}`;
23683
+ url = this.mutable ? `${this.getNowFilesS3Url()}/${digestHash}` : `${this.getNowFilesCloudfrontUrl()}/${digestHash}`;
23659
23684
  } else if (digestType === "sha+ephemeral") {
23660
- url = `https://now-ephemeral-files.s3.amazonaws.com/${digestHash}`;
23685
+ url = `${this.getNowEphemeralFilesS3Url()}/${digestHash}`;
23661
23686
  } else {
23662
23687
  throw new Error("Expected digest to be sha");
23663
23688
  }
@@ -23696,6 +23721,23 @@ var FileRef = class {
23696
23721
  });
23697
23722
  }
23698
23723
  };
23724
+ function getEnvAsUrlOrThrow(key) {
23725
+ const value = process.env[key];
23726
+ if (value === void 0)
23727
+ return void 0;
23728
+ try {
23729
+ new URL(value);
23730
+ return value;
23731
+ } catch (e) {
23732
+ if (e instanceof TypeError && "code" in e && e.code === "ERR_INVALID_URL") {
23733
+ throw new Error(
23734
+ `A non-URL value was supplied to the ${key} environment variable`
23735
+ );
23736
+ } else {
23737
+ throw e;
23738
+ }
23739
+ }
23740
+ }
23699
23741
 
23700
23742
  // src/lambda.ts
23701
23743
  var import_assert4 = __toESM(require("assert"));
@@ -24384,6 +24426,7 @@ var import_util2 = require("util");
24384
24426
  var import_fs = require("fs");
24385
24427
  var import_semver = __toESM(require_semver2());
24386
24428
  var NODE_VERSIONS = [
24429
+ { major: 22, range: "22.x", runtime: "nodejs22.x" },
24387
24430
  { major: 20, range: "20.x", runtime: "nodejs20.x" },
24388
24431
  { major: 18, range: "18.x", runtime: "nodejs18.x" },
24389
24432
  {
@@ -24418,12 +24461,6 @@ var NODE_VERSIONS = [
24418
24461
  }
24419
24462
  ];
24420
24463
  function getOptions() {
24421
- if (process.env.VERCEL_ALLOW_NODEJS22 === "1") {
24422
- return [
24423
- { major: 22, range: "22.x", runtime: "nodejs22.x" },
24424
- ...NODE_VERSIONS
24425
- ];
24426
- }
24427
24464
  return NODE_VERSIONS;
24428
24465
  }
24429
24466
  function isNodeVersionAvailable(version) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "8.4.12",
3
+ "version": "8.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -26,7 +26,7 @@
26
26
  "@types/node-fetch": "^2.1.6",
27
27
  "@types/semver": "6.0.0",
28
28
  "@types/yazl": "2.4.2",
29
- "@vercel/error-utils": "2.0.2",
29
+ "@vercel/error-utils": "2.0.3",
30
30
  "aggregate-error": "3.0.1",
31
31
  "async-retry": "1.2.3",
32
32
  "async-sema": "2.1.4",
@@ -40,18 +40,21 @@
40
40
  "jest-junit": "16.0.0",
41
41
  "js-yaml": "3.13.1",
42
42
  "minimatch": "3.1.2",
43
+ "ms": "2.1.3",
43
44
  "multistream": "2.1.1",
44
45
  "node-fetch": "2.6.7",
45
46
  "semver": "6.3.1",
46
47
  "typescript": "4.9.5",
47
48
  "yazl": "2.5.1",
49
+ "vitest": "2.0.1",
48
50
  "json5": "2.2.3"
49
51
  },
50
52
  "scripts": {
51
53
  "build": "node build.mjs",
52
- "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
53
- "test-unit": "pnpm test test/unit.*test.*",
54
- "test-e2e": "pnpm test test/integration.test.ts",
54
+ "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand",
55
+ "vitest-run": "vitest -c ../../vitest.config.mts",
56
+ "vitest-unit": "glob --absolute 'test/unit.*.test.ts'",
57
+ "vitest-e2e": "glob --absolute 'test/integration-*.test.ts'",
55
58
  "type-check": "tsc --noEmit"
56
59
  }
57
60
  }