question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-lambda-nodejs): esbuild does not support emitting typescript decorator metadata

See original GitHub issue

Somewhere in the recent version of ‘aws-lambda-nodejs’ module, the default bundler for aws-lambda-nodejs was changed from ‘parcel’ to ‘esbuild’. Bundling performance has improved greatly but all my handlers are broken now (all the ones that were relying on ts metadata reflaction).

This has to do with how esbuild transpiles typescript code, as stated here by the author of esbuild, emitDecoratorMetadata is not and will not be supported by esbuild, but this would break all other libraries that rely on the availability of run time metadata. like: TypeORM, TypeDORM, Nestjs.

I think aws-lambda-nodejs should auto handle pre-transpiling files with decorators using tsc and later continue with esbuild. (Similar suggested by the author of esbuild too.)

Reproduction Steps

Trying to bundle a simple nodejs project using Reflect metadata api should demonstrate the problem.

What did you expect to happen?

when bundling code with aws-lambda-nodejs decorator metadata should be reflected properly.

What actually happened?

Decorator metadata is not reflected in the fine js bundle.

If this is something aws-lambda-nodejs should handle, I can do a PR.

Environment

  • **CDK CLI Version :1.91
  • **Framework Version:1.91
  • **Node.js Version:14.15
  • **OS :linux
  • **Language (Version):TypeScript (3.9.9)

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
hassanazharkhancommented, Dec 8, 2021

@modul You are not missing anything,there seems to be bug with preCompiled flag if you try to bundle using docker it will probably work but not sure however I will try to PR the fix ASAP!

3reactions
hassanazharkhancommented, Sep 9, 2021

@whimzyLive any update over this ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to enable decorators in NodeJs lambda function that are ...
It looks like tsyringe requires the emitDecoratorMetadata option, which isn't supported natively by esbuild. You have a couple of options to ...
Read more >
@aws-cdk/aws-lambda-nodejs | Yarn - Package Manager
The NodejsFunction construct creates a Lambda function with automatic transpiling and bundling of TypeScript or Javascript code.
Read more >
esbuild-plugin-typescript-decorators - npm
Start using esbuild-plugin-typescript-decorators in your project by running `npm i ... There is 1 other project in the npm registry using ...
Read more >
BundlingOptions — AWS Cloud Development Kit 1.183.0 ...
For example, bundle buddy can consume esbuild's metadata format and generates a treemap ... features that are only supported by typescript's tsc compiler....
Read more >
How We Sped Up Our TypeScript Serverless Builds Ten ...
We are using decorators, but emitting decorator metadata is not supported by esbuild. We fixed a bug and submitted a PR to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found