@vercel/build-utils 9.0.1 → 9.1.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,20 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 9.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [cli] shift node 16 deprecation date to 2025-02-03 ([#12981](https://github.com/vercel/vercel/pull/12981))
8
+
9
+ ## 9.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Add `useWebApi` property to `NodejsLambda` class ([#12873](https://github.com/vercel/vercel/pull/12873))
14
+
15
+ - [build-utils] convert NodeVersion to class and add state getter ([#12883](https://github.com/vercel/vercel/pull/12883))
16
+ [ruby] convert RubyVersion to class and add state getter
17
+
3
18
  ## 9.0.1
4
19
 
5
20
  ### Patch Changes
@@ -37,42 +37,55 @@ __export(node_version_exports, {
37
37
  module.exports = __toCommonJS(node_version_exports);
38
38
  var import_fs = require("fs");
39
39
  var import_semver = require("semver");
40
+ var import_types = require("../types");
40
41
  var import_errors = require("../errors");
41
42
  var import_debug = __toESM(require("../debug"));
42
43
  const NODE_VERSIONS = [
43
- { major: 22, range: "22.x", runtime: "nodejs22.x" },
44
- { major: 20, range: "20.x", runtime: "nodejs20.x" },
45
- { major: 18, range: "18.x", runtime: "nodejs18.x" },
46
- {
44
+ new import_types.NodeVersion({
45
+ major: 22,
46
+ range: "22.x",
47
+ runtime: "nodejs22.x"
48
+ }),
49
+ new import_types.NodeVersion({
50
+ major: 20,
51
+ range: "20.x",
52
+ runtime: "nodejs20.x"
53
+ }),
54
+ new import_types.NodeVersion({
55
+ major: 18,
56
+ range: "18.x",
57
+ runtime: "nodejs18.x"
58
+ }),
59
+ new import_types.NodeVersion({
47
60
  major: 16,
48
61
  range: "16.x",
49
62
  runtime: "nodejs16.x",
50
- discontinueDate: /* @__PURE__ */ new Date("2025-01-31")
51
- },
52
- {
63
+ discontinueDate: /* @__PURE__ */ new Date("2025-02-03")
64
+ }),
65
+ new import_types.NodeVersion({
53
66
  major: 14,
54
67
  range: "14.x",
55
68
  runtime: "nodejs14.x",
56
69
  discontinueDate: /* @__PURE__ */ new Date("2023-08-15")
57
- },
58
- {
70
+ }),
71
+ new import_types.NodeVersion({
59
72
  major: 12,
60
73
  range: "12.x",
61
74
  runtime: "nodejs12.x",
62
75
  discontinueDate: /* @__PURE__ */ new Date("2022-10-03")
63
- },
64
- {
76
+ }),
77
+ new import_types.NodeVersion({
65
78
  major: 10,
66
79
  range: "10.x",
67
80
  runtime: "nodejs10.x",
68
81
  discontinueDate: /* @__PURE__ */ new Date("2021-04-20")
69
- },
70
- {
82
+ }),
83
+ new import_types.NodeVersion({
71
84
  major: 8,
72
85
  range: "8.10.x",
73
86
  runtime: "nodejs8.10",
74
87
  discontinueDate: /* @__PURE__ */ new Date("2020-01-06")
75
- }
88
+ })
76
89
  ];
77
90
  function getOptions() {
78
91
  return NODE_VERSIONS;
@@ -105,7 +118,9 @@ function getLatestNodeVersion(availableVersions) {
105
118
  return all[0];
106
119
  }
107
120
  function getDiscontinuedNodeVersions() {
108
- return getOptions().filter(isDiscontinued);
121
+ return getOptions().filter((version) => {
122
+ return version.state === "discontinued";
123
+ });
109
124
  }
110
125
  async function getSupportedNodeVersion(engineRange, isAuto = false, availableVersions) {
111
126
  let selection;
@@ -128,7 +143,7 @@ async function getSupportedNodeVersion(engineRange, isAuto = false, availableVer
128
143
  if (!selection) {
129
144
  selection = getLatestNodeVersion(availableVersions);
130
145
  }
131
- if (isDiscontinued(selection)) {
146
+ if (selection.state === "discontinued") {
132
147
  const intro = `Node.js Version "${selection.range}" is discontinued and must be upgraded.`;
133
148
  throw new import_errors.NowBuildError({
134
149
  code: "BUILD_UTILS_NODE_VERSION_DISCONTINUED",
@@ -137,20 +152,24 @@ async function getSupportedNodeVersion(engineRange, isAuto = false, availableVer
137
152
  });
138
153
  }
139
154
  (0, import_debug.default)(`Selected Node.js ${selection.range}`);
140
- if (selection.discontinueDate) {
141
- const d = selection.discontinueDate.toISOString().split("T")[0];
142
- console.warn(
143
- `Error: Node.js version ${selection.range} has reached End-of-Life. Deployments created on or after ${d} will fail to build. ${getHint(
144
- isAuto
145
- )}`
146
- );
155
+ if (selection.state === "deprecated") {
156
+ const d = selection.formattedDate;
157
+ if (d) {
158
+ console.warn(
159
+ `Error: Node.js version ${selection.range} is deprecated. Deployments created on or after ${d} will fail to build. ${getHint(
160
+ isAuto
161
+ )}`
162
+ );
163
+ } else {
164
+ console.warn(
165
+ `Error: Node.js version ${selection.range} is deprecated. ${getHint(
166
+ isAuto
167
+ )}`
168
+ );
169
+ }
147
170
  }
148
171
  return selection;
149
172
  }
150
- function isDiscontinued({ discontinueDate }) {
151
- const today = Date.now();
152
- return discontinueDate !== void 0 && discontinueDate.getTime() <= today;
153
- }
154
173
  // Annotate the CommonJS export names for ESM import in node:
155
174
  0 && (module.exports = {
156
175
  NODE_VERSIONS,
@@ -201,7 +201,8 @@ function getSpawnOptions(meta, nodeVersion) {
201
201
  async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = (0, import_node_version.getAvailableNodeVersions)()) {
202
202
  const latestVersion = (0, import_node_version.getLatestNodeVersion)(availableVersions);
203
203
  if (meta.isDev) {
204
- return { ...latestVersion, runtime: "nodejs" };
204
+ latestVersion.runtime = "nodejs";
205
+ return latestVersion;
205
206
  }
206
207
  const { packageJson } = await scanParentDirs(destPath, true);
207
208
  const configuredVersion = config.nodeVersion || fallbackVersion;
package/dist/index.js CHANGED
@@ -21851,9 +21851,11 @@ __export(src_exports, {
21851
21851
  FileRef: () => FileRef,
21852
21852
  Lambda: () => Lambda,
21853
21853
  NODE_VERSIONS: () => NODE_VERSIONS,
21854
+ NodeVersion: () => NodeVersion,
21854
21855
  NodejsLambda: () => NodejsLambda,
21855
21856
  NowBuildError: () => NowBuildError,
21856
21857
  Prerender: () => Prerender,
21858
+ Version: () => Version,
21857
21859
  buildsSchema: () => buildsSchema,
21858
21860
  cloneEnv: () => cloneEnv,
21859
21861
  createLambda: () => createLambda,
@@ -22581,6 +22583,7 @@ var NodejsLambda = class extends Lambda {
22581
22583
  shouldAddHelpers,
22582
22584
  shouldAddSourcemapSupport,
22583
22585
  awsLambdaHandler,
22586
+ useWebApi,
22584
22587
  ...opts
22585
22588
  }) {
22586
22589
  super(opts);
@@ -22588,6 +22591,7 @@ var NodejsLambda = class extends Lambda {
22588
22591
  this.shouldAddHelpers = shouldAddHelpers;
22589
22592
  this.shouldAddSourcemapSupport = shouldAddSourcemapSupport;
22590
22593
  this.awsLambdaHandler = awsLambdaHandler;
22594
+ this.useWebApi = useWebApi;
22591
22595
  }
22592
22596
  };
22593
22597
 
@@ -22853,40 +22857,78 @@ var import_util2 = require("util");
22853
22857
  // src/fs/node-version.ts
22854
22858
  var import_fs = require("fs");
22855
22859
  var import_semver = __toESM(require_semver2());
22860
+
22861
+ // src/types.ts
22862
+ var Version = class {
22863
+ constructor(version) {
22864
+ this.major = version.major;
22865
+ this.minor = version.minor;
22866
+ this.range = version.range;
22867
+ this.runtime = version.runtime;
22868
+ this.discontinueDate = version.discontinueDate;
22869
+ }
22870
+ get state() {
22871
+ if (this.discontinueDate && this.discontinueDate.getTime() <= Date.now()) {
22872
+ return "discontinued";
22873
+ } else if (this.discontinueDate) {
22874
+ return "deprecated";
22875
+ }
22876
+ return "active";
22877
+ }
22878
+ get formattedDate() {
22879
+ return this.discontinueDate && this.discontinueDate.toISOString().split("T")[0];
22880
+ }
22881
+ };
22882
+ var NodeVersion = class extends Version {
22883
+ };
22884
+
22885
+ // src/fs/node-version.ts
22856
22886
  var NODE_VERSIONS = [
22857
- { major: 22, range: "22.x", runtime: "nodejs22.x" },
22858
- { major: 20, range: "20.x", runtime: "nodejs20.x" },
22859
- { major: 18, range: "18.x", runtime: "nodejs18.x" },
22860
- {
22887
+ new NodeVersion({
22888
+ major: 22,
22889
+ range: "22.x",
22890
+ runtime: "nodejs22.x"
22891
+ }),
22892
+ new NodeVersion({
22893
+ major: 20,
22894
+ range: "20.x",
22895
+ runtime: "nodejs20.x"
22896
+ }),
22897
+ new NodeVersion({
22898
+ major: 18,
22899
+ range: "18.x",
22900
+ runtime: "nodejs18.x"
22901
+ }),
22902
+ new NodeVersion({
22861
22903
  major: 16,
22862
22904
  range: "16.x",
22863
22905
  runtime: "nodejs16.x",
22864
- discontinueDate: /* @__PURE__ */ new Date("2025-01-31")
22865
- },
22866
- {
22906
+ discontinueDate: /* @__PURE__ */ new Date("2025-02-03")
22907
+ }),
22908
+ new NodeVersion({
22867
22909
  major: 14,
22868
22910
  range: "14.x",
22869
22911
  runtime: "nodejs14.x",
22870
22912
  discontinueDate: /* @__PURE__ */ new Date("2023-08-15")
22871
- },
22872
- {
22913
+ }),
22914
+ new NodeVersion({
22873
22915
  major: 12,
22874
22916
  range: "12.x",
22875
22917
  runtime: "nodejs12.x",
22876
22918
  discontinueDate: /* @__PURE__ */ new Date("2022-10-03")
22877
- },
22878
- {
22919
+ }),
22920
+ new NodeVersion({
22879
22921
  major: 10,
22880
22922
  range: "10.x",
22881
22923
  runtime: "nodejs10.x",
22882
22924
  discontinueDate: /* @__PURE__ */ new Date("2021-04-20")
22883
- },
22884
- {
22925
+ }),
22926
+ new NodeVersion({
22885
22927
  major: 8,
22886
22928
  range: "8.10.x",
22887
22929
  runtime: "nodejs8.10",
22888
22930
  discontinueDate: /* @__PURE__ */ new Date("2020-01-06")
22889
- }
22931
+ })
22890
22932
  ];
22891
22933
  function getOptions() {
22892
22934
  return NODE_VERSIONS;
@@ -22919,7 +22961,9 @@ function getLatestNodeVersion(availableVersions) {
22919
22961
  return all[0];
22920
22962
  }
22921
22963
  function getDiscontinuedNodeVersions() {
22922
- return getOptions().filter(isDiscontinued);
22964
+ return getOptions().filter((version) => {
22965
+ return version.state === "discontinued";
22966
+ });
22923
22967
  }
22924
22968
  async function getSupportedNodeVersion(engineRange, isAuto = false, availableVersions) {
22925
22969
  let selection;
@@ -22942,7 +22986,7 @@ async function getSupportedNodeVersion(engineRange, isAuto = false, availableVer
22942
22986
  if (!selection) {
22943
22987
  selection = getLatestNodeVersion(availableVersions);
22944
22988
  }
22945
- if (isDiscontinued(selection)) {
22989
+ if (selection.state === "discontinued") {
22946
22990
  const intro = `Node.js Version "${selection.range}" is discontinued and must be upgraded.`;
22947
22991
  throw new NowBuildError({
22948
22992
  code: "BUILD_UTILS_NODE_VERSION_DISCONTINUED",
@@ -22951,20 +22995,24 @@ async function getSupportedNodeVersion(engineRange, isAuto = false, availableVer
22951
22995
  });
22952
22996
  }
22953
22997
  debug(`Selected Node.js ${selection.range}`);
22954
- if (selection.discontinueDate) {
22955
- const d = selection.discontinueDate.toISOString().split("T")[0];
22956
- console.warn(
22957
- `Error: Node.js version ${selection.range} has reached End-of-Life. Deployments created on or after ${d} will fail to build. ${getHint(
22958
- isAuto
22959
- )}`
22960
- );
22998
+ if (selection.state === "deprecated") {
22999
+ const d = selection.formattedDate;
23000
+ if (d) {
23001
+ console.warn(
23002
+ `Error: Node.js version ${selection.range} is deprecated. Deployments created on or after ${d} will fail to build. ${getHint(
23003
+ isAuto
23004
+ )}`
23005
+ );
23006
+ } else {
23007
+ console.warn(
23008
+ `Error: Node.js version ${selection.range} is deprecated. ${getHint(
23009
+ isAuto
23010
+ )}`
23011
+ );
23012
+ }
22961
23013
  }
22962
23014
  return selection;
22963
23015
  }
22964
- function isDiscontinued({ discontinueDate }) {
22965
- const today = Date.now();
22966
- return discontinueDate !== void 0 && discontinueDate.getTime() <= today;
22967
- }
22968
23016
 
22969
23017
  // src/fs/read-config-file.ts
22970
23018
  var import_js_yaml = __toESM(require_js_yaml2());
@@ -23161,7 +23209,8 @@ function getSpawnOptions(meta, nodeVersion) {
23161
23209
  async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = getAvailableNodeVersions()) {
23162
23210
  const latestVersion = getLatestNodeVersion(availableVersions);
23163
23211
  if (meta.isDev) {
23164
- return { ...latestVersion, runtime: "nodejs" };
23212
+ latestVersion.runtime = "nodejs";
23213
+ return latestVersion;
23165
23214
  }
23166
23215
  const { packageJson } = await scanParentDirs(destPath, true);
23167
23216
  const configuredVersion = config.nodeVersion || fallbackVersion;
@@ -24199,9 +24248,11 @@ async function getInstalledPackageVersion(packageName, path7) {
24199
24248
  FileRef,
24200
24249
  Lambda,
24201
24250
  NODE_VERSIONS,
24251
+ NodeVersion,
24202
24252
  NodejsLambda,
24203
24253
  NowBuildError,
24204
24254
  Prerender,
24255
+ Version,
24205
24256
  buildsSchema,
24206
24257
  cloneEnv,
24207
24258
  createLambda,
@@ -3,12 +3,14 @@ interface NodejsLambdaOptions extends LambdaOptionsWithFiles {
3
3
  shouldAddHelpers: boolean;
4
4
  shouldAddSourcemapSupport: boolean;
5
5
  awsLambdaHandler?: string;
6
+ useWebApi?: boolean;
6
7
  }
7
8
  export declare class NodejsLambda extends Lambda {
8
9
  launcherType: 'Nodejs';
9
10
  shouldAddHelpers: boolean;
10
11
  shouldAddSourcemapSupport: boolean;
11
12
  awsLambdaHandler?: string;
12
- constructor({ shouldAddHelpers, shouldAddSourcemapSupport, awsLambdaHandler, ...opts }: NodejsLambdaOptions);
13
+ useWebApi?: boolean;
14
+ constructor({ shouldAddHelpers, shouldAddSourcemapSupport, awsLambdaHandler, useWebApi, ...opts }: NodejsLambdaOptions);
13
15
  }
14
16
  export {};
@@ -27,6 +27,7 @@ class NodejsLambda extends import_lambda.Lambda {
27
27
  shouldAddHelpers,
28
28
  shouldAddSourcemapSupport,
29
29
  awsLambdaHandler,
30
+ useWebApi,
30
31
  ...opts
31
32
  }) {
32
33
  super(opts);
@@ -34,6 +35,7 @@ class NodejsLambda extends import_lambda.Lambda {
34
35
  this.shouldAddHelpers = shouldAddHelpers;
35
36
  this.shouldAddSourcemapSupport = shouldAddSourcemapSupport;
36
37
  this.awsLambdaHandler = awsLambdaHandler;
38
+ this.useWebApi = useWebApi;
37
39
  }
38
40
  }
39
41
  // Annotate the CommonJS export names for ESM import in node:
package/dist/types.d.ts CHANGED
@@ -283,16 +283,32 @@ export interface PackageJson {
283
283
  readonly publishConfig?: PackageJson.PublishConfig;
284
284
  readonly packageManager?: string;
285
285
  }
286
- export interface NodeVersion {
286
+ export interface ConstructorVersion {
287
287
  /** major version number: 18 */
288
288
  major: number;
289
+ /** minor version number: 18 */
290
+ minor?: number;
289
291
  /** major version range: "18.x" */
290
292
  range: string;
291
293
  /** runtime descriptor: "nodejs18.x" */
292
294
  runtime: string;
293
- /** date beyond which this version is discontinued: 2023-08-17T19:05:45.951Z */
294
295
  discontinueDate?: Date;
295
296
  }
297
+ interface BaseVersion extends ConstructorVersion {
298
+ state: 'active' | 'deprecated' | 'discontinued';
299
+ }
300
+ export declare class Version implements BaseVersion {
301
+ major: number;
302
+ minor?: number;
303
+ range: string;
304
+ runtime: string;
305
+ discontinueDate?: Date;
306
+ constructor(version: ConstructorVersion);
307
+ get state(): "active" | "deprecated" | "discontinued";
308
+ get formattedDate(): string | undefined;
309
+ }
310
+ export declare class NodeVersion extends Version {
311
+ }
296
312
  export interface Builder {
297
313
  use: string;
298
314
  src?: string;
package/dist/types.js CHANGED
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -13,4 +17,35 @@ var __copyProps = (to, from, except, desc) => {
13
17
  };
14
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
19
  var types_exports = {};
20
+ __export(types_exports, {
21
+ NodeVersion: () => NodeVersion,
22
+ Version: () => Version
23
+ });
16
24
  module.exports = __toCommonJS(types_exports);
25
+ class Version {
26
+ constructor(version) {
27
+ this.major = version.major;
28
+ this.minor = version.minor;
29
+ this.range = version.range;
30
+ this.runtime = version.runtime;
31
+ this.discontinueDate = version.discontinueDate;
32
+ }
33
+ get state() {
34
+ if (this.discontinueDate && this.discontinueDate.getTime() <= Date.now()) {
35
+ return "discontinued";
36
+ } else if (this.discontinueDate) {
37
+ return "deprecated";
38
+ }
39
+ return "active";
40
+ }
41
+ get formattedDate() {
42
+ return this.discontinueDate && this.discontinueDate.toISOString().split("T")[0];
43
+ }
44
+ }
45
+ class NodeVersion extends Version {
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ NodeVersion,
50
+ Version
51
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "9.0.1",
3
+ "version": "9.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",