Open patrykkrawczyk opened 4 years ago
Hmmm we don't remove the warmup files. We only ignore them for ESLint and Babel, etc. We simply move it over to the package directory.
If we removed them, then the warmup plugin won't work right?
I believe _warmup files is the function code of the Lambda function that is calling a function that needs to be warmed up. It seems that when using warmup plugin after packaging, we get two functions:
@patrykkrawczyk Can you try the same setup in your post but disable the bundle plugin? And see if you see something different?
with serverless-bundle commented out in serverless.yml I get a zip package with all contents of my project inside, along with _warmup folder @jayair
Just to double check, is that the same as if you are using the bundle plugin?
if im using bundle plugin:
without bundle plugin:
I'm a little confused here. Can you tell me what the issue is?
When using warmup plugin together with bundle plugin, after you package your lambda function you will have a zip file in .serverless
directory.
Within this zip, you will actually have two functions instead of one.
If your function name is hello
, then within your hello.zip
you will have code for the hello
function and for the warmup
function. So it's basically uploading two functions within a single zip file, bloating up code size.
This hello.zip
should only have code of the hello
function.
In .serverless directory, there will also be a warmUpPlugin.zip
which holds only the warmup
function code, which will be called to warmup the hello
function.
\---.serverless
\---hello.zip
| | hello.js
| \---_warmup
| index.js
|
\---warmUpPlugin.zip
\---_warmup
index.js
Notice how the _warmup
directory is duplicated in hello.zip
Hmm if I run the steps in your original post with the bundle plugin I get this:
And with the bundle plugin commented out, I get this:
The _warmup
dir is there in both cases. I don't really see what you are saying.
Thats the issue. Let's focus on the first case.
Why is there _warmup
directory in hello.zip
?
It's not used for anything and just increases zip size.
hello.zip
should only contain handler.js
and handler.js.map
For warming up there's another zip called warmUpPlugin.zip
.
But from my quick test, this happens with or without the bundle plugin. So it doesn't seem related?
bundle plugin is removing all other files except for the _warmup directory
I don't have a ton of experience with the warmup plugin. But wouldn't it make more sense to tell them not to add that file in the package?
I think during webpack build this directory _warmup
is being created to build warmUpPlugin.zip
. The files then are picked up by serverless-bundle and are added to other zips. I don't think it's possible for them to mitigate this. The warmUpPlugin.zip
package still needs to be build but for other functions it should be ignored like all other files are ignored.
Can you provide steps to reproduce this? Because as I said above, even with the bundle plugin disabled, the files are still there.
Hi,
I've created a project based on this repository https://github.com/AnomalyInnovations/serverless-nodejs-starter
Then I've added serverless-plugin-warmup, to do so the only thing I did is:
and
Now when I do:
sls package
I have a zip file in .serverless directory and it contains _warmup directory with index.js This is strange since I believe there is a functionality to remove this directory baked into serverless-bundle. Unfortunately it does not work :(