yarbsemaj / sveltekit-adapter-lambda

An adapter to build a SvelteKit app into a lambda ready for deployment with lambda proxy via the Serverless Framework or CDK.
https://www.npmjs.com/package/@yarbsemaj/adapter-lambda
MIT License
77 stars 16 forks source link

v1.0.0 #1

Closed sallaben closed 2 years ago

sallaben commented 2 years ago

Hi @Yarbsemaj, Thanks for offering this. I had the same idea for a lambda sveltekit adapter and was happy to see you had already made some progress on one.

My question is, How close is this adapter to v1 public release? What can I do to help? I'd like to get involved.

yarbsemaj commented 2 years ago

Hi @sallaben. Thank you for your comment! As for the adapter itself, I can’t think of any additional functionality that I would need adding. It should handle all requests and work as intended, unless it is having an issue in your use case?

However, I do think the deployment could be handled better. More specifically the routing of static assets of dynamic content. At the moment this routing is done via Cloudfront with some manually set up behaviours. In my setup, by default, all request go to the lambda, except files matching the path *.* which go to S3. Expect files matching *.json, those go to lambda, I then add in behaviours for the limited number of pre-rendered routes, having those go to S3. This works fine for my application but for more complex applications like those with many static files without extensions, static json files or many pre-rendered routes could easily breach the 25 behaviour limit of Cloudfrount.

To get around this I was considering using an edge lambda to rote the traffic base upon a manifest generated at build time, this manifest would contain a list of all files in S3 and would allow the edge lambda to rewrite the CF origin as required. I never got round to it as it wasn’t need for my application but if you would I’d be grateful for a PR. Or if you have any other solutions I’d love to hear them 😀

I have a brief blog post where I describe this in more detail https://yarbsemaj.com/blog/svelte-kit-ssr-aws-lambda