Skip to content
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

Sheer size #3508

Closed
gaving opened this issue Nov 1, 2016 · 13 comments
Closed

Sheer size #3508

gaving opened this issue Nov 1, 2016 · 13 comments

Comments

@gaving
Copy link

gaving commented Nov 1, 2016

mapbox-gl-js 0.26:

Am I missing something, or should a npm install mapbox-gl in a directory result in a ~1 gig node_modules folder and ~5 minute install?

Steps to Trigger Behavior

  1. npm install mapbox-gl

Expected Behavior

Reasonably quick npm install, sensible size.

Actual Behavior

Gives my relatively recent MacBook a heart attack, fan slams on and unibody becomes a 80 degree heatsink.

ncdu on node_modules shows the bulk of it under the documentation/gl folders.

screen shot 2016-11-01 at 19 17 40

@tmcw
Copy link
Contributor

tmcw commented Nov 1, 2016

Since documentation is at the top of that list, I did some research and the result is... puzzling: documentationjs/documentation#583 - npm installs the core-js module for every single babel transform. 84% of the install is duplicate core-js modules. That's assuming npm v2.x. yarn, on the other hand, installs documentation in 46MB, instead of 372MB of space.

Likewise, with mapbox-gl-js

  • 897M - npm v2
  • 485M - yarn

The conclusion here is that, for large projects, it's looking like npm v2 is insufficient and we all need to switch to yarn or npm v3.

@mourner
Copy link
Member

mourner commented Nov 1, 2016

Yes, this is unfortunately an issue with NPM2 and the way it duplicates dependencies. It leads to huge sizes in any projects that use Babel, which is broken down into tons of tiny reused modules. There's nothing we can do about that on GL JS side, so I have to close the issue.

For Headless GL size, I filed stackgl/headless-gl#83 earlier.

@mourner mourner closed this as completed Nov 1, 2016
@gaving
Copy link
Author

gaving commented Nov 1, 2016

@tmcw @mourner Should have added that I'm on [email protected], I'll give yarn a go, though.

Woah, yarn's night and day coming in at 42meg total.

@mourner
Copy link
Member

mourner commented Nov 1, 2016

@gaving wait, I thought you were talking about npm install in mapbox-gl-js directory... Why are devDependencies installed when you do npm install mapbox-gl? Are you sure your NPM is configured properly? It shouldn't normally install dev dependencies in this case.

@gaving
Copy link
Author

gaving commented Nov 1, 2016

@mourner This is just adding mapbox-gl dependency to a project, so not within a mapbox-gl-js folder.

Isn't the default of npm install to install dev dependencies? --production or --dev flags are used to differentiate between the two.

Edit: Looks like there's an --only flag now https://docs.npmjs.com/cli/install

@mourner
Copy link
Member

mourner commented Nov 1, 2016

@gaving no, the flags are for running npm install in a directory without specifying a package. devDependencies of a package shouldn't be installed on npm install package, which is documented in https://docs.npmjs.com/files/package.json#devdependencies.

@gaving
Copy link
Author

gaving commented Nov 1, 2016

@mourner Seems that isn't the case anymore with npm@3, check out: https://docs.npmjs.com/misc/config#production

production from npm config get production is set to false here with no configuration on my end.

@gaving
Copy link
Author

gaving commented Nov 1, 2016

Or maybe that just applies without specifying a package name as you've already said, I'm so confused.

All I know is what is happening in my original report, I don't think I've any weird configuration going on unless my npm is busted somehow.

@mourner
Copy link
Member

mourner commented Nov 1, 2016

¯_(ツ)_/¯ NPM3 is very buggy, no idea what triggers this for you. I'd recommend trying out Yarn. It hasn't matured yet, but it's already better than NPM in every way.

@gaving
Copy link
Author

gaving commented Nov 1, 2016

Yeah I'll stick with yarn, I'll follow-up if I manage to work out what the deal is with npm.

Cheers!

@mourner
Copy link
Member

mourner commented Nov 1, 2016

@gaving we found out what's going on — it's an NPM bug that makes npm install mapbox-gl install devDependencies. This should be fixed in the next release (to be out in a few days) because we removed npm-shrinkwrap in #3377.

@gaving
Copy link
Author

gaving commented Nov 2, 2016

@mourner Ah good to hear, I glanced over that other related/closed issue actually but didn't see the relevance due to the shrinkwrap mention.

Glad there isn't something mental with my setup!

@gaving
Copy link
Author

gaving commented Nov 8, 2016

Should this work as expected now on the latest version of npm? It's is still giving me headaches even on the latest version (I can't use yarn at work due to other issues).

I've stuck a minimum Dockerfile reproducing the issue here:- https://gist.github.com/gaving/eae05782b9bd5e791e320c26a7e9788e

As you can see, still a ginormous 700meg build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants