Skip to content

Commit 9ad7baf

Browse files
authored
chore: deprecate runtime config (#14253)
1 parent 9dd666c commit 9ad7baf

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

.changeset/kind-snails-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-vercel': patch
3+
---
4+
5+
chore: deprecate `runtime` config

documentation/docs/25-build-and-deploy/90-adapter-vercel.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,20 @@ export default config;
3030

3131
To control how your routes are deployed to Vercel as functions, you can specify deployment configuration, either through the option shown above or with [`export const config`](page-options#config) inside `+server.js`, `+page(.server).js` and `+layout(.server).js` files.
3232

33-
For example you could deploy some parts of your app as [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions)...
33+
For example you could deploy one specific route as an individual serverless function, separate from the rest of your app:
3434

3535
```js
3636
/// file: about/+page.js
3737
/** @type {import('@sveltejs/adapter-vercel').Config} */
3838
export const config = {
39-
runtime: 'edge'
40-
};
41-
```
42-
43-
...and others as [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (note that by specifying `config` inside a layout, it applies to all child pages):
44-
45-
```js
46-
/// file: admin/+layout.js
47-
/** @type {import('@sveltejs/adapter-vercel').Config} */
48-
export const config = {
49-
runtime: 'nodejs22.x'
39+
split: true
5040
};
5141
```
5242

5343
The following options apply to all functions:
5444

5545
- `runtime`: `'edge'`, `'nodejs18.x'`, `'nodejs20.x'` or `'nodejs22.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
46+
> [!NOTE] This option is deprecated and will be removed in a future version, at which point all your functions will use whichever Node version is specified in the project configuration on Vercel
5647
- `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
5748
- `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
5849

@@ -64,6 +55,8 @@ And the following option apply to serverless functions:
6455
- `maxDuration`: [maximum execution duration](https://vercel.com/docs/functions/runtimes#max-duration) of the function. Defaults to `10` seconds for Hobby accounts, `15` for Pro and `900` for Enterprise
6556
- `isr`: configuration Incremental Static Regeneration, described below
6657

58+
Configuration set in a layout applies to all the routes beneath that layout, unless overridden at a more granular level.
59+
6760
If your functions need to access data in a specific region, it's recommended that they be deployed in the same region (or close to it) for optimal performance.
6861

6962
## Image Optimization
@@ -95,7 +88,7 @@ export default config;
9588

9689
Vercel supports [Incremental Static Regeneration](https://vercel.com/docs/incremental-static-regeneration) (ISR), which provides the performance and cost advantages of prerendered content with the flexibility of dynamically rendered content.
9790

98-
> Use ISR only on routes where every visitor should see the same content (much like when you prerender). If there's anything user-specific happening (like session cookies), they should happen on the client via JavaScript only to not leak sensitive information across visits
91+
> [!NOTE] Use ISR only on routes where every visitor should see the same content (much like when you prerender). If there's anything user-specific happening (like session cookies), they should happen on the client via JavaScript only to not leak sensitive information across visits
9992
10093
To add ISR to a route, include the `isr` property in your `config` object:
10194

@@ -112,7 +105,7 @@ export const config = {
112105
};
113106
```
114107

115-
> Using ISR on a route with `export const prerender = true` will have no effect, since the route is prerendered at build time
108+
> [!NOTE] Using ISR on a route with `export const prerender = true` will have no effect, since the route is prerendered at build time
116109
117110
The `expiration` property is required; all others are optional. The properties are discussed in more detail below.
118111

@@ -144,7 +137,7 @@ vercel env pull .env.development.local
144137

145138
A list of valid query parameters that contribute to the cache key. Other parameters (such as utm tracking codes) will be ignored, ensuring that they do not result in content being re-generated unnecessarily. By default, query parameters are ignored.
146139

147-
> Pages that are [prerendered](page-options#prerender) will ignore ISR configuration.
140+
> [!NOTE] Pages that are [prerendered](page-options#prerender) will ignore ISR configuration.
148141
149142
## Environment variables
150143

packages/adapter-vercel/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface ServerlessConfig {
77
/**
88
* 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).
99
* @default Same as the build environment
10+
* @deprecated
1011
*/
1112
runtime?: `nodejs${number}.x`;
1213
/**
@@ -74,6 +75,7 @@ type ImagesConfig = {
7475
contentDispositionType?: string;
7576
};
7677

78+
/** @deprecated */
7779
export interface EdgeConfig {
7880
/**
7981
* 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).

packages/adapter-vercel/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,21 @@ const plugin = function (defaults = {}) {
131131
}
132132
}
133133

134+
let warned = false;
135+
134136
/**
135137
* @param {string} name
136138
* @param {import('./index.js').EdgeConfig} config
137139
* @param {import('@sveltejs/kit').RouteDefinition<import('./index.js').EdgeConfig>[]} routes
138140
*/
139141
async function generate_edge_function(name, config, routes) {
142+
if (!warned) {
143+
warned = true;
144+
builder.log.warn(
145+
`The \`runtime: 'edge'\` option is deprecated, and will be removed in a future version of adapter-vercel`
146+
);
147+
}
148+
140149
const tmp = builder.getBuildDirectory(`vercel-tmp/${name}`);
141150
const relativePath = path.posix.relative(tmp, builder.getServerDirectory());
142151

0 commit comments

Comments
 (0)