Skip to content

Commit

Permalink
Run server.init() for edge functions on Vercel (#6327)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Simon H <[email protected]>
  • Loading branch information
3 people authored Aug 27, 2022
1 parent c3818b2 commit ddd3b63
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/strong-kangaroos-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sveltejs/adapter-vercel': patch
'@sveltejs/adapter-netlify': patch
---

Run `server.init()` for edge functions
5 changes: 5 additions & 0 deletions packages/adapter-netlify/src/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-netlify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"checkJs": true,
"noEmit": true,
"noImplicitAny": true,
"module": "es2020",
"module": "es2022",
"target": "es2022",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
Expand Down
4 changes: 4 additions & 0 deletions packages/adapter-vercel/files/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { manifest } from 'MANIFEST';

const server = new Server(manifest);

await server.init({
env: process.env
});

/**
* @param {Request} request
*/
Expand Down

0 comments on commit ddd3b63

Please sign in to comment.