HACKER Q&A
📣 jdthedisciple

Why does React need 1484 dependencies by default?


Run

    npx create-react-app my-app
and watch how it says

    added 1484 packages in 1m
How in the world can this number of dependencies be considered sane and normal, and most of all, necessary?

What's more is that this barebone source code already takes up 235 MB (!)

What the ...? Is this what it takes to display some rectangles and glyphs in a browser?


  👤 whatamidoingyo Accepted Answer ✓
That's not _React_, that's `create-react-app`, which was built long ago, and isn't really used so much today for starting new projects (for obvious reasons). (In fact, it's considered deprecated)

Check out Vite: https://vitejs.dev/

`npm create vite@latest`

run through the process

--> `added 217 packages`


👤 shich
While dependencies can provide convenient functionality, the JS ecosystem has tended towards excessive granularity. Many packages contain limited code yet still require a large number of dependencies .. sometimes because of tooling (as in the example in the post here), but quite often out of convenience!

Rather than hastily installing the latest shiny package, we should refactor and build reusable minimal utilities tailored to our domain.


👤 praet
Create-react-app has a whole bunch of extra stuff, like a testing library, various styling engines, HMR and other build tools that aren't included in your deployed code anyway.

Production React, on the other hand, appears to only have 2 deps: js-tokens and loose-envify


👤 super256
That's not React. The stuff you need for "displaying some rectangles and glyphs in a browser" is "react" and "react-dom".

Those 1484 packages are simply for the build step. And having a lot of dependencies in a build tool isn't necessary "insane".


👤 he11ow
According to the latest Stackoverflow developer survey, 40% of developers use React, well above any other web framework. (42% for "professional developers").

It doesn't answer to your question, but it does answer to mine on these flexes in HN around niche frameworks and the difficulty of putting them into context.

I'm glad people are working on alternative solutions, and maybe ten years from now everyone will be using something else. But right now, 235 MB is an awfully small price to pay for something that just works, especially as a lot of it doesn't actually show up in deployment.


👤 kristianp
It does seem insane. Lots of small dependencies upon dependencies exponentially multipy

👤 tracker1
I'd probably start with vite or parcel, vitest and biome. This is for build, test, formatting and linting.

Otherwise,. Just use HTMX if you want to minimize your JS footprint.


👤 rabbits_2002
That is create-react-app not react itself but I agree webdev has reached a point of schizophrenia regarding dependencies and performance.

👤 meiraleal
Because react (and create-react-app, nextjs and alike) is terrible, old, badly maintained.

👤 al2o3cr

    How in the world can this number of dependencies be considered
    sane and normal, and most of all, necessary?
Wait until you find out how many parts are inside an internal combustion engine.

👤 dalmo3
It's the same reason as why it's so slow: the shadow DOM. The shadow DOM consumes 80% of that disk space. 49% is dedicated to box-shadow alone.