cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.06k stars 397 forks source link

react-jss depends on all jss plugins even when not using them #1539

Open Paitum opened 2 years ago

Paitum commented 2 years ago

Expected behavior: Using react-jss should not require bundling all jss plugins used by the jss-preset-default.

Describe the bug: When creating a custom JSS instance without any plugins as explained in the Custom Setup instructions (https://cssinjs.org/react-jss?v=v10.7.1#custom-setup) the result of my Webpack build included all of the jss-preset-default related plugins.

Reproduction: I have tried to create a stand alone example, but am finding it difficult to create it. Why aren't there good React + Webpack + TS starter generators?

I went back to my code and removed all references to react-jss, and the bundle didn't have any plugins. Then I added in the JssProvider from react-jss and then suddenly the bundle exploded.

Managing expectations: I will try to pin-point where in the react-jss code this problem may be, but wanted to at least post the problem to see if this is a known design issue.

kof commented 2 years ago

I guess we need a separate bundle for react-jss without jss-preset-default. We had this by default before, but some complained that adding the preset and calling setup was too much work.

kof commented 2 years ago

actually, we don't need to also provide a bundle, if someone wants to setup a custom jss, they are likely using bundlers, so we just need a separate entry point that doesn't import the preset