Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

feat: update default nodejs version to 16 #1138

Merged
merged 5 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions src/runtimes/node/bundlers/esbuild/bundler_target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/runtimes/node/utils/node_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/runtimes/node/utils/node_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
biruwon marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@danez danez Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you jsut changed the number, but it was actually wrong before. node1X is not a valid specifier. It needs to be either nodejs16.x or 16.x. It works though because in case the input cannot be parse it defaults to the default nodejs version. Hence the next line in this file with :shrug:

Suggested change
t.is(getNodeVersion('node16'), DEFAULT_NODE_VERSION)
t.is(getNodeVersion('16.x'), DEFAULT_NODE_VERSION)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this unit test check that something like "nodeVersion" is invalid so it uses the default one. Not sure if we should change it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I see.

t.is(getNodeVersion(':shrug:'), DEFAULT_NODE_VERSION)
})

Expand Down