Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change default node version to v22 #5958

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const versionMap = {
16: 'node16',
18: 'node18',
20: 'node20',
22: 'node22',
} as const

type VersionValues = (typeof versionMap)[keyof typeof versionMap]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getNodeRuntimeForV2 = (input: string | undefined): string | undefin
const version = parseVersion(input)

// If version was unable to be parsed or if the version is older than Node.js 18
// we return the current default Node.js version (which was Node.js 18 while writing this).
// we return the current default Node.js version (which was Node.js 22 while writing this).
// Here we do not want BB/FO to decide on the version, because they value AWS_LAMBDA_JS_RUNTIME, which
// might be set to an too old version
if (!version || version < minimumV2Version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface NodeVersionSupport {
}

// Must match the default version used in Bitballoon.
export const DEFAULT_NODE_VERSION = 18
export const DEFAULT_NODE_VERSION = 22

export const getNodeVersion = (configVersion?: string) => parseVersion(configVersion) ?? DEFAULT_NODE_VERSION

Expand Down
4 changes: 2 additions & 2 deletions packages/zip-it-and-ship-it/tests/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ describe('esbuild', () => {
await zipFixture('node-module-optional-catch-binding', {
opts: {
archiveFormat: ARCHIVE_FORMAT.NONE,
config: { '*': { nodeBundler: NODE_BUNDLER.ESBUILD, nodeVersion: '18.x' } },
config: { '*': { nodeBundler: NODE_BUNDLER.ESBUILD, nodeVersion: '22.x' } },
},
})

expect(build).toHaveBeenCalledWith(expect.objectContaining({ target: ['node18'] }))
expect(build).toHaveBeenCalledWith(expect.objectContaining({ target: ['node22'] }))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('getNodeRuntime', () => {
['nodejs16.x', 'nodejs16.x'],
['nodejs18.x', 'nodejs18.x'],
['nodejs20.x', 'nodejs20.x'],
['nodejs22.x', 'nodejs22.x'],
['14.x', 'nodejs14.x'],
['v16.x', 'nodejs16.x'],
['18.0.0', 'nodejs18.x'],
Expand All @@ -21,17 +22,17 @@ describe('getNodeRuntime', () => {

describe('getNodeRuntimeForV2', () => {
test.each([
['nodejs12.x', 'nodejs18.x'],
['nodejs16.x', 'nodejs18.x'],
['nodejs12.x', 'nodejs22.x'],
['nodejs16.x', 'nodejs22.x'],
['nodejs18.x', 'nodejs18.x'],
['nodejs20.x', 'nodejs20.x'],
['14.x', 'nodejs18.x'],
['v16.x', 'nodejs18.x'],
['14.x', 'nodejs22.x'],
['v16.x', 'nodejs22.x'],
['18.0.0', 'nodejs18.x'],
['20.0.0', 'nodejs20.x'],
['v14.2.0', 'nodejs18.x'],
['14.1', 'nodejs18.x'],
[':shrug:', 'nodejs18.x'],
['v14.2.0', 'nodejs22.x'],
['14.1', 'nodejs22.x'],
[':shrug:', 'nodejs22.x'],
['99.0.0', undefined],
])('handles `%s`', (input, expected) => {
expect(getNodeRuntimeForV2(input)).toBe(expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('getNodeVersion', () => {
['nodejs16.x', 16],
['nodejs18.x', 18],
['nodejs20.x', 20],
['nodejs22.x', 22],
['18.x', 18],
['node16', 16],
['14.1.1', 14],
Expand All @@ -29,6 +30,7 @@ describe('parseVersion', () => {
['nodejs12.x', 12],
['nodejs18.x', 18],
['nodejs20.x', 20],
['nodejs22.x', 22],
['18.x', 18],
['node14', 14],
['14.1.1', 14],
Expand Down
4 changes: 2 additions & 2 deletions packages/zip-it-and-ship-it/tests/v2api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => {
},
})

expect(files[0].runtimeVersion).toBe('nodejs18.x')
expect(files[0].runtimeVersion).toBe('nodejs22.x')
})

test('Returns Node.js 18 if invalid version is set', async () => {
Expand All @@ -357,7 +357,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => {
},
})

expect(files[0].runtimeVersion).toBe('nodejs18.x')
expect(files[0].runtimeVersion).toBe('nodejs22.x')
})

test('Returns no Node.js version if version is newer than 18 but not a valid runtime', async () => {
Expand Down
Loading