News for hackers. Stuff that matters.
Re:Changes to Npm's unpublish policy by jerf on Tuesday March 29, 2016 @02:08PM (#11383505)
So, fully serious and non-sarcastic question since I'm not a node developer, what is in that 673MB?
Re:Changes to Npm's unpublish policy by tlrobinson on Tuesday March 29, 2016 @02:20PM (#11383615)
It's mostly Babel and other build tools: https://gist.github.com/tlrobinson/1fba66be86f473ffe76312c32...

With npm every dependency gets it's own tree of dependencies, so there's tons of duplication.

Also, this is using npm 2. With npm 3 that's approximately cut in half since it tries to flatten the hierarchy as much as possible, but I haven't switched to npm 3 yet (seems slower and still somewhat buggy)

Re:Changes to Npm's unpublish policy by nostrademons on Tuesday March 29, 2016 @03:05PM (#11383995)
Babel seems to be a terrible offender as far as dependencies go. In my node_modules, babel-preset-es2015 takes up 200M - as you've noticed, each individual transformer has its own copy of the core Babel runtime.

And Babel was largely responsible for this whole left-pad fiasco in the first place: about 2/3 of left-pad downloads were through Babel.

The good news is that Node 6.0 is coming out next month, with V8 5.0, which supports 93% of ES6 natively. That means that most of the transformers can go away for server & Chrome code, with the appropriate Babel preset. And the big remaining ones - modules and async/await - are scheduled for Q2 2016, with work on modules already underway as of a couple weeks ago. So within a couple months, we may not need Babel at all anymore.

Re:Changes to Npm's unpublish policy by insin on Tuesday March 29, 2016 @07:36PM (#11385859)
It's specifically a Babel 6 problem - the way plugins are published means it now implicitly requires npm3.

Similarly, I had to bail on installing the 'victory' package (React visualisation components) using npm2 more than 600MB into it attempting to pull down its dependencies - I don't know if this is still the case, but every "victory-*" plugin was installing its own copies of Babel 6 and Webpack...

Re:Changes to Npm's unpublish policy by nilliams on Tuesday March 29, 2016 @05:03PM (#11384855)
Yes, if you only write JS for Chrome and Node, not sure how many JS devs fall into that bracket!
Re:Changes to Npm's unpublish policy by nostrademons on Tuesday March 29, 2016 @06:46PM (#11385589)
You also have the option of doing split JS bundles, using different Babel presets, for different browsers. Eg. for Chrome the only thing you need is module imports, but for Safari you use a preset that also includes destructuring, function defaults, etc.

This reduces the attack surface that a rogue Babel dependency has access to - instead of being able to pwn your server and all browsers, it can only pwn the browsers that use the particular transform that depends on it. It also can result in significant byte-size savings in the downloaded bundle.

Re:Changes to Npm's unpublish policy by jerf on Tuesday March 29, 2016 @03:04PM (#11383976)
"With npm every dependency gets it's own tree of dependencies, so there's tons of duplication."

That sounds like the missing bit of info.

If that is the primary problem, then the good news is that git actually ought to be able to re-de-dupe that stuff back down; checking it into git may not be as catastrophic as you'd initially think.

Re:Changes to Npm's unpublish policy by tlrobinson on Tuesday March 29, 2016 @04:07PM (#11384442)
Good point. If I add my node_modules to a new git repo it ends up being about 65MB, which is better, but still significant, and I imagine the overhead of tracking an additional 100,000+ files is non-trivial.
Re:Changes to Npm's unpublish policy by etblg on Tuesday March 29, 2016 @10:23PM (#11386542)
That also shouldn't be true in the latest npm, which uses a global node_modules and a bit of trickery for different versions of the same library, instead of recursive node_modules.
Re:Changes to Npm's unpublish policy by ceejayoz on Tuesday March 29, 2016 @02:57PM (#11383923)
In many cases, a bunch of useless stuff.

One of our devs added a material design webfont NPM package (IIRC, https://github.com/google/material-design-icons). Something like 40kb worth of font files, but the folder was 100+ MB because it included a PNGs of each icon at every imaginable resolution.

I've seen others with 10+MB CSV files used by the unit tests.

Re:Changes to Npm's unpublish policy by jakub_g on Tuesday March 29, 2016 @03:08PM (#11384023)
In such case you should send them a pull request with a proper .npmignore file which contains whole of .gitignore plus rules to not publish those PNGs