-
Notifications
You must be signed in to change notification settings - Fork 155
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
Unable to use SDK with ESM bundling in AWS Lambda / Nodejs 14.x #482
Comments
I'm getting this exact issue as well, I would really like it if this was fixed! |
Pretty sure I've got the same issue with a different error:
I'm bundling my lambda using rollup, but since |
Hi! Thank you for raising this issue, sorry for the delay in responding. I did some digging around and read this really useful article on how to build a package for both CommonJS and ESM. Based on this, I learnt that we need to build the
It would definitely be great to employ something like in that article to have a single module that supports both
Because of all of this I'm labeling this issue as an "enhancement" instead of a "bug", please let me know if you think this isn't the best label for this. I have also created a ticket internally to track this and will bring it up to our team to hopefully get priority on this soon!
@ianwremmel By handler do you mean the Lambda handler? Also, this is with the latest release of |
This article on the AWS blog generated a lot of buzz a few weeks back, but since the XRay SDK (and full aws-sdk) don't work with it, the article is announcing a feature no one can use, so it does feel more like a bug than an enhancement.
No, sorry, I was saying that if I don't use module mode, everything works, implying I have the layers working correctly. There's no workaround there, I was just trying to get a jump start on potential triage questions you might ask me. |
A couple of weeks ago AWS announced support for ESM modules in AWS Lambda for
node.js >=14.x
runtimes. To quote the announcement:When trying to bundle a function as ESM module with
aws-xray-sdk-node
as dependency, simply importing the SDK in AWS Lambda an error is thrown:We have received a bug report from a Customer using
@aws-lambda-powertools/tracer
, an utility that depends on this SDK.I was able to reproduce the error using CDK &
esbuild
with ESM output format enabled.Below a reproduction example with
"aws-cdk-lib": "^2.8.0"
&"esbuild": "^0.14.11"
Content of
lib/main.ts
, function has a single dependency of"aws-xray-sdk": "^3.3.4"
Please don't hesitate to ping me if you need additional details.
The text was updated successfully, but these errors were encountered: