hsb1007
hsb1007

Reputation: 119

Lambda functions with ESM

First of all, I am a Node newbie, moved from PHP development, so the question may be dumb..

I am in the process of developing a webservice using node with ESM ("import" syntax).

Now I am trying to build some microservices to do background operation using Lambdas with SQS as a trigger and Serverless framework as a deployment tool..

Now that I deployed the first Lambda, I realised ESM syntax isn't supported by Lambda but all services / factories are in ESM syntax already..

What's the best way to manage this lambda function based on services in ESM syntax?

And how do you deal with the common services used in both web service and lambda package? I don't want to duplicate to both projects in IDE if that makes sense.

Hence, I was hoping to place this serverless framework in the same folder and manage it from there, but unsure if this is the best way to move forward..

If I used 'Typescript', which I haven't had a chance to explore yet due to the deadline of the project, would I not have faced this issue with Lambda deployment?

Upvotes: 2

Views: 3121

Answers (1)

Erez
Erez

Reputation: 1750

With Serverless Webpack you can have both ESM and TypeScript support.

For common services, you can consider publishing them as packages, installing them directly from GitHub URLs or just place everything in the same repository and import them directly, whatever works best for you.

Upvotes: 3

Related Questions