@sveltejs/adapter-vercel 3.1.0 → 4.0.1
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.
- package/files/serverless.js +1 -9
- package/index.d.ts +26 -0
- package/index.js +11 -4
- package/package.json +9 -8
package/files/serverless.js
CHANGED
|
@@ -32,15 +32,7 @@ export default async (req, res) => {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
let request;
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
request = await getRequest({ base: `https://${req.headers.host}`, request: req });
|
|
40
|
-
} catch (err) {
|
|
41
|
-
res.statusCode = /** @type {any} */ (err).status || 400;
|
|
42
|
-
return res.end('Invalid request body');
|
|
43
|
-
}
|
|
35
|
+
const request = await getRequest({ base: `https://${req.headers.host}`, request: req });
|
|
44
36
|
|
|
45
37
|
setResponse(
|
|
46
38
|
res,
|
package/index.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ export interface ServerlessConfig {
|
|
|
28
28
|
* If `true`, this route will always be deployed as its own separate function
|
|
29
29
|
*/
|
|
30
30
|
split?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* https://vercel.com/docs/build-output-api/v3/configuration#images
|
|
34
|
+
*/
|
|
35
|
+
images?: ImagesConfig;
|
|
36
|
+
|
|
31
37
|
/**
|
|
32
38
|
* [Incremental Static Regeneration](https://vercel.com/docs/concepts/incremental-static-regeneration/overview) configuration.
|
|
33
39
|
* Serverless only.
|
|
@@ -53,6 +59,26 @@ export interface ServerlessConfig {
|
|
|
53
59
|
| false;
|
|
54
60
|
}
|
|
55
61
|
|
|
62
|
+
type ImageFormat = 'image/avif' | 'image/webp';
|
|
63
|
+
|
|
64
|
+
type RemotePattern = {
|
|
65
|
+
protocol?: 'http' | 'https';
|
|
66
|
+
hostname: string;
|
|
67
|
+
port?: string;
|
|
68
|
+
pathname?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type ImagesConfig = {
|
|
72
|
+
sizes: number[];
|
|
73
|
+
domains: string[];
|
|
74
|
+
remotePatterns?: RemotePattern[];
|
|
75
|
+
minimumCacheTTL?: number; // seconds
|
|
76
|
+
formats?: ImageFormat[];
|
|
77
|
+
dangerouslyAllowSVG?: boolean;
|
|
78
|
+
contentSecurityPolicy?: string;
|
|
79
|
+
contentDispositionType?: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
56
82
|
export interface EdgeConfig {
|
|
57
83
|
/**
|
|
58
84
|
* 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).
|
package/index.js
CHANGED
|
@@ -54,7 +54,7 @@ const plugin = function (defaults = {}) {
|
|
|
54
54
|
functions: `${dir}/functions`
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
const static_config = static_vercel_config(builder);
|
|
57
|
+
const static_config = static_vercel_config(builder, defaults);
|
|
58
58
|
|
|
59
59
|
builder.log.minor('Generating serverless function...');
|
|
60
60
|
|
|
@@ -367,14 +367,20 @@ function write(file, data) {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
// This function is duplicated in adapter-static
|
|
370
|
-
/**
|
|
371
|
-
|
|
370
|
+
/**
|
|
371
|
+
* @param {import('@sveltejs/kit').Builder} builder
|
|
372
|
+
* @param {import('.').Config} config
|
|
373
|
+
*/
|
|
374
|
+
function static_vercel_config(builder, config) {
|
|
372
375
|
/** @type {any[]} */
|
|
373
376
|
const prerendered_redirects = [];
|
|
374
377
|
|
|
375
378
|
/** @type {Record<string, { path: string }>} */
|
|
376
379
|
const overrides = {};
|
|
377
380
|
|
|
381
|
+
/** @type {import('./index').ImagesConfig} */
|
|
382
|
+
const images = config.images;
|
|
383
|
+
|
|
378
384
|
for (const [src, redirect] of builder.prerendered.redirects) {
|
|
379
385
|
prerendered_redirects.push({
|
|
380
386
|
src,
|
|
@@ -420,7 +426,8 @@ function static_vercel_config(builder) {
|
|
|
420
426
|
handle: 'filesystem'
|
|
421
427
|
}
|
|
422
428
|
],
|
|
423
|
-
overrides
|
|
429
|
+
overrides,
|
|
430
|
+
images
|
|
424
431
|
};
|
|
425
432
|
}
|
|
426
433
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-vercel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A SvelteKit adapter that creates a Vercel app",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,17 +25,18 @@
|
|
|
25
25
|
"index.d.ts"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vercel/nft": "^0.
|
|
29
|
-
"esbuild": "^0.
|
|
28
|
+
"@vercel/nft": "^0.26.0",
|
|
29
|
+
"esbuild": "^0.19.9"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
32
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
|
33
|
+
"@types/node": "^18.19.3",
|
|
34
|
+
"typescript": "^5.3.3",
|
|
35
|
+
"vitest": "^1.0.4",
|
|
36
|
+
"@sveltejs/kit": "^2.0.0"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
"@sveltejs/kit": "^
|
|
39
|
+
"@sveltejs/kit": "^2.0.0"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"lint": "prettier --check .",
|