AnomalyInnovations / serverless-bundle

Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
https://serverless-stack.com/chapters/package-lambdas-with-serverless-bundle.html
MIT License
536 stars 157 forks source link

Trouble using node-vibrant with serverless-bundle #40

Open Susan123456789 opened 5 years ago

Susan123456789 commented 5 years ago

I am trying to use node-vibrant on an image Buffer (obtained from an image on s3) in a node.js serverless function.

        const image=
            await s3.getObject({
                Bucket:     bucket,
                Key:        key,
            }).promise();

        const palette = await Vibrant.from(image.Body).getPalette();

However, I keep getting the error:

TypeError: Jimp.read is not a function
    at NodeImage.../../@vibrant/image-node/lib/index.js.NodeImage._loadByJimp (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/image-node/lib/index.js:61:1)
    at NodeImage.../../@vibrant/image-node/lib/index.js.NodeImage.load (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/image-node/lib/index.js:72:1)
    at Vibrant.../../@vibrant/core/lib/index.js.Vibrant.getPalette (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/core/lib/index.js:44:1)
    at Builder.../../@vibrant/core/lib/builder.js.Builder.getPalette (/mnt/c/dev/photobook/image-optimizer/.webpack/image-optimizer/webpack:/mnt/c/dev/photobook/image-optimizer/node_modules/@vibrant/core/lib/builder.js:62:1)

When I switch back from using serverless-bundle to the packages/config described in the old Serverless Stack tutorial (see the old version at https://github.com/AnomalyInnovations/serverless-stack-com/commit/052567d66d4c960814897a88e00fa49f629f10e7#diff-5ab08fc0a992c83fe1b2d549015ec527), then it works fine. How can I configure the serverless-bundle such that node-vibrant will work?

@Susan123456789

jayair commented 5 years ago

I think for some packages like this, we need to take a look and handle them specifically. I'm not entirely sure what is going on.

Does node-vibrant have any instructions on how to use with Webpack?

escarbor commented 3 years ago

I am having a similar issue, and while searching, I found this.