@vercel/build-utils 5.5.4 → 5.5.6

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.
@@ -34,6 +34,6 @@ export declare class EdgeFunction {
34
34
  path: string;
35
35
  }[];
36
36
  /** The regions where the edge function will be executed on */
37
- regions?: 'auto' | string[] | 'all' | 'default';
37
+ regions?: string | string[];
38
38
  constructor(params: Omit<EdgeFunction, 'type'>);
39
39
  }
@@ -3,6 +3,10 @@ export declare function getLatestNodeVersion(): {
3
3
  readonly major: 16;
4
4
  readonly range: "16.x";
5
5
  readonly runtime: "nodejs16.x";
6
+ } | {
7
+ readonly major: 18;
8
+ readonly range: "18.x";
9
+ readonly runtime: "nodejs18.x";
6
10
  };
7
11
  export declare function getDiscontinuedNodeVersions(): NodeVersion[];
8
12
  export declare function getSupportedNodeVersion(engineRange: string | undefined, isAuto?: boolean): Promise<NodeVersion>;
@@ -7,28 +7,37 @@ exports.getSupportedNodeVersion = exports.getDiscontinuedNodeVersions = exports.
7
7
  const semver_1 = require("semver");
8
8
  const errors_1 = require("../errors");
9
9
  const debug_1 = __importDefault(require("../debug"));
10
- const allOptions = [
11
- { major: 16, range: '16.x', runtime: 'nodejs16.x' },
12
- { major: 14, range: '14.x', runtime: 'nodejs14.x' },
13
- {
14
- major: 12,
15
- range: '12.x',
16
- runtime: 'nodejs12.x',
17
- discontinueDate: new Date('2022-10-03'),
18
- },
19
- {
20
- major: 10,
21
- range: '10.x',
22
- runtime: 'nodejs10.x',
23
- discontinueDate: new Date('2021-04-20'),
24
- },
25
- {
26
- major: 8,
27
- range: '8.10.x',
28
- runtime: 'nodejs8.10',
29
- discontinueDate: new Date('2020-01-06'),
30
- },
31
- ];
10
+ function getOptions() {
11
+ const options = [
12
+ { major: 16, range: '16.x', runtime: 'nodejs16.x' },
13
+ { major: 14, range: '14.x', runtime: 'nodejs14.x' },
14
+ {
15
+ major: 12,
16
+ range: '12.x',
17
+ runtime: 'nodejs12.x',
18
+ discontinueDate: new Date('2022-10-03'),
19
+ },
20
+ {
21
+ major: 10,
22
+ range: '10.x',
23
+ runtime: 'nodejs10.x',
24
+ discontinueDate: new Date('2021-04-20'),
25
+ },
26
+ {
27
+ major: 8,
28
+ range: '8.10.x',
29
+ runtime: 'nodejs8.10',
30
+ discontinueDate: new Date('2020-01-06'),
31
+ },
32
+ ];
33
+ if (process.env.VERCEL_ALLOW_NODEJS18 === '1') {
34
+ return [
35
+ { major: 18, range: '18.x', runtime: 'nodejs18.x' },
36
+ ...options,
37
+ ];
38
+ }
39
+ return options;
40
+ }
32
41
  function getHint(isAuto = false) {
33
42
  const { major, range } = getLatestNodeVersion();
34
43
  return isAuto
@@ -36,18 +45,18 @@ function getHint(isAuto = false) {
36
45
  : `Please set "engines": { "node": "${range}" } in your \`package.json\` file to use Node.js ${major}.`;
37
46
  }
38
47
  function getLatestNodeVersion() {
39
- return allOptions[0];
48
+ return getOptions()[0];
40
49
  }
41
50
  exports.getLatestNodeVersion = getLatestNodeVersion;
42
51
  function getDiscontinuedNodeVersions() {
43
- return allOptions.filter(isDiscontinued);
52
+ return getOptions().filter(isDiscontinued);
44
53
  }
45
54
  exports.getDiscontinuedNodeVersions = getDiscontinuedNodeVersions;
46
55
  async function getSupportedNodeVersion(engineRange, isAuto = false) {
47
56
  let selection = getLatestNodeVersion();
48
57
  if (engineRange) {
49
58
  const found = semver_1.validRange(engineRange) &&
50
- allOptions.some(o => {
59
+ getOptions().some(o => {
51
60
  // the array is already in order so return the first
52
61
  // match which will be the newest version of node
53
62
  selection = o;
@@ -147,27 +147,22 @@ function getSpawnOptions(meta, nodeVersion) {
147
147
  exports.getSpawnOptions = getSpawnOptions;
148
148
  async function getNodeVersion(destPath, _nodeVersion, config = {}, meta = {}) {
149
149
  const latest = node_version_1.getLatestNodeVersion();
150
- if (meta && meta.isDev) {
150
+ if (meta.isDev) {
151
151
  // Use the system-installed version of `node` in PATH for `vercel dev`
152
152
  return { ...latest, runtime: 'nodejs' };
153
153
  }
154
154
  const { packageJson } = await scanParentDirs(destPath, true);
155
155
  let { nodeVersion } = config;
156
156
  let isAuto = true;
157
- if (packageJson && packageJson.engines && packageJson.engines.node) {
157
+ if (packageJson?.engines?.node) {
158
158
  const { node } = packageJson.engines;
159
- if (nodeVersion &&
160
- semver_1.validRange(node) &&
161
- !semver_1.intersects(nodeVersion, node) &&
162
- !meta.isDev) {
159
+ if (nodeVersion && semver_1.validRange(node) && !semver_1.intersects(nodeVersion, node)) {
163
160
  console.warn(`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${nodeVersion}") will not apply. Learn More: http://vercel.link/node-version`);
164
161
  }
165
- else if (semver_1.coerce(node)?.raw === node && !meta.isDev) {
162
+ else if (semver_1.coerce(node)?.raw === node) {
166
163
  console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version`);
167
164
  }
168
- else if (semver_1.validRange(node) &&
169
- semver_1.intersects(`${latest.major + 1}.x`, node) &&
170
- !meta.isDev) {
165
+ else if (semver_1.validRange(node) && semver_1.intersects(`${latest.major + 1}.x`, node)) {
171
166
  console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version`);
172
167
  }
173
168
  nodeVersion = node;