From dec245a02f80b290698fd99d44851df977f64bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Jes=C3=BAs?= Date: Wed, 13 Jul 2022 17:12:32 +0200 Subject: [PATCH] feat: update default nodejs version to 16 (#1138) * Update default nodejs version to 16 * Added missing test case for getting node14 version * chore: fixed failing unit test * chore: trigger checks --- README.md | 4 ++-- src/runtimes/node/bundlers/esbuild/bundler_target.ts | 1 + src/runtimes/node/utils/node_version.ts | 2 +- tests/unit/runtimes/node/utils/node_version.js | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc8a24bad..e8d71fa4c 100644 --- a/README.md +++ b/README.md @@ -441,9 +441,9 @@ need to be the same as the one used when installing those native modules. In Netlify, this is done by ensuring that the following Node.js versions are the same: -- Build-time Node.js version: this defaults to Node `12`, but can be +- Build-time Node.js version: this defaults to Node `16`, but can be [overridden with a `.nvmrc` or `NODE_VERSION` environment variable](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript). -- Function runtime Node.js version: this defaults to `nodejs12.x` but can be +- Function runtime Node.js version: this defaults to `nodejs16.x` but can be [overridden with a `AWS_LAMBDA_JS_RUNTIME` environment variable](https://docs.netlify.com/functions/build-with-javascript/#runtime-settings). Note that this problem might not apply for Node.js native modules using the [N-API](https://nodejs.org/api/n-api.html). diff --git a/src/runtimes/node/bundlers/esbuild/bundler_target.ts b/src/runtimes/node/bundlers/esbuild/bundler_target.ts index aa4a7cd53..d1ad11723 100644 --- a/src/runtimes/node/bundlers/esbuild/bundler_target.ts +++ b/src/runtimes/node/bundlers/esbuild/bundler_target.ts @@ -8,6 +8,7 @@ const versionMap = { '10.x': 'node10', '12.x': 'node12', '14.x': 'node14', + '16.x': 'node16', } as const type VersionKeys = keyof typeof versionMap diff --git a/src/runtimes/node/utils/node_version.ts b/src/runtimes/node/utils/node_version.ts index 1071ad46b..13e340906 100644 --- a/src/runtimes/node/utils/node_version.ts +++ b/src/runtimes/node/utils/node_version.ts @@ -7,7 +7,7 @@ export interface NodeVersionSupport { } // Must match the default version used in Bitballoon. -export const DEFAULT_NODE_VERSION = 14 +export const DEFAULT_NODE_VERSION = 16 const VERSION_REGEX = /(nodejs)?(\d+)\.x/ export const getNodeVersion = (configVersion?: string) => parseVersion(configVersion) ?? DEFAULT_NODE_VERSION diff --git a/tests/unit/runtimes/node/utils/node_version.js b/tests/unit/runtimes/node/utils/node_version.js index df409ed0d..459834f45 100644 --- a/tests/unit/runtimes/node/utils/node_version.js +++ b/tests/unit/runtimes/node/utils/node_version.js @@ -7,11 +7,12 @@ const { } = require('../../../../../dist/runtimes/node/utils/node_version.js') test('getNodeVersion', (t) => { + t.is(getNodeVersion('nodejs14.x'), 14) t.is(getNodeVersion('nodejs12.x'), 12) t.is(getNodeVersion('nodejs8.x'), 8) t.is(getNodeVersion('12.x'), 12) t.is(getNodeVersion('8.x'), 8) - t.is(getNodeVersion('node14'), DEFAULT_NODE_VERSION) + t.is(getNodeVersion('node16'), DEFAULT_NODE_VERSION) t.is(getNodeVersion(':shrug:'), DEFAULT_NODE_VERSION) })