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?

asked 2 years ago223 views
1 Answer
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
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions