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

Reduce installed size in 2.x #3880

Open
gaearon opened this issue Jan 20, 2018 · 14 comments
Open

Reduce installed size in 2.x #3880

gaearon opened this issue Jan 20, 2018 · 14 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Jan 20, 2018

I noticed 2.x has regressed on the installed size

Before:

  • 109,142,603 bytes (172.7 MB on disk) for 23,707 items

After:

  • 135,452,954 bytes (216.4 MB on disk) for 29,913 items

You can check by creating a project with 2.0 alpha: #3815.

@wtgtybhertgeghgtwtg Is this something you could look into?

@gaearon gaearon added this to the 2.0.0 milestone Jan 20, 2018
@wtgtybhertgeghgtwtg
Copy link
Contributor

wtgtybhertgeghgtwtg commented Jan 20, 2018

As far as new dependencies go:

  • svgr adds 13 MB of unique dependencies, in part because it pins a version of jsdom that falls outside of the one jest uses.
  • uglifyjs-webpack-plugin adds 5 MB of unique dependencies. Part of this is because it uses cacache, which brings in a lot of new and undeduped packages, but mostly it's just because it uses a new version of uglify that isn't used by handlebars or webpack. webpack switches to the new version in webpack@4.

As far as updates:

  • jest grew a bit since jest@22, and the babel stuff in jest-runtime doesn't dedupe so well with babel-@7. I don't have numbers on the delta there.

@iansu
Copy link
Contributor

iansu commented Jan 20, 2018

It's unfortunate that svgr is so large. It may or may not stay in 2.0 though.

It would be really nice to have some kind of build size and install size check that ran automatically along with the other tests. Something like: https://github.com/apps/buildsize

@gaearon
Copy link
Contributor Author

gaearon commented Jan 22, 2018

Cold or warm build? First build will be slower because we compile node_modules now (people overwhelmingly want that). But warm builds should not be much slower (since that data would be cached).

@gregberge
Copy link

@iansu I plan to update JSDOM soon, issue is already opened smooth-code/h2x#8

@gregberge
Copy link

gregberge commented May 14, 2018

Done, you can upgrade to v1.9.2, it uses the last version of JSDOM and the version is not fixed. So it should solve your problem.

@iansu
Copy link
Contributor

iansu commented May 14, 2018

@neoziro That's great! Thank you. I'll make a PR to update this right away.

@iansu iansu mentioned this issue May 14, 2018
@bugzpodder
Copy link

bugzpodder commented May 25, 2018

I took a quick look and svgr and jest 22/23 seem to be the biggest culprit as they contribute ~15MB of unique dependencies in the latest build (probably thanks to jsdom)
since we control babel-plugin-named-asset-import it might be possible to put svgr as an optional dependency like we do for sass?
Also, the largest contributor is actually rxjs (19MB), and we only include it to show a user prompt via inquirer pacakge. I think we can probably find an alternative there.

@bugzpodder
Copy link

I think we can downgrade inquirer to 3.3.0 as it doesn't have rxjs dependency.

@gregberge
Copy link

I hope svgr is now sharing the same JSDOM as Jest.

@bugzpodder
Copy link

Yep:
=> Found "[email protected]"
info Reasons this module exists

  • "svgr#h2x-core#h2x-parse" depends on it
  • Hoisted from "svgr#h2x-core#h2x-parse#jsdom"
  • Hoisted from "jest#jest-cli#jest-environment-jsdom#jsdom"
    jsdom has a dependency on nwsapi which is like 16MB.

@bugzpodder
Copy link

svgr also has a dependency on prettier @neoziro
https://github.com/smooth-code/svgr/blob/master/package.json#L51
I guess most people installs that nowadays, but shouldn't it be a devdependency?

@gregberge
Copy link

Hmm yes, it is not required for webpack usage but it is for CLI, I have to think about it. It will probably come with the v2, i plan to move into a Lerna architecture. It will be easier to do it.

@Zirro
Copy link

Zirro commented May 27, 2018

@bugzpodder nwsapi 2.0.0 had accidentally been published without an .npmignore file. This was fixed in the latest release, bringing its size down to a more appropriate 74 K.

@styfle
Copy link

styfle commented May 29, 2018

FYI, you can visualize npm install size over time with Package Phobia 👍

For example [email protected]

Update: I realize now you were refering to react-scripts, d'oh 😆

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

No branches or pull requests

8 participants