Open artworx opened 4 years ago
thanks for the report, I'm a bit busy right now, but I'll check this out once I have some time.
One thing to check: do you have any plugin compiling the files into dist/index.js
? If so, is that step happening when you add serverless-plugin-tree-shake
?
I don't have any extra plugins for compiling
This is the minimal serverless.yml I used to reproduce it.
org: artworx
app: demo
service: lambda-demo
provider:
name: aws
runtime: nodejs12.x
region: eu-central-1
stage: dev
plugins
- serverless-plugin-tree-shake
functions:
hello:
handler: handler.main
As soon as I add org
and app
keys to serverless.yml
, the handler in cloud formation is s_handler
.
# .serverless/serverless-state.json
"HelloLambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "ServerlessDeploymentBucket"
},
"S3Key": "serverless/...
},
"Handler": "s_hello.handler",
If I remove the serverless-plugin-tree-shake
, the packaged zip file includes s_handler
.
edit: without the plugin:
Archive: .serverless/demo-lambda.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
158 Defl:N 123 22% 1980-01-01 00:00 9d69e4e5 handler.js
177 Defl:N 139 22% 1980-01-01 00:00 550be662 node_modules/.bin/components
1542 Defl:N 694 55% 1980-01-01 00:00 6339c529 node_modules/.bin/nft
272492 Defl:N 83162 70% 1980-01-01 00:00 85af2074 package-lock.json
431 Defl:N 263 39% 1980-01-01 00:00 71d54573 package.json
910 Defl:N 490 46% 1980-01-01 00:00 79514b6d s_hello.js
350564 Defl:N 121712 65% 1980-01-01 00:00 0fb2e8c6 serverless_sdk/index.js
-------- ------- --- -------
626274 206583 67% 7 files
with the plugin enabled:
Archive: .serverless/demo-lambda.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
158 Defl:N 123 22% 1980-01-01 00:00 9d69e4e5 handler.js
431 Defl:N 263 39% 1980-01-01 00:00 71d54573 package.json
-------- ------- --- -------
589 386 35% 2 files
Original directory:
$ tree
.
├── handler.js
├── package.json
├── package-lock.json
└── serverless.yml
But notice that in your second snippet you no longer have the dist/
in the handler. Any reason why?
Because i created a new project with just a single js file. It's not about the compilation, its about the injected wrapper by the serverless framework which gets stripped from the final package.
On Tue, Nov 10, 2020, 6:43 PM Sérgio Ramos notifications@github.com wrote:
But notice that in your second snippet you no longer have the dist/ in the handler. Any reason why?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sergioramos/serverless-plugin-tree-shake/issues/47#issuecomment-724823437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO5GEVYFMGIJZM27QV7BULSPFUSZANCNFSM4TPSASTQ .
This is my serverless.yml file:
The deployed Lamba's entry point gets set to
s_index.handler
, but whenserverless-plugin-tree-shake
is enabled, that file is not present in the deployment.