@sveltejs/adapter-vercel
Advanced tools
Comparing version 2.2.0 to 2.2.1
25
index.js
@@ -9,2 +9,4 @@ import fs from 'node:fs'; | ||
const DEFAULT_FUNCTION_NAME = 'fn'; | ||
const get_default_runtime = () => { | ||
@@ -218,3 +220,3 @@ const major = process.version.slice(1).split('.')[0]; | ||
// generate one function for the group | ||
const name = singular ? 'fn' : `fn-${group.i}`; | ||
const name = singular ? DEFAULT_FUNCTION_NAME : `fn-${group.i}`; | ||
@@ -292,8 +294,21 @@ await generate_function( | ||
if (singular) { | ||
// Common case: One function for all routes | ||
// Needs to happen after ISR or else regex swallows all other matches | ||
static_config.routes.push({ src: '/.*', dest: `/fn` }); | ||
if (!singular) { | ||
// we need to create a catch-all route so that 404s are handled | ||
// by SvelteKit rather than Vercel | ||
const runtime = defaults.runtime ?? get_default_runtime(); | ||
const generate_function = | ||
runtime === 'edge' ? generate_edge_function : generate_serverless_function; | ||
await generate_function( | ||
DEFAULT_FUNCTION_NAME, | ||
/** @type {any} */ ({ runtime, ...defaults }), | ||
[] | ||
); | ||
} | ||
// Catch-all route must come at the end, otherwise it will swallow all other routes, | ||
// including ISR aliases if there is only one function | ||
static_config.routes.push({ src: '/.*', dest: `/${DEFAULT_FUNCTION_NAME}` }); | ||
builder.log.minor('Copying assets...'); | ||
@@ -300,0 +315,0 @@ |
{ | ||
"name": "@sveltejs/adapter-vercel", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"repository": { | ||
@@ -32,3 +32,3 @@ "type": "git", | ||
"typescript": "^4.9.4", | ||
"@sveltejs/kit": "^1.8.7" | ||
"@sveltejs/kit": "^1.9.2" | ||
}, | ||
@@ -35,0 +35,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23075
597