-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm 8 / Node 16 produces deployments zip's too large to deploy (50meg), npm 6 / Node 12 fine (12meg) #10863
Comments
Hello @tomchiverton - thanks for reporting. It seems like you're using a heavily outdated version of the Framework - do you have the option to check if that problem persists on recent versions as well? |
I've run
|
Hello @tomchiverton - based on the output you're providing you're using |
I'm not really sure how to check that.
|
Based on the outputs it looks like it's using some kind of local installation - is there a chance that you have a |
I removed node_modules. re-ran "npm i" and again :
There is a node_modules folder Renamed that node_modules, re-ran and now I get messages about needing to fix my SSM variable syntax. Interesting.
fixed that up easily and
So why is Serverless looking up in parent folders ?!? |
Hey @tomchiverton - so it seems like the issue was solved for you? The reason it's looking up in parent folders is that people sometimes have different configurations where they nest services inside a bigger projects - in that cases you can e.g. install |
No, it's not solved; As soon as we "npm i" a Serverless plugin - such as serverless-plugin-aws-alerts the whole @serverless / serverless folder is copied to node_modules in the deployment package. Because the plugins specify only Serverless v2.x or v1.x, so it down grades the whole "sls" experience from the global install of v3.x to v2.x for this particular project. I understand this is by design :) Bu I think this is still a bug in how dependencies are removed, because the plugin's have no runtime dependency on anything, so there's no need to bundle them and 40meg of their dependencies into the deployment .zip |
Ex
1.5K
47M |
Hey @tomchiverton - are you adding the plugins as |
https://github.com/activescott/serverless-aws-static-file-handler#install says to not have them as devDeps ? |
Thanks for sharing @tomchiverton - I personally don't see a valid reason for adding plugins as |
From a clean new project (as above)
132k I'll have to test in a non-toy project to see if it still works. |
Thanks @tomchiverton - please let us know if the problem still persist on the other project, thanks in advance 🙇 |
Doesn't work, because the usage of serverless-aws-static-file-handler is at run time as a require(). It's package.json appears to be correct : https://github.com/activescott/serverless-aws-static-file-handler/blob/main/package.json Doesn't list anything too odd. So I still don't understand why sls is packaging all the extra stuff in when it's installed (as non-dev, as intended and expected) |
npm ls -a snippit
|
So in this situation that's going to be the case - this plugin has a peer dependency on |
Could the plugin simply not declare any peer deps at all ? |
This is a question to plugin author, but it's a good practice to declare supported versions of Framework by peer dependencies. It's very unusual however, that the plugin has a part that is supposed to be required on runtime - 99.9% of plugins are required only as dev dependencies. |
I am the author of the serverless-aws-static-file-handler plugin. The plugin doesn't import or access serverless at runtime technically (only expects standard lambda/APIG payloads), but it seemed like a good practice to be explicit. Being explicit may be causing more trouble than its worth though. @pgrzesik do you have a recommendation or best practice based on your experience with other serverless plugins? |
Hello @activescott - first of all, thanks a lot for your work on the |
Thanks for your advice @pgrzesik! I’m this case it’s more appropriate to be a library so we’ll try removing the peer dependency. |
No problem @activescott - once again thanks a lot for being a part of community. I'm going to close this issue. |
…less as a peer dependency * Removes serverless as a peer dependency (see serverless/serverless#10863) * Deletes package-lock.json * fixes #139 Co-authored-by: Scott Willeke <scott@willeke.com>
Hey guys! When i push a commit with the only change in the
and the deployment fails due to the zip being too large ( If i then push a change, just setting
So it seems that there is really something going wrong? |
Grab the before and after .zip and compare. What's your package.json? Does your ci/cd start from scratch each time eg package-lock and node_modules wiped? Note that updating your runtime and not dependancies may be sub optimal anyway. What happens if you also bump all of them? |
Are you certain it's a bug?
Is the issue caused by a plugin?
Are you using the latest version?
Is there an existing issue for this?
Issue description
Node 16 with NPM 8 generates deployment packages far too big - >50meg
Appears to be including things like aws-sdk that are not required.
Exact sane project using Node 12 NPM 6 produces ~12meg
Service configuration (serverless.yml) content
N/A
Command name and used flags
serverless package
Command output
Environment information
The text was updated successfully, but these errors were encountered: