eslint-plugin-react icon indicating copy to clipboard operation
eslint-plugin-react copied to clipboard

Reduce install size by 30%

Open developit opened this issue 3 years ago • 12 comments

Hi @yannickcr! I'm working on reducing the disk usage of a typical ESlint setup, and found a couple cases where this plugin can be slimmed down with no functional impact:

  • Object.entries is supported in Node 6+ and does not need to be polyfilled.
  • Object.fromEntries is supported in Node 12+, and its usage here is minimal enough that an inline shim suffices.
  • Array.prototype.includes is supported in Node 6+
  • Object.values is supported in Node 7+

developit avatar Dec 14 '20 16:12 developit

Why would this plugin have any reason to support Node 4 when ESlint itself only supports Node 10+? That's a lot of baggage for no discernable gain.

developit avatar Dec 14 '20 16:12 developit

Because it also supports down to eslint 3, which supports node 4. The gain is backwards compatibility, and avoiding a semver-major bump.

ljharb avatar Dec 14 '20 16:12 ljharb

Have you evaluated the performance and disk usage tradeoff this is inherently making, or is this a purely philosophical stance?

developit avatar Dec 14 '20 16:12 developit

It's a dev tool; install speed impact is negligible and disk usage is irrelevant.

ljharb avatar Dec 14 '20 16:12 ljharb

I'm not sure that viewpoint is broadly shared. Developers have hundreds of projects on a machine, and this one is just under 8mb. Anecdotally, eslint-plugin-react accounts for more than 1GB of disk usage on my machine.

developit avatar Dec 14 '20 16:12 developit

I have almost 500 projects on my personal machine that are fully npm-installed, a handful of them using eslint-plugin-react, and the total size of the entire dir that holds them (including .git and node_modules and the actual code) is around 20GB, which is minuscule - anecdata is tricky :-/

If the goal is to take up less disk space, I'm happy to discuss ways to do that on those polyfill repos - that would have far greater impact than removing them from one eslint plugin.

ljharb avatar Dec 14 '20 17:12 ljharb

That seems like a reasonable plan - I don't have exact numbers on the % impact of the polyfill repos, but estimating based on packagephobia seems to indicate they're at least 50% of the disk usage of this plugin.

developit avatar Dec 14 '20 17:12 developit

Here's a number for one included polyfill. 3.39mb. Would be good at least to not have duplicated monstrous packages. Would be good to not pay for theoretical users of eslint 3 and node 4. https://packagephobia.com/[email protected] https://packagephobia.com/[email protected]

TrySound avatar Dec 23 '20 13:12 TrySound

Maybe releasing library major version every 10 major version of node.js would be "stable enough". @ljharb how long do you plan to support node v4?

chyzwar avatar May 20 '22 19:05 chyzwar

Are there stats somewhere on the actual users of ESLint 3, node.js 4 that need the latest eslint-plugin-react for React 18 ?

I understand that people could be using older versions of ESLint and node.js, but supporting runtimes that were released 7 years ago seems a bit overkill. Even more so that for people stuck on old versions of ESLint and node.js are also probably stuck on React 0.14

Releasing a new major version of eslint-plugin-react would still allow these people to use the previous major version for their use case.

onigoetz avatar May 20 '22 19:05 onigoetz

@onigoetz react 18 works just fine on ancient versions of node, so that assumption doesn't hold. Also, the instant we shipped a bugfix or a new feature, the folks stuck on the previous major would be left in the lurch. That's a high cost, compared to the virtually zero cost of "a few extra packages".

@chyzwar i maintain over 300 packages that still support node 0.4. So, "how long"? Probably forever.

ljharb avatar May 21 '22 17:05 ljharb

True, maybe it would suck /if/ those people are actually using Node 4 and ESLint 3

On another hand, your package has 12'500'000 downloads a week, according to packagephobia, one install is 3.77MB (Unzipped, so let's say half that when transfered)

Which means (3.77/2)*12500000 = 23 562 500 MB = 23.5625 TB

In other words, this PR is proposing to shave off 7.8 TB of data transfer per week.

Here is an article written by chokidar's maintainer Paul Miller on how the newest version is massively smaller and the implications of that size : https://paulmillr.com/posts/chokidar-3-save-32tb-of-traffic/

onigoetz avatar May 21 '22 19:05 onigoetz