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년 전248회 조회
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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인