So I am trying to build my first react component library. My library is using flowbite
and also react-icons
. I've done some reading on the differences but I still am not sure where do these go.
I want to say just normal dependencies no? As they are actually needed to build my components when my client would use the library? Not sure about it though?
Asked
Active
Viewed 49 times
0

Tsabary
- 3,119
- 2
- 24
- 66
1 Answers
1
If you import and use them in your production code(ie should be included to your bundle) - it goes to dependencies.
Otherwise, if it's needed for building, webpack, tests, storybook stories, typing, linting and stuff like that - it's devDependency
UPD: Here's small cheatsheet:
- I use some library in my sources and I want it to be included to my bundle - dependencies
- I use some library in my sources BUT I don't want it to be included to my bundle(leave it to the end user) OR I know that end user will have this library anyways - peerDependencies
- I use library as a tool to run/check/build bundle(lint, test, storybook) and everything that will not go to the production code - devDependencies

PepperoniSquat
- 54
- 6
-
I think what confuses me, as this is the fist time I am building a library, is at what point do the the `flowbite-react` components for example, get translated to js? Does it happen when I bundle my package, meaning my client would already get these components as simple js, or dos my client also needs to have `flowbite-react` installed, as it will be their code that'll need to "translate" the ocmponent to regular js. Hope the question makes sense. – Tsabary Jun 09 '23 at 14:30
-
Your client will have to install flowbite-react if you will have it as a peerDependencies. As far as I remember if peerDependency is not installed then npm will do it automatically for you. So I guess you're fine unless you'll not move those to peerDependencies. Everytime you'll run watcher or build your bundle flowbite-react will be there in your bundle(imported and translated to whatever your compiler is set up to). – PepperoniSquat Jun 09 '23 at 14:38