-
Notifications
You must be signed in to change notification settings - Fork 14
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
Potential size reduction for npm distribution #19
Comments
Thanks for the idea! I must admit that I am new to node and npm. If minified...would it only be the minified code in the |
Yeah, it would. Your code on GitHub would still be the unminified development code, but the code that users have in their node_modules folder will be minified |
Can all of the dependencies be minified too? Or does that need to be done by each package owner? |
It has to be done by the package owners but most owners distribute their minified package. |
Fair enough. I do agree that this takes a long time to install! I wonder how much minifying will impact that. Though that rational is likely the problem in the first place :P I will certainly keep this in mind. I wonder if there are any good articles on it. |
@Jameskmonger there's several reasons I think this isn't worth it:
|
@jedwards1211 Most packages I've seen are distributed over npm with only minified code - bugs that occur can then be investigated with the full code, but the majority of users never need to debug it at all. Could you point to some packages which don't slim down their distributions? |
Huh, I'm surprised you say that, because I can't remember the last time I've seen a package like that. These popular packages are distributed with unminified code:
|
That's odd, I've just looked into how React does it (only one I had already installed for a project) and you're right. However I don't think that they're doing it in the best way. npm is a distribution platform to distribute packages to be used as they are distributed. I think that if a user wants to then go on to debug a package, they are obviously free to clone the github repo, but I think the distributed package should be as small as possible to reduce the footprint. |
What do you mean by this? NPM isn't a CDN. And even on CDNs, most projects I've seen distribute non-minified code alongside minified code. I know in the case of React, it's distributed with If you're concerned about slow |
I agree that it would be cool to make this smaller. Though I also think that npm and the way it downloads a tree of dependencies will always be slow. Minifying may not really add gains in terms of install times when considering the deps. Those definitely need reducing though. With this type of tool I'm not sure anyone will really need to edit the installed version. I'd really like it to become stable and not try to do too much. If this overall pattern gets distilled it would be cool to rewrite it in something like GO so that it really could just be a binary that you download quickly as part of a CI process. |
The other thing about this is that (I assume at least) it's not really intended to be used as a dependency of anything else. I would be more concerned about |
I've never actually come across any big issues with package size @jedwards1211 - I'm just aware that it could cause issues with people who have significantly slower connections (developing countries for example) |
It could be better to minify the code as a prepublish npm command into a distribution folder (
dist
?) which is then included in thefiles
property ofpackage.json
, rather than the unminifiedlib
folder.This change could make a slight difference in the size of the distribution.
The text was updated successfully, but these errors were encountered: