From 6821d642478c692ed028e91d8d08c9754aa1db2f Mon Sep 17 00:00:00 2001
From: Gal Schlezinger <gal@spitfire.co.il>
Date: Mon, 25 Apr 2022 17:06:38 +0300
Subject: [PATCH] [adapter-vercel] Make all root routes be called `index`
 instead of an empty string (#4731)

* [adapter-vercel] Make all root routes be called `index` instead of an empty string

* Add changeset

* Update packages/adapter-vercel/index.js

* Update packages/adapter-vercel/index.js

* Update .changeset/shiny-needles-divide.md

Co-authored-by: Conduitry <git@chor.date>

Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Conduitry <git@chor.date>
---
 .changeset/shiny-needles-divide.md | 5 +++++
 packages/adapter-vercel/index.js   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 .changeset/shiny-needles-divide.md

diff --git a/.changeset/shiny-needles-divide.md b/.changeset/shiny-needles-divide.md
new file mode 100644
index 000000000000..9dbc612a36eb
--- /dev/null
+++ b/.changeset/shiny-needles-divide.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/adapter-vercel': patch
+---
+
+Fix `edge: true, split: true` build error for root routes when deploying to Vercel
diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js
index 728996d7e6db..f98c2c4b5137 100644
--- a/packages/adapter-vercel/index.js
+++ b/packages/adapter-vercel/index.js
@@ -340,7 +340,7 @@ async function v3(builder, external, edge, split) {
 						.slice(1, -2) // remove leading / and trailing $/
 						.replace(/\\\//g, '/')}(?:/__data.json)?$`; // TODO adding /__data.json is a temporary workaround — those endpoints should be treated as distinct routes
 
-					await generate_function(route.id, src, entry.generateManifest);
+					await generate_function(route.id || 'index', src, entry.generateManifest);
 				}
 			};
 		});