serverless-plugins icon indicating copy to clipboard operation
serverless-plugins copied to clipboard

support for serverless-offline 10 in SQS

Open rubenkaiser opened this issue 3 years ago • 13 comments

SLS offline was converted to a pure esm module in version 9 and since then the import of modules throws an error. Therefore I added a dynamic import for the lambda code keeping the rest of the plugin pretty much the same.

After this update you still need to remove the single "exports" line from node_modules/serverless-offline/package.json by hand to be able to import the required lambda files. In the serverless-offline-eventBridge plugin I automated this but it is not a nice solution.

rubenkaiser avatar Aug 17 '22 07:08 rubenkaiser

@godu would you please take a look? i dont really want to keep local plugin copy in our repo - so if you could review/approve/release - would be great ;)

zumby avatar Aug 17 '22 10:08 zumby

Is this going to be merged in? It'd also keep us from maintaining it locally.

an1va avatar Aug 25 '22 06:08 an1va

A new PR is present at https://github.com/dherault/serverless-offline/pull/1552 that will add named exports for the lambda code we need in this plugin. This will also affect this PR so when the mentioned PR has gone through I will update this one as well. This will only affect the async import in the _createLambda changing it to:

const { Lambda } = await import('serverless-offline');

rubenkaiser avatar Aug 25 '22 11:08 rubenkaiser

Been trying to fix the builds, but the node12 build will remain a problem since dynamic import (which is used for the new sls offline lambda import) is supported from 13.2. I'll leave the decision to upgrade this to the repo owners.

rubenkaiser avatar Sep 14 '22 11:09 rubenkaiser

As a user of the plugin, since node.js 12 is very soon about to be deprecated as a lambda runtime it feels it would be much more valuable to have a version which can work with more recent serverless-offline even if it means dropping the support for node12.

Afaik right now there is no way to run Node 16 lambdas with serverless offline & offline sqs since the node16 is not supported by serverless offline versions which are still compatible with the latest version of the plugin.

terozio avatar Sep 14 '22 11:09 terozio

@godu Please take a look of this PR, we do really need it

Arcuman avatar Sep 16 '22 15:09 Arcuman

@godu Most people using this are blocked on moving to serverless-offline 10 still because of these changes. It'd be really useful to get this change merged and the dependencies moved to Node13.2/Node14+ on a new release across serverless-plugins.

an1va avatar Sep 27 '22 08:09 an1va

still someone trying to defend the late node 12? 🥹

luisdemarchi avatar Sep 29 '22 18:09 luisdemarchi

@rubenkaiser i pulled it directly from your PR and it looks like the error really stopped, but the serverless offline hangs on this line: Starting Offline SQS: devel/us-east-1.

luisdemarchi avatar Sep 29 '22 20:09 luisdemarchi

@luisdemarchi can you give some more details. I didn't really change the workings, just the way the lambda's are handled. Are the credentials for the queue correct? Or do you emulate the queue with elasticMQ locally?

rubenkaiser avatar Sep 30 '22 07:09 rubenkaiser

@rubenkaiser I already found the error. It was just a setting that I accidentally modified

luisdemarchi avatar Oct 04 '22 21:10 luisdemarchi

Taking quite some time so I decided to quickly (read: without testing) publish a version of the update to use for the time being:

https://www.npmjs.com/package/sls-offline-aws-sqs

rubenkaiser avatar Oct 07 '22 09:10 rubenkaiser

This isn't going to happen. The last time this repo was updated was a year ago. I suggest looking in to LocalStack instead or @rubenkaiser alternative repo

drace-rgare avatar Oct 07 '22 14:10 drace-rgare

But if they do not update the serverless-offline package, wouldn't this mean, that the whole serverless.js ecosystem is not useable anymore?

sambP avatar Oct 07 '22 19:10 sambP

But if they do not update the serverless-offline package, wouldn't this mean, that the whole serverless.js ecosystem is not useable anymore?

No, it will mean that the plugins in this repo will not be usable anymore. But for now you can try my published package for sqs

rubenkaiser avatar Oct 08 '22 08:10 rubenkaiser

@rubenkaiser Thank you for your work. I applied the same logic to the others packages. https://github.com/CoorpAcademy/serverless-plugins/pull/228 It is already available in the latest publish 🚀

godu avatar Oct 26 '22 14:10 godu