Skip to content

Bug: Unable to use ESM bundling in AWS Lambda / Nodejs 14.x #490

Closed
@revmischa

Description

@revmischa

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:

Related issues, RFCs

Metadata

Metadata

Assignees

Labels

blockedThis item's progress is blocked by external dependency or reasonbug-upstreamThis item is related to a bug caused by upstream dependencyduplicateThis issue is a duplicate of an existing onetracerThis item relates to the Tracer Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions