Closed
Description
Bug description
If you enable "ESM" bundling with NodejsFunction you get this error:
{
"errorType": "Error",
"errorMessage": "Dynamic require of \"util\" is not supported",
"stack": [
"Error: Dynamic require of \"util\" is not supported",
" at file:///var/task/index.mjs:1:820",
" at null.<anonymous> (/node_modules/cls-hooked/context.js:4:14)",
" at file:///var/task/index.mjs:1:1067",
" at null.<anonymous> (/node_modules/aws-xray-sdk-core/dist/lib/context_utils.js:5:11)",
" at file:///var/task/index.mjs:1:1067",
" at null.<anonymous> (/node_modules/aws-xray-sdk-core/dist/lib/aws-xray.js:2:20)",
" at file:///var/task/index.mjs:1:1067",
" at null.<anonymous> (/node_modules/aws-xray-sdk-core/dist/lib/index.js:3:18)",
" at file:///var/task/index.mjs:1:1067",
" at null.<anonymous> (/node_modules/@aws-lambda-powertools/tracer/src/provider/ProviderService.ts:4:1)"
]
}
Expected Behavior
Would like to use xray with ESM.
Steps to Reproduce
I'm using middy with the tracer middleware. I get the above error when I set
format: OutputFormat.ESM
Environment
- Powertools version used: 0.3.3
- Packaging format (Layers, npm): nodejsfunction
- AWS Lambda function runtime: node 14
- Debugging logs: