Skip to content

How to use with @aws-cdk/aws-lambda-nodejs #363

@matthias-pichler

Description

@matthias-pichler

Describe the bug

When I try to deploy my TypeScript Lambdas using the @aws-cdk/aws-lambda-nodejs the invocations fail with:

2021-09-21T16:19:24.193Z	undefined	ERROR	Uncaught Exception 	{
    "errorType": "Error",
    "errorMessage": "make sure you have enabled the typescript compiler options which enable us to work with decorators (see doc)",
    "stack": [
        "Error: make sure you have enabled the typescript compiler options which enable us to work with decorators (see doc)",
        "    at createNewProperty (/var/task/index.js:33673:15)",
        "    at Object.initOrUpdateProperty (/var/task/index.js:33665:20)",
        "    at /var/task/index.js:33947:46",
        "    at __decorateClass (/var/task/index.js:66:24)",
        "    at model/api-key.ts (/var/task/index.js:38123:5)",
        "    at __init (/var/task/index.js:41:50)",
        "    at Object.<anonymous> (/var/task/index.js:38166:18)",
        "    at Module._compile (internal/modules/cjs/loader.js:1072:14)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)",
        "    at Module.load (internal/modules/cjs/loader.js:937:32)"
    ]
}

Since @aws-cdk/aws-lambda-nodejs uses esbuild which doesn't support emitDecoratorMetadata this isn't surprising.

However for some reason transpiling with tsc first doesn't solve the issue either.

A PR is currently open in the @aws-cdk repo to do exactly this to work around this. I tried their approach without success. Will this PR make dynamo-easy work with @aws-cdk/aws-lambda-nodejs?

To Reproduce
Steps to reproduce the behavior:

  1. Write a function using decorators from dynamo-easy
  2. Deploy them using @aws-cdk/aws-lambda-nodejs
  3. Invoke them
  4. See error

Expected behavior

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions