Skip to content

Commit

Permalink
feat: change default node version to v22
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork committed Dec 20, 2024
1 parent 3757b1d commit 82a771e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
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

0 comments on commit 82a771e

Please sign in to comment.