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

Why does every colour have its own Github repo? #1

Open
Daniel15 opened this issue May 2, 2016 · 8 comments
Open

Why does every colour have its own Github repo? #1

Daniel15 opened this issue May 2, 2016 · 8 comments

Comments

@Daniel15
Copy link

Daniel15 commented May 2, 2016

It seems a bit excessive. Surely every colour could live in a single repo?

@jonschlinkert
Copy link
Owner

Are you really asking or did you open this to tell me your opinion? If you do in fact want to know, I can give you 5 reasons.

@Daniel15
Copy link
Author

Daniel15 commented May 2, 2016

I'm really asking. Curious as to what the advantages are.

Actually I have two questions:

  1. Why does every colour have its own Github repo?
  2. Why does every colour have its own npm package?

@jonschlinkert
Copy link
Owner

Okay, thanks for clarifying, totally legitimate questions. I'll add an answer here in the next day or so.

@RusinovAnton
Copy link

Still waiting... yawn

@cspshadx
Copy link

Seems the the truth is out there 😮 who knows ... 😆

@jonschlinkert
Copy link
Owner

jonschlinkert commented Sep 29, 2016

yes, the truth is indeed out there ;)

I prefer using micro-libraries that do one specific thing. I see no reason why I'd need any more justification than that. But if I'm honest, I always look for ways to optimize our projects, and with these module in particular I was doing a sort of anecdotal experiment. Around the time that I created these I was doing a lot of code coverage stuff in our projects and it occurred to me that probably 85% to 95% of the code in the dependency tree of any project would never, ever be executed.

I'd love to find out some real stats about this someday, but as a really basic test I came up with the idea of breaking these into modules so that I could use NPM's download stats to tell me how much each color was actually used over time. IMO ANSI colors are a decent test case for this because there are a number of libs - like chalk, which has 6 dependencies in its tree, a huge API surface with 25+ methods, takes 8-12ms to load, and it's likely that only one or two colors are used in any given project. This won't tell us how much the actual methods are called, but at least it shows how much of the API is used in a digestible way.

Here is what I found in case you're curious (this is a snapshot of the downloads for these libraries at the time this question was asked):

ANSI module Total downloads Percent of total
ansi-wrap 12,764,621 0.486%
ansi-green 12,321,412 0.469%
ansi-red 418,960 0.016%
ansi-cyan 202,887 0.008%
ansi-yellow 112,031 0.004%
ansi-bold 38,646 0.001%
ansi-bgred 28,587 0.001%
ansi-gray 28,099 0.001%
ansi-magenta 23,141 0.001%
ansi-underline 18,313 0.001%
ansi-dim 17,913 0.001%
ansi-bgblue 17,913 0.001%
ansi-inverse 17,908 0.001%
ansi-hidden 17,908 0.001%
ansi-white 17,907 0.001%
ansi-reset 17,902 0.001%
ansi-black 17,902 0.001%
ansi-bgwhite 17,901 0.001%
ansi-bggreen 17,896 0.001%
ansi-strikethrough 17,891 0.001%
ansi-blue 17,890 0.001%
ansi-bgblack 17,887 0.001%
ansi-grey 17,883 0.001%
ansi-bgcyan 17,883 0.001%
ansi-bgyellow 17,865 0.001%
ansi-italic 17,860 0.001%
ansi-bgmagenta 17,860 0.001%

It's even more asymptotic than I expected. But that's it. Nothing complicated.

edit: so the bottom line is that, since ~96% of projects only use one color, we can now require that color in directly and only get one extra dep and 1ms load time, versus 6 addl deps with chalk and 8-12ms load time

@Daniel15
Copy link
Author

Thanks, interesting explanation. That still doesn't explain the separate repos though - It just explains the separate npm packages 😛

@jonschlinkert
Copy link
Owner

It explains both. I don't see why it would be inferred that an npm repository wouldn't === a github repository.

Repository owner locked and limited conversation to collaborators Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants