(aws-lambda-nodejs): esbuild does not support emitting typescript decorator metadata
See original GitHub issueSomewhere 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:
- Created 2 years ago
- Reactions:10
- Comments:19 (10 by maintainers)
Top GitHub Comments
@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!
@whimzyLive any update over this ?