@sveltejs/adapter-vercel 5.1.1 → 5.3.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.
- package/files/edge.js +1 -0
- package/index.js +71 -21
- package/package.json +4 -4
package/files/edge.js
CHANGED
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import { nodeFileTrace } from '@vercel/nft';
|
|
5
5
|
import esbuild from 'esbuild';
|
|
6
6
|
import { get_pathname, pattern_to_src } from './utils.js';
|
|
7
|
+
import { VERSION } from '@sveltejs/kit';
|
|
7
8
|
|
|
8
9
|
const name = '@sveltejs/adapter-vercel';
|
|
9
10
|
const DEFAULT_FUNCTION_NAME = 'fn';
|
|
@@ -57,7 +58,12 @@ const plugin = function (defaults = {}) {
|
|
|
57
58
|
functions: `${dir}/functions`
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
builder.log.minor('Copying assets...');
|
|
62
|
+
|
|
63
|
+
builder.writeClient(dirs.static);
|
|
64
|
+
builder.writePrerendered(dirs.static);
|
|
65
|
+
|
|
66
|
+
const static_config = static_vercel_config(builder, defaults, dirs.static);
|
|
61
67
|
|
|
62
68
|
builder.log.minor('Generating serverless function...');
|
|
63
69
|
|
|
@@ -174,7 +180,11 @@ const plugin = function (defaults = {}) {
|
|
|
174
180
|
{
|
|
175
181
|
runtime: config.runtime,
|
|
176
182
|
regions: config.regions,
|
|
177
|
-
entrypoint: 'index.js'
|
|
183
|
+
entrypoint: 'index.js',
|
|
184
|
+
framework: {
|
|
185
|
+
slug: 'sveltekit',
|
|
186
|
+
version: VERSION
|
|
187
|
+
}
|
|
178
188
|
},
|
|
179
189
|
null,
|
|
180
190
|
'\t'
|
|
@@ -363,11 +373,6 @@ const plugin = function (defaults = {}) {
|
|
|
363
373
|
// including ISR aliases if there is only one function
|
|
364
374
|
static_config.routes.push({ src: '/.*', dest: `/${DEFAULT_FUNCTION_NAME}` });
|
|
365
375
|
|
|
366
|
-
builder.log.minor('Copying assets...');
|
|
367
|
-
|
|
368
|
-
builder.writeClient(dirs.static);
|
|
369
|
-
builder.writePrerendered(dirs.static);
|
|
370
|
-
|
|
371
376
|
builder.log.minor('Writing routes...');
|
|
372
377
|
|
|
373
378
|
write(`${dir}/config.json`, JSON.stringify(static_config, null, '\t'));
|
|
@@ -420,8 +425,9 @@ function write(file, data) {
|
|
|
420
425
|
/**
|
|
421
426
|
* @param {import('@sveltejs/kit').Builder} builder
|
|
422
427
|
* @param {import('.').Config} config
|
|
428
|
+
* @param {string} dir
|
|
423
429
|
*/
|
|
424
|
-
function static_vercel_config(builder, config) {
|
|
430
|
+
function static_vercel_config(builder, config, dir) {
|
|
425
431
|
/** @type {any[]} */
|
|
426
432
|
const prerendered_redirects = [];
|
|
427
433
|
|
|
@@ -462,20 +468,60 @@ function static_vercel_config(builder, config) {
|
|
|
462
468
|
overrides[page.file] = { path: overrides_path };
|
|
463
469
|
}
|
|
464
470
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
{
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
471
|
+
const routes = [
|
|
472
|
+
...prerendered_redirects,
|
|
473
|
+
{
|
|
474
|
+
src: `/${builder.getAppPath()}/immutable/.+`,
|
|
475
|
+
headers: {
|
|
476
|
+
'cache-control': 'public, immutable, max-age=31536000'
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
];
|
|
480
|
+
|
|
481
|
+
// https://vercel.com/docs/deployments/skew-protection
|
|
482
|
+
if (process.env.VERCEL_SKEW_PROTECTION_ENABLED) {
|
|
483
|
+
routes.push({
|
|
484
|
+
src: '/.*',
|
|
485
|
+
has: [
|
|
486
|
+
{
|
|
487
|
+
type: 'header',
|
|
488
|
+
key: 'Sec-Fetch-Dest',
|
|
489
|
+
value: 'document'
|
|
473
490
|
}
|
|
491
|
+
],
|
|
492
|
+
headers: {
|
|
493
|
+
'Set-Cookie': `__vdpl=${process.env.VERCEL_DEPLOYMENT_ID}; Path=${builder.config.kit.paths.base}/; SameSite=Strict; Secure; HttpOnly`
|
|
474
494
|
},
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
495
|
+
continue: true
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// this is a dreadful hack that is necessary until the Vercel Build Output API
|
|
499
|
+
// allows you to set multiple cookies for a single route. essentially, since we
|
|
500
|
+
// know that the entry file will be requested immediately, we can set the second
|
|
501
|
+
// cookie in _that_ response rather than the document response
|
|
502
|
+
const base = `${dir}/${builder.config.kit.appDir}/immutable/entry`;
|
|
503
|
+
const entry = fs.readdirSync(base).find((file) => file.startsWith('start.'));
|
|
504
|
+
|
|
505
|
+
if (!entry) {
|
|
506
|
+
throw new Error('Could not find entry point');
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
routes.splice(-2, 0, {
|
|
510
|
+
src: `/${builder.getAppPath()}/immutable/entry/${entry}`,
|
|
511
|
+
headers: {
|
|
512
|
+
'Set-Cookie': `__vdpl=; Path=/${builder.getAppPath()}/version.json; SameSite=Strict; Secure; HttpOnly`
|
|
513
|
+
},
|
|
514
|
+
continue: true
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
routes.push({
|
|
519
|
+
handle: 'filesystem'
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
return {
|
|
523
|
+
version: 3,
|
|
524
|
+
routes,
|
|
479
525
|
overrides,
|
|
480
526
|
images
|
|
481
527
|
};
|
|
@@ -588,7 +634,11 @@ async function create_function_bundle(builder, entry, dir, config) {
|
|
|
588
634
|
maxDuration: config.maxDuration,
|
|
589
635
|
handler: path.relative(base + ancestor, entry),
|
|
590
636
|
launcherType: 'Nodejs',
|
|
591
|
-
experimentalResponseStreaming: !config.isr
|
|
637
|
+
experimentalResponseStreaming: !config.isr,
|
|
638
|
+
framework: {
|
|
639
|
+
slug: 'sveltekit',
|
|
640
|
+
version: VERSION
|
|
641
|
+
}
|
|
592
642
|
},
|
|
593
643
|
null,
|
|
594
644
|
'\t'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-vercel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "A SvelteKit adapter that creates a Vercel app",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@vercel/nft": "^0.26.1",
|
|
29
|
-
"esbuild": "^0.
|
|
29
|
+
"esbuild": "^0.20.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
|
33
33
|
"@types/node": "^18.19.3",
|
|
34
34
|
"typescript": "^5.3.3",
|
|
35
|
-
"vitest": "^1.
|
|
36
|
-
"@sveltejs/kit": "^2.5.
|
|
35
|
+
"vitest": "^1.5.0",
|
|
36
|
+
"@sveltejs/kit": "^2.5.6"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@sveltejs/kit": "^2.4.0"
|