@sveltejs/adapter-vercel 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +3 -3
  2. package/index.js +8 -9
  3. package/package.json +5 -5
package/index.d.ts CHANGED
@@ -5,10 +5,10 @@ export default function plugin(config?: Config): Adapter;
5
5
 
6
6
  export interface ServerlessConfig {
7
7
  /**
8
- * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions)
8
+ * 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
9
  * @default 'nodejs18.x'
10
10
  */
11
- runtime?: 'nodejs16.x' | 'nodejs18.x';
11
+ runtime?: `nodejs${number}.x`;
12
12
  /**
13
13
  * To which regions to deploy the app. A list of regions.
14
14
  * More info: https://vercel.com/docs/concepts/edge-network/regions
@@ -55,7 +55,7 @@ export interface ServerlessConfig {
55
55
 
56
56
  export interface EdgeConfig {
57
57
  /**
58
- * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions)
58
+ * 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).
59
59
  */
60
60
  runtime?: 'edge';
61
61
  /**
package/index.js CHANGED
@@ -5,17 +5,16 @@ import { nodeFileTrace } from '@vercel/nft';
5
5
  import esbuild from 'esbuild';
6
6
  import { get_pathname } from './utils.js';
7
7
 
8
- const VALID_RUNTIMES = ['edge', 'nodejs16.x', 'nodejs18.x'];
9
-
10
8
  const DEFAULT_FUNCTION_NAME = 'fn';
11
9
 
12
10
  const get_default_runtime = () => {
13
11
  const major = process.version.slice(1).split('.')[0];
14
12
  if (major === '16') return 'nodejs16.x';
15
13
  if (major === '18') return 'nodejs18.x';
14
+ if (major === '20') return 'nodejs20.x';
16
15
 
17
16
  throw new Error(
18
- `Unsupported Node.js version: ${process.version}. Please use Node 16 or Node 18 to build your project, or explicitly specify a runtime in your adapter configuration.`
17
+ `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.`
19
18
  );
20
19
  };
21
20
 
@@ -164,20 +163,20 @@ const plugin = function (defaults = {}) {
164
163
  continue;
165
164
  }
166
165
 
167
- if (runtime && !VALID_RUNTIMES.includes(runtime)) {
166
+ const node_runtime = /nodejs([0-9]+)\.x/.exec(runtime);
167
+ if (runtime !== 'edge' && (!node_runtime || node_runtime[1] < 16)) {
168
168
  throw new Error(
169
- `Invalid runtime '${runtime}' for route ${
170
- route.id
171
- }. Valid runtimes are ${VALID_RUNTIMES.join(', ')}`
169
+ `Invalid runtime '${runtime}' for route ${route.id}. Valid runtimes are 'edge' and 'nodejs16.x' or higher ` +
170
+ '(see the Node.js Version section in your Vercel project settings for info on the currently supported versions).'
172
171
  );
173
172
  }
174
173
 
175
174
  if (config.isr) {
176
175
  const directory = path.relative('.', builder.config.kit.files.routes + route.id);
177
176
 
178
- if (runtime !== 'nodejs16.x' && runtime !== 'nodejs18.x') {
177
+ if (!runtime.startsWith('nodejs')) {
179
178
  throw new Error(
180
- `${directory}: Routes using \`isr\` must use either \`runtime: 'nodejs16.x'\` or \`runtime: 'nodejs18.x'\``
179
+ `${directory}: Routes using \`isr\` must use a Node.js runtime (for example 'nodejs20.x')`
181
180
  );
182
181
  }
183
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-vercel",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "A SvelteKit adapter that creates a Vercel app",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,20 +25,20 @@
25
25
  "index.d.ts"
26
26
  ],
27
27
  "dependencies": {
28
- "@vercel/nft": "^0.22.6",
28
+ "@vercel/nft": "^0.24.0",
29
29
  "esbuild": "^0.18.11"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^16.18.6",
33
33
  "typescript": "^4.9.4",
34
- "vitest": "^0.32.2",
35
- "@sveltejs/kit": "^1.22.2"
34
+ "vitest": "^0.34.5",
35
+ "@sveltejs/kit": "^1.27.6"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@sveltejs/kit": "^1.5.0"
39
39
  },
40
40
  "scripts": {
41
- "lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
41
+ "lint": "prettier --check .",
42
42
  "format": "pnpm lint --write",
43
43
  "check": "tsc",
44
44
  "test": "vitest run"