tjtanjin / react-chatbotify

A modern React library for creating flexible and extensible chatbots.
https://react-chatbotify.com
MIT License
217 stars 121 forks source link

[Feat] Styleless Build #276

Closed mariovalney closed 1 week ago

mariovalney commented 1 week ago

Hey! How are you? First of all, I want to say thanks for the code: it's a amazing chatbot solution (and the docs is superb).

Is your feature request related to a problem? Please describe. Due to some frameworks being incompatible with importing CSS on external modules (#79 / #80) would be nice to have a "styleless" version of library. I know it's not a trivial case to not use the default CSS but developers would be allowed to import as needed too.

Describe the solution you'd like Just a "index.nocss.js" version in dist folder.

Describe alternatives you've considered The issues have workarounds but this solution is not too cost too.

Additional context I would be happy to make a PR.

tjtanjin commented 1 week ago

Hey @mariovalney! Thank you for the kind words 😊

With regard to the CSS import issue, the library actually started out requiring all developers to import the css file manually. From v1.5.0 onwards, manual importing was no longer necessary as the library handled it. This update was made because: 1) Less stuffs for users to do, less mistakes 2) The library needed the css file to work correctly, might as well the library import it 3) Makes a simple thing even simpler 😊

That said, I'm aware it caused issues for NextJS users who are using pages instead of the app directory. From what I've gathered, these are the only users affected because of how pages worked. This caused issues with quite a number of libraries and the app directory is suppose to overcome this limitation (and is also the encouraged way forward).

With that in mind, it felt a little unnecessary to solution for an approach that will eventually be "outdated". Adding an extra index.nocss.js and exporting it is a simple and viable solution, but some concerns come to mind: 1) Potential for confusion (unknowing users may make use of the wrong imports) 2) Significant increase in package size (even if unused parts are tree-shaken, developers may perceive a larger library size negatively)

Taking into account that there are existing workarounds to get things to work, there wasn't really a strong reason to take on the cons of adding an extra solution. After all, the recommended approach forward for NextJS users is the app directory as well and we adopt the same recommendation for users facing import issues. This is probably not a satisfactory answer but I hope it sheds some light on the situation 🥹

mariovalney commented 1 week ago

Thank you for the detailed explanation and context!

I understood that app directory being the encouraged approach, but it’s worth noting that NextJS itself allowed a gradual transition from pages to app precisely because it represents a significant paradigm shift.

Given this, I thought it might be interesting to explore a solution, and since I’ve already created an example, you’re welcome to check out the link if you change your mind: https://github.com/tjtanjin/react-chatbotify/compare/main...mariovalney:react-chatbotify:feat/276-nocss-build

Anyway, thanks for your time!