Webpack and TypeScript configuration for AWS CloudFront Functions

0

I am aware of a definitely typed package for AWS CloudFront Functions. Is there a recommended webpack and TypeScript configuration that can generate valid code?

已提問 2 年前檢視次數 243 次
1 個回答
0

I worked on this problem for quite a while. Cloudfront Functions are definitely meant to be small. It is all explained reasonably well HERE. The javascript that runs a cloud function is pretty limited not only in what it can do but also the language - for example there's no const or let. It's kind of close to ECMAScript 5.1 with a bunch of stuff missing.

Based on this, I don't know how you'd coerce the typescript compiler to build to that. See HERE. I am not confident you could make it work, and if even if you sort of did I think you'd run into many unpleasant surprises.

In my case, I only really cared about having strong typing, for reasons of code quality. But with the idea that Cloudfront Functions are meant to be short and sweet, I decided to just do without it, and that's what I recommend you do, too. If you need more, run lambda@edge instead. Just keep in mind that costs six times as much per invocation, meaning if you can do it in a Cloudfront Function that's definitely advisable. All I'm saying is that CloudFront Functions are meant to be pretty to-the-point, so maybe you need to convince yourself you can live without it being in TS.

This question has been sitting out here for quite a while, so I'm probably too late. Hope this helps somebody else, though.

profile picture
wz2b
已回答 9 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南