CoorpAcademy / serverless-plugins

Collection of serverless plugins :zap:
231 stars 132 forks source link

support for serverless-offline 10 in SQS #220

Closed rubenkaiser closed 2 years ago

rubenkaiser commented 2 years ago

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.

zumby commented 2 years ago

@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 ;)

an1va commented 2 years ago

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

rubenkaiser commented 2 years ago

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 commented 2 years ago

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.

terozio commented 2 years ago

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.

Arcuman commented 2 years ago

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

an1va commented 2 years ago

@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.

luisdemarchi commented 2 years ago

still someone trying to defend the late node 12? 🥹

luisdemarchi commented 2 years ago

@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.

rubenkaiser commented 2 years ago

@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?

luisdemarchi commented 2 years ago

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

rubenkaiser commented 2 years ago

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

drace-rgare commented 2 years ago

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

sambP commented 2 years ago

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

rubenkaiser commented 2 years ago

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

godu commented 2 years ago

@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 🚀