Skip to content

Commit e295db5

Browse files
feat: Add Node 24 support to Vercel adapter (#14982)
* feat: Add Node 24 support to Vercel adapter * changeset * tweak error message
1 parent f1176ea commit e295db5

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

.changeset/giant-sites-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-vercel': minor
3+
---
4+
5+
feat: Node 24 support

packages/adapter-vercel/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function plugin(config?: Config): Adapter;
66

77
export interface ServerlessConfig {
88
/**
9-
* Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
9+
* Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs22.x'`, `'nodejs24.x'` etc).
1010
* @default Same as the build environment
1111
*/
1212
runtime?: Exclude<RuntimeConfigKey, 'edge'>;
@@ -78,7 +78,7 @@ type ImagesConfig = {
7878
/** @deprecated */
7979
export interface EdgeConfig {
8080
/**
81-
* Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
81+
* Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs22.x'`, `'nodejs24.x'` etc).
8282
*/
8383
runtime?: 'edge';
8484
/**

packages/adapter-vercel/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ const plugin = function (defaults = {}) {
285285

286286
if (runtime === 'edge') {
287287
throw new Error(
288-
`${directory}: Routes using \`isr\` must use a Node.js or Bun runtime (for example 'nodejs22.x' or 'experimental_bun1.x')`
288+
`${directory}: Routes using \`isr\` must use a Node.js or Bun runtime (for example 'nodejs24.x' or 'experimental_bun1.x')`
289289
);
290290
}
291291

packages/adapter-vercel/utils.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,31 @@ export function resolve_runtime(default_key, override_key) {
120120
return key;
121121
}
122122

123+
const valid_node_versions = [20, 22, 24];
124+
123125
/** @returns {RuntimeKey} */
124126
function get_default_runtime() {
125127
// TODO may someday need to auto-detect Bun, but this will be complicated because you may want to run your build
126128
// with Bun but not have your serverless runtime be in Bun. Vercel will likely have to attach something to `globalThis` or similar
127129
// to tell us what the bun configuration is.
128130
const major = Number(process.version.slice(1).split('.')[0]);
129131

130-
if (major !== 20 && major !== 22) {
132+
if (!valid_node_versions.includes(major)) {
131133
throw new Error(
132-
`Unsupported Node.js version: ${process.version}. Please use Node 20 or 22 to build your project, or explicitly specify a runtime in your adapter configuration.`
134+
`Unsupported Node.js version: ${process.version}. Please use Node ${valid_node_versions.slice(0, -1).join(', ')} or ${valid_node_versions.at(-1)} to build your project, or explicitly specify a runtime in your adapter configuration.`
133135
);
134136
}
135137

136-
return `nodejs${major}.x`;
138+
return `nodejs${/** @type {20 | 22 | 24} */ (major)}.x`;
137139
}
138140

139-
const valid_runtimes = /** @type {const} */ (['nodejs20.x', 'nodejs22.x', 'bun1.x', 'edge']);
141+
const valid_runtimes = /** @type {const} */ ([
142+
'nodejs20.x',
143+
'nodejs22.x',
144+
'nodejs24.x',
145+
'bun1.x',
146+
'edge'
147+
]);
140148

141149
/**
142150
* @param {string} key

0 commit comments

Comments
 (0)