Skip to content

Commit

Permalink
fix: update adapter-vercel supported node versions (#11328)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
  • Loading branch information
Rich-Harris and dummdidumm committed Dec 15, 2023
1 parent 134b2af commit e7e3c84
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-yaks-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-vercel': patch
---

fix: remove broken node 16 support
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ If the `netlify.toml` file or the `build.publish` value is missing, a default va

### Node version

New projects will use Node 16 by default. However, if you're upgrading a project you created a while ago it may be stuck on an older version. See [the Netlify docs](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) for details on manually specifying Node 16 or newer.
New projects will use the current Node LTS version by default. However, if you're upgrading a project you created a while ago it may be stuck on an older version. See [the Netlify docs](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) for details on manually specifying a current Node version.

## Netlify Edge Functions

Expand Down
4 changes: 2 additions & 2 deletions documentation/docs/25-build-and-deploy/90-adapter-vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const config = {

The following options apply to all functions:

- `runtime`: `'edge'`, `'nodejs16.x'` or `'nodejs18.x'`. By default, the adapter will select `'nodejs16.x'` or `'nodejs18.x'` depending on the Node version your project is configured to use on the Vercel dashboard
- `runtime`: `'edge'`, `'nodejs18.x'` or `'nodejs20.x'`. By default, the adapter will select the `'nodejs<version>.x'` corresponding to the Node version your project is configured to use on the Vercel dashboard
- `regions`: an array of [edge network regions](https://vercel.com/docs/concepts/edge-network/regions) (defaulting to `["iad1"]` for serverless functions) or `'all'` if `runtime` is `edge` (its default). Note that multiple regions for serverless functions are only supported on Enterprise plans
- `split`: if `true`, causes a route to be deployed as an individual function. If `split` is set to `true` at the adapter level, all routes will be deployed as individual functions

Expand Down Expand Up @@ -151,7 +151,7 @@ If you have Vercel functions contained in the `api` directory at the project's r

### Node version

Projects created before a certain date will default to using Node 14, while SvelteKit requires Node 16 or later. You can [change the Node version in your project settings](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version).
Projects created before a certain date may default to using an older Node version than what SvelteKit currently requires. You can [change the Node version in your project settings](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js#node.js-version).

## Troubleshooting

Expand Down
7 changes: 3 additions & 4 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ const DEFAULT_FUNCTION_NAME = 'fn';

const get_default_runtime = () => {
const major = process.version.slice(1).split('.')[0];
if (major === '16') return 'nodejs16.x';
if (major === '18') return 'nodejs18.x';
if (major === '20') return 'nodejs20.x';

throw new Error(
`Unsupported Node.js version: ${process.version}. Please use Node 16, Node 18 or Node 20 to build your project, or explicitly specify a runtime in your adapter configuration.`
`Unsupported Node.js version: ${process.version}. Please use Node 18 or Node 20 to build your project, or explicitly specify a runtime in your adapter configuration.`
);
};

Expand Down Expand Up @@ -164,9 +163,9 @@ const plugin = function (defaults = {}) {
}

const node_runtime = /nodejs([0-9]+)\.x/.exec(runtime);
if (runtime !== 'edge' && (!node_runtime || node_runtime[1] < 16)) {
if (runtime !== 'edge' && (!node_runtime || node_runtime[1] < 18)) {
throw new Error(
`Invalid runtime '${runtime}' for route ${route.id}. Valid runtimes are 'edge' and 'nodejs16.x' or higher ` +
`Invalid runtime '${runtime}' for route ${route.id}. Valid runtimes are 'edge' and 'nodejs18.x' or higher ` +
'(see the Node.js Version section in your Vercel project settings for info on the currently supported versions).'
);
}
Expand Down

0 comments on commit e7e3c84

Please sign in to comment.