I agree with this question. If I were to check the source code of every dependency in my node_modules and use a lock file, it would be great if I could feel confidant that this is the code I'm executing.
Having to read minified code to review dependencies is, well, stupid. This feel like a flaw in npm. I would prefer if npm never used minified code, but the source code instead. If that's not possible because of backwards compatibility, adding a flag like --no-minified could probably solve it.
That would be pretty hard for npm to enforce -- minified javascript is just javascript with short variable names, no extraneous whitespace, etc. Who's npm to say whether e.g. a function with a 1-letter name is there because the code is minified, or just there because that's what someone happened to write?
Yes, you're right, that's not possible. What I was thinking about was that there shouldn't be a difference between the code on github and the code published to npm. In that case the minified code should be uploaded to github, so that anyone that reviews the code on github should see the minified code. That's totally fine. The problem is that it's totally fine to upload something else to npm then github (minified code for instance).
There's a difference between minification and variable mangling. Generally they are done together, but you can minify javascript without mangling, or mangle without minifying.
16
u/samjmckenzie Nov 27 '18
Why are minified libraries published onto npm? Is this standard practice?