-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Exclude non-essential files from published package (especially test/**) #277
Comments
They are in fact quite essential; they’re included by design. Duplicate of #258. Duplicate of #235. Duplicate of #207. Duplicate of #171. Duplicate of #180. See not just #82, but #149 (review), #132 (review), #128 (review), #59 (comment). I’d be happy to exclude appveyor.yml if those mere bytes (not 4K, that’s just the block size limits of your hard drive) are worth excluding. Excluding examples would be a breaking change, so we could do it in v2, i suppose - except that examples are ran as part of tests, so they’d need to remain. |
This doesn't seem like a valid reason for shipping test files in production. I've never once had a case where a user expected this to work, nor where I felt it would have been helpful. Bottom line: Test scripts just aren't something anyone expects to run as part of a production environment. In part because production environments often go through additional toolchains that will break this sort of thing. |
Sure - but the other bottom line is that package size doesn't matter in practice - what matters is the memory or bundle size of your program, and none of these files affect that. There's certainly tools that try to imply that package size matters, but this is just FUD. |
@broofa Very much agree. Jordan did not reference #235 where we had a longer discussion that was eventually not replied to. It seems that Jordan is very convinced despite reoccurring requests. I am back here checking on things because security scanning tools continue to crawl though this dependency and find issues. With such demand out there it would be helpful to provide community with the option to not get the overhead (which is not just about size). There could be two packages. One with just what is needed and another with whatever extras. |
@jason-ha thanks for that; i'll update the list to include that one also. |
@jason-ha if npm offered a way to have the "default" installation be minimal, and a "full" installation be something that could be opted into, i would absolutely do that immediately - but npm doesn't offer it. Having two packages would not solve anything because then I wouldn't have the "full" one installed when I suddenly find myself without internet and needing to test dependencies. Please feel free to file bugs on any security scanning tools that incorrectly flag these files. |
I will direct you to the #235 thread about the tooling. Reading through some related issues it is not just tooling my team uses that is impacted. It seems that two packages would very much solve the issue. In your use case of having everything, you would never reference the production only package. The other folks who never want to deal with the resolve tests as part of their production environment would never reference the "full" package. |
The problem is that I always want the full package, transitively. |
Either I am not understanding you or you are misunderstanding the proposal. Proposing a new package; let's call it |
@jason-ha I'm saying that even when The interest you highlight means that folks would switch to |
Please help me understand why you want the tests installed in all situations. I can understand there are packages you work with and would get to stick with It might be helpful to walk through the npm "default"/"full" scenario since you are saying that would work for you. What is a case now where I am also wondering if there may be a solution where tests are packaged apart from |
First of all, this isn't just for The problem is that my local npm cache is only guaranteed to contain what's in my projects' transitive dependency graphs. Thus, The problem is that I can't predict when I'll need npm could solve this potentially by allowing a package to have multiple "distributions", and then the minimal one would be the default, and I'd set an npm config value to always install the "full" one. However, short of that, this is the only practical approach. |
Definitely understand that is it not just I am not suggesting I was looking for "official" guidance on this question and NPMJS does recommend chucking things that are not required like test data. It also indicates that a smoke test is fine, but (a) that is not a whole test suite and (b) doesn't really say it is for use once installed. And elsewhere recommendation for testing a module is to create a test external to the package and see also here. It is not clear to me if you are completely opposed to the other solution I was wondering about where the tests are brought in via the install in package scope step. As far as I can tell that can meet your caching and offline requirements. |
My use case only works if everyone chooses the full package. That’s the problem. |
Please explain everyone. This project has 12.6M repos / 10k packages that depend on it. I don't see how you need every single instance of those uses to have full package. Can you help explore alternatives to the current pattern that resolve this issue for consumers and are acceptable for your situation? I want to encourage your "will try anything once" part of your profile. I see two possibilities right now (beyond the rejected two package "distributions") that don't require package manager features:
To the extent that I understand your use case, you can before going offline ensure your local git repositories are synced with remote. When you explore into package you will know the version and may grab all of the additional files from your local repository at the same version. Now you can test. You will even have the additional option to validate that what came installed matches your repository. |
Excluding the
test
directory from thenpm publish
ed files will shave ~75% off the size of the package.'Probably want to also exclude
appveyor.yml
andexample
.$ mkdir -p /tmp/foo $ cd /tmp/foo $ npm install resolve $ du -sh node_modules/resolve 4.0K node_modules/resolve/LICENSE 4.0K node_modules/resolve/SECURITY.md 4.0K node_modules/resolve/appveyor.yml 4.0K node_modules/resolve/async.js 4.0K node_modules/resolve/bin 8.0K node_modules/resolve/example 4.0K node_modules/resolve/index.js 52K node_modules/resolve/lib 4.0K node_modules/resolve/package.json 12K node_modules/resolve/readme.markdown 4.0K node_modules/resolve/sync.js 304K node_modules/resolve/test
The text was updated successfully, but these errors were encountered: