async function generate_edge_function(name, config, routes) {
				const tmp = builder.getBuildDirectory(`vercel-tmp/${name}`);
				const relativePath = path.posix.relative(tmp, builder.getServerDirectory());

				builder.copy(`${files}/edge.js`, `${tmp}/edge.js`, {
					replace: {
						SERVER: `${relativePath}/index.js`,
						MANIFEST: './manifest.js'
					}
				});

				write(
					`${tmp}/manifest.js`,
					`export const manifest = ${builder.generateManifest({ relativePath, routes })};\n`
				);

				try {
					const result = await esbuild.build({
						entryPoints: [`${tmp}/edge.js`],
						outfile: `${dirs.functions}/${name}.func/index.js`,
						// minimum Node.js version supported is v14.6.0 that is mapped to ES2019
						// https://edge-runtime.vercel.app/features/polyfills
						// TODO verify the latest ES version the edge runtime supports
						target: 'es2020',
						bundle: true,
						platform: 'browser',
						conditions: [
							// Vercel's Edge runtime key https://runtime-keys.proposal.wintercg.org/#edge-light
							'edge-light',
							// re-include these since they are included by default when no conditions are specified
							// https://esbuild.github.io/api/#conditions
							'module'
						],
						format: 'esm',
						external: [
							...compatible_node_modules,
							...compatible_node_modules.map((id) => `node:${id}`),
							...(config.external || [])
						],
						sourcemap: 'linked',
						banner: { js: 'globalThis.global = globalThis;' },
						loader: {
							'.wasm': 'copy',
							'.woff': 'copy',
							'.woff2': 'copy',
							'.ttf': 'copy',
							'.eot': 'copy',
							'.otf': 'copy'
						}
					});

					if (result.warnings.length > 0) {
						const formatted = await esbuild.formatMessages(result.warnings, {
							kind: 'warning',
							color: true
						});

						console.error(formatted.join('\n'));
					}
				} catch (err) {
					const error = /** @type {import('esbuild').BuildFailure} */ (err);
					for (const e of error.errors) {
						for (const node of e.notes) {
							const match =
								/The package "(.+)" wasn't found on the file system but is built into node/.exec(
									node.text
								);

							if (match) {
								node.text = `Cannot use "${match[1]}" when deploying to Vercel Edge Functions.`;
							}
						}
					}

					const formatted = await esbuild.formatMessages(error.errors, {
						kind: 'error',
						color: true
					});

					console.error(formatted.join('\n'));

					throw new Error(
						`Bundling with esbuild failed with ${error.errors.length} ${
							error.errors.length === 1 ? 'error' : 'errors'
						}`
					);
				}

				write(
					`${dirs.functions}/${name}.func/.vc-config.json`,
					JSON.stringify(
						{
							runtime: config.runtime,
							regions: config.regions,
							entrypoint: 'index.js',
							framework: {
								slug: 'sveltekit',
								version: VERSION
							}
						},
						null,
						'\t'
					)
				);
			}
@param {string} name
@param {import('./index.js').EdgeConfig} config
@param {import('@sveltejs/kit').RouteDefinition<import('./index.js').EdgeConfig>[]} routes