Skip to content

Slim Dependencies #1183

Description

@wtgtybhertgeghgtwtg

Based on a previous discussion.
This is a short list of some of what can be done to reduce some of the larger items that increase the overall size of react-scripts. Excluded are smaller, opinionated, or rejected fixes.

Activity

  1. gaearon commented on Dec 6, 2016

    @gaearon
    Contributor

    Amazing investigation, thank you.

  2. wtgtybhertgeghgtwtg commented on Dec 8, 2016

    @wtgtybhertgeghgtwtg
    ContributorAuthor

    Another thing that might help would be trying greenkeeper to keep things up to date. There's an issue with babel I am noticing.

    1. react-scripts requires babel-core@6.17.0.
    2. babel-core requires babel-register >= 6.16.0. Since the latest is babel-register@6.18.0, it grabs that.
    3. babel-register@6.18.0 requires babel-core >= 6.18.0, but we only have babel-core@6.17.0 locally, so it has to grab another copy, babel-core@6.18.2.

    Assuming this isn't just a program with my machine, I think you can run yarn list babel-core to see this. If not, please correct me.

  3. wtgtybhertgeghgtwtg commented on Dec 14, 2016

    @wtgtybhertgeghgtwtg
    ContributorAuthor

    And I don't know why I'm just now noticing this, but since the version of fbjs that react upon depends on a different major version of core-js than Babel and Friends, that is not deduping properly, either. Once react bumps to at least fbjs@0.9.0-alpha.1, it should save something like 1 to 14 megabytes, depending on how yarn dedupes it. Although I'd imagine that fbjs@0.9.0 would have to come out of alpha first.

  4. gaearon commented on Jan 3, 2017

    @gaearon
    Contributor

    Also interesting: apparently installed size is larger with Yarn? https://twitter.com/petrhurtak/status/812356423795568640

  5. wtgtybhertgeghgtwtg commented on Jan 3, 2017

    @wtgtybhertgeghgtwtg
    ContributorAuthor

    I think that's because of how yarn and npm dedupe things. The most obvious example would be with core-js; fbjs requires one version, babel-runtime requires another. Installing npm only leaves two copies of core-js, but yarn seems to install a copy in every directory that requires babel-runtime.

    You can see this by going to the babel-generator folder under node_modules; when installed by npm, it should not have a node_modules folder, when installed by yarn, it should have one with .bin, babel-runtime, and core-js.

  6. tbillington commented on Jan 4, 2017

    @tbillington

    Can confirm that yarn size is between 20-50% larger and the same % increase in total number of files due to the structure under yarn.

  7. mmrath commented on Jan 26, 2017

    @mmrath

    Instead of react-scripts I used react-scripts-ts, node_modules folder was 137MB instead of 561MB

  8. Daniel15 commented on Jan 27, 2017

    @Daniel15
    Contributor

    but yarn seems to put minimatch@3.0.2 in the base node_modules folder while placing minimatch@3.0.3 in the node_modules folders of babel-core, eslint-plugin-import, glob, fstream-ignore, multimatch, readdirp, and sane, meaning the same version of a ~30 KB dependency is copied six times over.

    yarnpkg/yarn#2306 should help with that, once implemented!

  9. JaKXz commented on Jan 29, 2017

    @JaKXz
  10. gaearon commented on Jan 29, 2017

    @gaearon
    Contributor

    Instead of react-scripts I used react-scripts-ts, node_modules folder was 137MB instead of 561MB

    This is likely because you have Yarn installed, and Yarn has a bug.
    This will be fixed in next release: #1397

  11. wtgtybhertgeghgtwtg commented on Feb 5, 2017

    @wtgtybhertgeghgtwtg
    ContributorAuthor

    acorn-globals now uses acorn@4.0.8, as does jsdom. However, I noticed that espree depends on a specific version of acorn (acorn@4.0.4), so there are still three versions required.

  12. benjaminapetersen commented on Feb 8, 2017

    @benjaminapetersen

    Somewhat related, I was a bit alarmed at my first run of create-react-app yesterday, when I checked the size of my node_modules folder and found 179,491,959 bytes (556.6 MB on disk) for 110,557 items. 556MB is quite a lot!

    I was looking for a light-weight way to get up and running with react, ideally to spin up a handful of hello-world apps locally for running through tutorials, etc. Over half a gig does discourage creating a number of quick little prototypes.

    I'm new to the react world though, so perhaps there is a good resource for doing this!

  13. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

    @benjaminapetersen

    This is a different issue and caused by Yarn bug: #1397. We'll work around it in 0.9.0.

  14. benjaminapetersen commented on Feb 8, 2017

    @benjaminapetersen

    Indeed it is! Nuked the node_modules directory & reinstalled w/nmp instead of yarn, dropped to 72,495,611 bytes (131.7 MB on disk) for 1,922 items

    131MB is a lot easier to swallow than 556MB.

  15. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

    This is why you should be careful adopting new tech 😉

  16. wtgtybhertgeghgtwtg commented on Feb 21, 2017

    @wtgtybhertgeghgtwtg
    ContributorAuthor

    jest@19.0.0 has been released, which contains the node-notifier bump. It's also about a megabyte smaller.

  17. mhart commented on Mar 14, 2017

    @mhart

    You can take a high-level view here: http://pkgsize.com/react-scripts.html

    jest, webpack, autoprefixer and eslint are the four largest contributors.

    autoprefixer largely due to the ever increasing caniuse-db: http://pkgsize.com/autoprefixer.html (is autoprefixer really a must-have?)

    jest mostly due to jest-cli mostly due to jsdom stuff and istanbul-api: http://pkgsize.com/jest-cli.html

    ... and they all include a whole bunch of babel libs – of which core-js makes up a large part: http://pkgsize.com/babel-runtime.html

  18. gaearon commented on Mar 14, 2017

    @gaearon
    Contributor

    I wonder how this compares to master since we switched to webpack 2 and might have new regressions (or it might be better). We should cut a canary release.

  19. JaKXz commented on Mar 14, 2017

    @JaKXz

    FWIW a PR has been filed for browserify-zlib: browserify/browserify-zlib#22

  20. wtgtybhertgeghgtwtg commented on Mar 14, 2017

    @wtgtybhertgeghgtwtg
    ContributorAuthor

    jest, webpack, autoprefixer and eslint are the four largest contributors.

    jest has an issue similar to this one. You might be able to get webpack and eslint interested if you asked.

    autoprefixer largely due to the ever increasing caniuse-db: http://pkgsize.com/autoprefixer.html (is autoprefixer really a must-have?)

    It's gonna be there anyway, since cssnano depends on it.

  21. gaearon commented on Jan 8, 2018

    @gaearon
    Contributor

    I'll close this as stale. (But efforts to further dedupe are welcome!)

  22. locked and limited conversation to collaborators on Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions