-
-
Notifications
You must be signed in to change notification settings - Fork 728
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
Only publish required files #389
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All files are required - npm explore foo && npm install && npm test
should always work.###
"files":[ | ||
"dist", | ||
"lib" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files
field is dangerous; it means needed files could be accidentally omitted. The only danger of .npmignore
is that an unneeded file is unnecessarily included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed the npm ignore file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np, unfortunately npm's own docs recommend "files", but it's the more dangerous approach.
Separately, "cold start time" is a runtime concern, and excluding files from the published tarball has no bearing on cold start times - only (imperceptibly) on install times. |
Thanks for the quick reply and detailed explanation. Everyone should be bundling their code in which case it doesn't have an impact on cold start time as you stated above. However, this isn't always the case and people package up everything and ship it. Will an extra 1-3kb make a difference, of course not, but when 100s of packages have extra file, they can add up to MB which can impact cold starts in my experience. I'm mostly trying to micro optimize for those less experienced developers that end up using middy.js v2. Thanks for taking the time to review. |
I'm not talking about bundling - files on disk that are never required hav e zero impact on start time, because they're never touched. It is, quite simply, impossible for a cold start to be impacted by unused files, unless you're including |
See https://docs.npmjs.com/cli/v6/configuring-npm/package-json#files for details. Every little bit to improve lambda cold start times.