KaiHotz / react-rollup-boilerplate

Boilerplate for creating React component libraries, bundled with Rollup.js to ESM and/or CJS Modules, Storybook, Typescript
https://kaihotz.github.io/react-rollup-boilerplate/
MIT License
300 stars 67 forks source link

Error if I want to import a specific component #40

Closed franmc01 closed 1 year ago

franmc01 commented 1 year ago

Works!! import { Button } from 'react-rollup-boilerplate'

Get ERROR :( import { Button } from "react-rollup-boilerplate/button"; import { Button } from "react-rollup-boilerplate/dist/components/button";

The problem that I currently see is that to use a component I must call it from the root but let's say if I have a library of 50 components, if only one button is going to load the entire lib and that is not good for the final bundle. Another little thing that is not clear to me is the issue if the styles are injected into each component, that is, when importing the button, only the button styles are loaded

KaiHotz commented 1 year ago

@t1fmarin thanks for pointing this out and for using my boilerplate. This should be resolved now. In case this still exists, you can always adjust the exports as well as the rollup config to your needs. Just a friendly reminder that this is just a boilerplate that i maintain actively on my free time. Any specific needs or customisations are up to your personal preferences and needs

franmc01 commented 1 year ago

Thanks for listening, I just have a question; that is, does the lib now allow you to export specific components?

KaiHotz commented 1 year ago

like i said, this is just a boilerplate to get you started. If you have the need to export specific components you might want to read about rollup configuration options, and then do the necessary changes in the rollup.config.mjs file, specifically in the input and output option.

This boilerplate does not resolve all the specific needs for all the use cases, but instead gives you a very comprehensive starting point to write your own library