Skip to content
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

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

Closed
Tracked by #374
matthias-pichler opened this issue Sep 21, 2021 · 2 comments
Closed
Tracked by #374

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

matthias-pichler opened this issue Sep 21, 2021 · 2 comments

Comments

@matthias-pichler
Copy link

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

@hassanazharkhan
Copy link

@matthias-pichler-warrify Transpiling first and pass the output to esbuild is indeed working for me, I'm not sure why this isn't working for you. Could you please share a minmal repo of the bug you're facing. I would really like to take a look.

Please have a look on this Issue and this Repo

@michaelwittwer
Copy link
Member

closing this in favour of #374 holding relevant topics to be updated in the docs, serving as a knowledge base for now and also describing the strategy of the technical solution of the documentation part, envision it to be closer to the source code of the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants