From ddd3b630090cd098a1038a56765e570339697830 Mon Sep 17 00:00:00 2001 From: Sam Greening <2552620+SG60@users.noreply.github.com> Date: Sat, 27 Aug 2022 19:43:18 +0100 Subject: [PATCH] Run server.init() for edge functions on Vercel (#6327) * Run server.init() for edge functions on Vercel. Required since #6179. Closes #6308. * changeset * changes * remove async keyword * Update .changeset/strong-kangaroos-work.md * netlify edge functions * changeset Co-authored-by: Rich Harris Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- .changeset/strong-kangaroos-work.md | 6 ++++++ packages/adapter-netlify/src/edge.js | 5 +++++ packages/adapter-netlify/tsconfig.json | 3 ++- packages/adapter-vercel/files/edge.js | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/strong-kangaroos-work.md diff --git a/.changeset/strong-kangaroos-work.md b/.changeset/strong-kangaroos-work.md new file mode 100644 index 000000000000..7708e75fdb13 --- /dev/null +++ b/.changeset/strong-kangaroos-work.md @@ -0,0 +1,6 @@ +--- +'@sveltejs/adapter-vercel': patch +'@sveltejs/adapter-netlify': patch +--- + +Run `server.init()` for edge functions diff --git a/packages/adapter-netlify/src/edge.js b/packages/adapter-netlify/src/edge.js index 44692e5fd49c..0acf8a593251 100644 --- a/packages/adapter-netlify/src/edge.js +++ b/packages/adapter-netlify/src/edge.js @@ -4,6 +4,11 @@ import { manifest, prerendered } from 'MANIFEST'; const server = new Server(manifest); const prefix = `/${manifest.appDir}/`; +await server.init({ + // @ts-ignore + env: Deno.env.toObject() +}); + /** * @param { Request } request * @param { any } context diff --git a/packages/adapter-netlify/tsconfig.json b/packages/adapter-netlify/tsconfig.json index 87bea241ee5c..0a6b886c8407 100644 --- a/packages/adapter-netlify/tsconfig.json +++ b/packages/adapter-netlify/tsconfig.json @@ -4,7 +4,8 @@ "checkJs": true, "noEmit": true, "noImplicitAny": true, - "module": "es2020", + "module": "es2022", + "target": "es2022", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "baseUrl": ".", diff --git a/packages/adapter-vercel/files/edge.js b/packages/adapter-vercel/files/edge.js index cc8cb64370b1..652f56cc7908 100644 --- a/packages/adapter-vercel/files/edge.js +++ b/packages/adapter-vercel/files/edge.js @@ -3,6 +3,10 @@ import { manifest } from 'MANIFEST'; const server = new Server(manifest); +await server.init({ + env: process.env +}); + /** * @param {Request} request */