Skip to content

Commit

Permalink
feat: update default nodejs version to 16 (#1138)
Browse files Browse the repository at this point in the history
* Update default nodejs version to 16

* Added missing test case for getting node14 version

* chore: fixed failing unit test

* chore: trigger checks
  • Loading branch information
biruwon committed Jul 13, 2022
1 parent 20fe86c commit dec245a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
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
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
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
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)
t.is(getNodeVersion(':shrug:'), DEFAULT_NODE_VERSION)
})

Expand Down

1 comment on commit dec245a

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

⏱ Benchmark results

largeDepsEsbuild: 6.2s

largeDepsZisi: 45.7s

Please sign in to comment.