Cool, so that's the first question we covered, and it pretty much led to another dozen or so questions, but I'm hoping that you have a better understanding about the kind of introspection that you need to do if you want to start building your first component library.
So the next question we're going to look at is whether to export your library as a single package or as scoped packages. And so what do I mean by this?
Well, if you've used component libraries in the past, maybe Material Web, you will know that if you run npm install Material Web or whatever component library, you'll have access to the entire component suite, and this is really useful as a consumer because if you're consuming this kind of component library, then you just need to run the update script against one package to get the latest version of all the components. You can easily look at the changelogs.
And if you're managing the component library yourself, it's way easier to just manage a single version and then publish a single version. For this, and I'll contrast this with scope packages, and this might, well, this is like a Radix UI where you might want to use, say, their select menu and maybe their popover menu components, and so you would need to run npm install Radix UI, select menu, and then npm install Radix UI popover. So installing a single package gives you access to a single component. And so this is useful if you just plan to use, say, a single, one, or two, or very, very small number of components from a given library.
And I've got an asterisk here about reducing bundle sizes, which is kind of maybe not strictly true, which I touch on a little bit later, but as a component author or a library author, you have a lot of flexibility as to how you version and publish them. You can publish them, version them independently so each component has its own version, or you can version them together so that whenever you release, you bump the version for all of them and maybe only some of the changes, only changes are made to some of those components. And we'll talk a little bit about that latter option in a second, because I find that really annoying as a consumer. I've worked with independent packages that were versioned together.
And even though the Gatsby plugin system wasn't necessarily like a component library, what you would, if you've built with Gatsby in the past, you would probably use a dozen or so of these different first party plugins, and they were all versioned together against the same version. And so what would happen is if you went away from your computer for a couple of weeks, came back and tried to upgrade your dependencies, you'd see a whole list of Gatsby plugins that needed to be updated, and so when you go through each change log, because I don't like just upgrading everything and hoping for the best, you'd often see this, like version bump, version bump, version bump, version bump, oh, slight change to the readme, version bump, version bump. And you would have to do that across a dozen or so, if not more, packages. So that's a bit of a pain. But it's not so bad if you're using a small number of components and they're versioned independently.
Now, as a publisher, I have actually dealt with publishing scope packages. And I talked about my A2K component library a little earlier on. And to be totally honest, it was a mistake and I regret it massively. So the purpose of A2K was to let people build an entire interface using a suite of retro style components. So why would I make my developers or my consumers install each component individually? It just makes no sense. If they plan to use A2K to build an interface, they're probably likely to use all of the components. So making someone install 12 components is absolutely kills the X and increases friction. And I'll probably say adoption would have been a bit higher if I published everything as a single component. On top of that, managing independent versions is a bit more complex. So you need to set up your repo like a model repo. They need to have a specific workflow so that you can publish components as they change and make sure that the versions are incremented based on the change.
Comments