serverless-webpack
serverless-webpack copied to clipboard
The Lambda layer is not working with Typescript.
This is a (Bug Report / Feature Proposal)
Bug Report
Description
I'm using AWS as a cloud provider. I created a serverless project with the NodeJS Typescript template to use Lambda Layers. Service only contains the layer details in the serverless.yml file. When I'm trying you to package it, it's throwing an error called entry can't be non-empty value. So I checked the serverless-webpack npm module. It seems it's only generating entries for the Lambda functions not for the layers. I modified the validation and generated the entries for layers as well in the npm library and pointed the entry as database/nodejs/node-modules/database/index.ts in the tsconfig.json file Then it's successfully packaging the layer.
For bug reports: Ts files are not getting compiled with the given folder structure. ASW have their folder structure to create lambda layer https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html. I followed the same structure My folder structure: database/nodejs/node-modules/database/index.ts (index.ts contains the typescript code).
The generated folder structure under .serverless folder is database.zip which contains (database/nodejs/node-modules/database/index.ts). This code has not complied. Seems it's just zipping the folder. If I use the mongoose npm library then the compiler is not resolving the file and it's throwing an error saying module is not resolved. But the file is there. under the node module.
The expected folder structure is database.zip which contains (database/nodejs/node-modules/database/index.js). index.js is a complied version of index.ts
For feature proposals:
Similar or dependent issue(s):
Additional Data
- Serverless-Webpack Version you're using: 1.63.0
- Webpack version you're using:
- Serverless Framework Version you're using:
- Operating System: win32
- Stack Trace (if available):
This is my folder Stucture.
This is the ts file
This is the
I am facing the similar issue while using AWS Lambda layers with TypeScript
I've seen workarounds but is there any update on this issue officially?
Im facing the same issue. Is there any workaround?
Same issue here.
Is there any chance to have a repo with minimal information to reproduce the issue?
Is there any chance to have a repo with minimal information to reproduce the issue?
I created a small repo to reproduce it: https://github.com/chriszirkel/serverless-webpack-layers
If you npx sls package
it, the resulting testLayer.zip will contain the original index.ts Typescript file.
@j0k3r I would like to volunteer for this issue if you could give me a hint where the layer packaging happens?
This is an issue with the serverless-webpack
plugin. It still does not support lambda layers. Any idea when can we be expecting a fix on this?
@zirkelc AFAIK there is no layer packaging logics anywhere in the codebase.
If anyone wants to work on this, I would recommend start studying how entries are generated validate.js#allEntryFunctions
, you should add layer entries there. It then goes through compile.js
.
After that, study packageModules.js
and pick up your compiled layer bundles there.
Same issue here.
Any update on this issue?