New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proper way to include the library for usage in aws lambda with ESM modules? #402
Comments
I think this should do the trick: import sizeOfImage from 'image-size';
// ...
const size = sizeOfImage.default(buffer); This should improve when #370 is merged, but who knows when that will happen. |
When you import with
Unfortunately, I don't. For anyone really wanting to help test this, please try using If you see the issue pointed out by the last comment on that PR, please feel free to debug and send a PR fixing this. Once enough people asking for ESM support confirm that the beta releases work for them, I'll gladly merge that PR, and release a |
this is the workaround I finally used: import * as imageSize from 'image-size';
const sizeOf = imageSize.imageSize;
const dimensions = sizeOf(filepath); |
@cesarpachon Does this also work for you? import { imageSize } from 'image-size';
const dimensions = imageSize(filepath); |
yeah it worked :) |
and that's with the |
nope: to clarify, the reason why I opened the ticket is because webpack ignores "require" calls when using with pure mjs modules, so I was forced to try-and-guess what is the proper way to use the library with "import", because the readme only presents examples with require... I looks just like it needs to add the "import" example to the readme. |
Hello,
I migrated recently my node.js project to ESM modules (type="module" in the package.json, using only ".mjs" files with import syntax) and bundling with webpack for usage in AWS lambda, but I have problems with image-size, it is in node-modules and package json but I get the following runtime error when trying to execute the lambda:
Like if the library is not being bundled. I am using the following statement to include:
I suspect I am missing some important steps in order to use image-size in this context.
The text was updated successfully, but these errors were encountered: