-
-
Notifications
You must be signed in to change notification settings - Fork 434
Example Serverless Arquitecture on Now v2 #564
Comments
Referencing https://github.com/zeit/now-examples/issues/193 |
I have no idea what I was doing and it was not successful: now.json
index.js
demo: https://sapper-template-114-izlvje2aa.now.sh shows 500 error
After removing
I tried several to make a custom builder (now-sapper) but without success... |
Any progress on this? |
@vladejs you can rest easy knowing that all the Sapper/Svelte sites, docs, examples are all hosted on now v1. Dogfooding is key :) |
There hasn't been any progress on this that I know of, but I'm pretty sure it will be a focus after Svelte 3 is out the door. One unfortunate thing that makes this a bit more pressing is that Now apparently isn't allowing v1 for new projects, only for ones created before a certain date. I'm not sure why they decided to have the window be so narrow between the introduction of v2 and disallowing v1 on new projects. I'm pretty sure I read when v2 was announced that "don't worry, v1 isn't going anywhere anytime soon", but I certainly did not get the impression that it was going to be disallowed for new projects so quickly. |
Progress: https://sapper-template-now-p0lz941iy.now.sh/
@Conduitry As far as I know, users with projects on v1 can create new v1 projects. Only users that never used v1 are forced to use v2. |
This is awesome news, well done @thgh Do you reckon you'll be able to get it running with Polka? What is the likelihood of a v2 app working with this? I've got a mountain of stuff to migrate and I'm not sure I'm ready just yet! |
You can try v2 yourself, I think it should work. @lukeed Polka says:
|
Does |
Now it exists: https://github.com/thgh/now-sapper @antony got Polka working, had to export the |
How about putting the example app itself somewhere open? I'd rather not form a relationship with a "zeit" (which might be amazing...) to take a look. Currently clicking on the link about ending in _src requires some kind of account or login. |
@kylecordes without login: code / result |
@thgh looks great! Yeah - Polka doesn't export the handler directly like express. Awesome work! @kylecordes I think you can also still set a project to open source which will allow anonymous access to |
Can this added to sapper with a |
It's nice we have an example. I'm also interested if we can take this a bit further. If I understand serverless correctly, the whole point is to do code splitting on serverside as well. This section from next.js explains well how they handle serverless build.
Would sapper consider supporting a build like this? Or is it even viable? I think it would be really great, as serverless benefits are numerous. |
Yeah, to be on par with the Next.js builder it would need to create a lambda for every route |
Do the examples I see here inherently support server routes, or no? |
@HorizonShadow yes, e.g. sapper-template has a server route for blog posts. |
Was playing around with this just using the @now/node builder, and I'm pretty sure once vercel/ncc#216 gets to now-builders, it'll "just work". So you'd set the I think, anway. |
@HorizonShadow While, I think that it will be great when |
Hi, Base on @danielschmitz modifications, I created a sample repo sapper-now-template base on the original sapper-template (diff). I don't know if it would make sense to make a Pull Request on the original sapper-template repo based on these modifications, or if you want to keep the template agnostic from Now (Though I was personnaly surprised to see it recommended on the documentation, but not working directly) Thank you very much anyway for your great work ! Tell me if I can be of any help :) |
@vfabing The official template already has explicit netlify support, so I would imagine that adding now v2 support would be welcome also. For a lot of people, myself included, this is a huge problem right now. |
I believe sapper should be now v2 aware, since the project is inspired by
Next.js which has excellent support for it.
…On Fri, Jul 26, 2019, 6:45 PM pngwn ***@***.***> wrote:
I've not read this thread and I don't use now. Do we need to put together
a custom loader or something? Is there something someone has built that
works without any issues? Or maybe we just need to recommend a different
host if now v2 is just causing too many problems?
I'm just trying to work out if there is something we need to do as regards
this issue or if it is just a support thing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#564?email_source=notifications&email_token=ADANIARCGSKDDV2YU63UMMDQBN5APA5CNFSM4GXXXMTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD254ATI#issuecomment-515620941>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADANIARGVGIU4537MI46HATQBN5APANCNFSM4GXXXMTA>
.
|
next.js has excellent support because it is built by the now v2's requirement are very specific and no other host that I'm aware of has the same requirements. We might be able to provide some guidance or even a separate package to help smooth out these issues but I don't see any reason why Sapper would have first class support for now out of the box since their shift to serverless in v2. |
@vladejs That's not correct. My understanding is that Sapper can export static sites for some projects, which will work great on Now v2, but more complex Sapper apps that require the server will not be optimized for Now v2 (they will work, but only slowly, as the server would need to start up again for each request). |
mmm. Interested to know how Next do it, since most basics apps made with
Next.js also requires a server.
Also, Zeit provides guides on how to make an Express server serverless,
which is done by just using Express as middleware and discarding routing.
Routing is handled by now.
I also saw a comment from a Zeit team member on one of their repos saying
that sapper should work great on serverless environments.
Not going in technical details but it should be possible to decompose the
routes on independent lambdas as Next.js does when setting it's serverless
config to true, at the end, both uses the filesystem as routing.
Also, Zeit has improved it's serverless functions by natively using common Express functions on the `request` and `response` objects:
https://zeit.co/blog/now-node-helpers
|
@pngwn , there is some discussion about bringing sapper to now v2 here: |
Hey everyone, we've just optimized Sapper for Now when using |
Is possible with that solution export authenticated apps? |
The rules about when you can export still apply - https://sapper.svelte.dev/docs#When_not_to_export Being able to serve completely static sites on Now isn't anything new, and nothing about this seems particularly specific to Sapper. |
Okay, it's great for the config to be simplified 👍 But this doesn't address serverless at all. |
Exactly
…On Fri, Aug 2, 2019, 1:32 AM Nathaniel Hill ***@***.***> wrote:
Okay, it's great for the config to be simplified 👍 But this doesn't
address serverless at all.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#564?email_source=notifications&email_token=ADANIAXSED4E4GENDWUMMVLQCPBFVA5CNFSM4GXXXMTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3MUQZI#issuecomment-517556325>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADANIASVJDLWMWGJ4LHEQNLQCPBFVANCNFSM4GXXXMTA>
.
|
Not sure if I'm late with this but looks like you could put your authentication functions into an |
@aurnik it's more about a function-per-route like Next does. |
While this used to be true for next.js, it's no longer the case after the release of next.js 9. A next.js application can now be static and dynamic at the same time |
Now is tackling the serious cold start problem with lambdas, by simply lowering the lambda cold boot time to an acceptable level (100-300 ms) through server side code splitting and tiny bundles. (Instead of one large monolithic bundle, that takes up to 2 sec to load into memory). This is a huge advantage for people who want to go the serverless route, and a large plus for Nextjs on the Next-vs-Sapper-comparison-sheet that one might draw mentally, when about to embark on a new project. As @rauchg has pointed out, the Sapper architecture, inspired by Next's, seems to be perfectly usable for serverless code splitting. It'd be a pity, if we wouldn't see a marriage between now and sapper - as sapper is still simply leaner and more efficient than react - and it's hard to forego efficiency. But Next+Now enabling killer-features like serverless prerendering makes Next even more appealing, in my opinion, as long as Sapper did not follow suit. |
Surely it is possible to achieve at least a meaningful portion of this kind of architectural improvement / code split speed booth without becoming bound to one specific serverless platform/vendor? Because while I'm sure Now is a wonderful wonderful thing… It is not reasonable to expect that one product/vendor to become "the" way to host efficiently. |
@kylecordes nobody is suggesting that, what is being suggested is a solution for all serverless-function based platforms. Now is a good starting place as it allows you to host on AWS, GCP, and possibly Azure in the near future. Being able to make a Sapper project split a project into functions based upon routes would be a step forward in this direction. |
Yes. If I get any spare time this month I'll give it a go. I'll make a fork called sapperless to experiment with building route-based functions and maybe it could be folded back into sapper at some point. |
I've created a sort-of evolution of the previous now-sapper builder by @thgh . You can test it out here: https://github.com/beyonk-adventures/now-sapper - by simply sticking the github URL into your Feedback is welcome. The roadmap (which I certainly need help with) is:
|
@antony Static assets are now served as static routes. Thanks to your refactor! |
@thgh Amazing! That's the next roadmap item checked off. Now we just see what @NathanielHill can come up with 💃 |
@antony Unfortunately, I'm not going to have time for this any time soon. |
@NathanielHill Ah that's a shame. |
Anyone that has got a working copy of I have SSR issues with the @antony Any tips? Thanks! |
@tomsoderlund It works without issue:
https://test-v2-qa-fvkozm8hw.now.sh closing this issue as I am happy with the way that Sapper works on now v2, and I think route splitting should be addressed in a separate issue. |
@antony Yes, thanks - I tried it last night too and it worked great! |
(here was the fix beyonk-group/now-sapper-demo#5 (comment)) |
It seems that Now (zeit.co/now) is moving towards a serverless approach.
Is there an example of Sapper working with Now v2?
Thanks
The text was updated successfully, but these errors were encountered: