javivelasco / react-css-themr

Easy theming and composition for CSS Modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When using ExtractTextPlugin it break the app

idangozlan opened this issue · comments

Trace: You are merging non-object // removed by extract-text-webpack-plugin with an object default
[0]     at /Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:265:23
[0]     at Array.forEach (native)
[0]     at merge (/Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:217:22)
[0]     at /Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:193:12
[0]     at Array.reduce (native)
[0]     at themeable (/Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:192:17)
[0]     at Themed.getTheme (/Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:139:156)
[0]     at Themed.calcTheme (/Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:145:36)
[0]     at new Themed (/Users/idangozlan/myproject/node_modules/react-css-themr/lib/components/themr.js:102:30)
[0]     at ReactCompositeComponentWrapper._constructComponentWithoutOwner (/Users/idangozlan/myproject/node_modules/react-dom/lib/ReactCompositeComponent.js:298:16) /
[0]     at /Users/idangozlan/myproject/src/server.js:341:17
[0]     at process._tickCallback (internal/process/next_tick.js:103:7)

Any special instructions to ExtractTextPlugin usage?

@idangozlan Could you provide a minimal representation gist/repo?

Yes please

Ok, so I investigate this issue very deeply, debug it and found the issue.

When using react-css-themr and supplying as base stylesheet which is empty / has only :global rules, for ex:

...
import * as styles from './App.scss';
...

@themr('App', styles)
......

and App.scss is empty / only :global rules, extract-text-webpack-plugin put in the webpack assets file "// removed by extract-text-webpack-plugin" instead of just empty json {}.

when react-css-themr is trying to merge the themed App.scss and the base one, which after the extraction is string of "// removed by extract-text-webpack-plugin", it's screaming, since it can't merge it.

Finally, we can warn users to not include empty/global rules as base theme file, but I would like to prevent users fail with that tricky thing.

Anyway, I've created an exception if for that, and im going to create pull request. it's up to you guys if to get it or not, but I think it will be good idea.