You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using @emotion/babel-plugin is generating longer classNames than expected in production. I can see that after build each component has two classNames: one longer one that contains the component name and references it's styles, and one shorter one that is only a hash, and has no references to any styles. Changing the config for this option to never improved things, but still contained the (seemingly) extraneous className? Results from testing below:
Method
Generated classNames in production
Without babel plugin
css-1vj8at2
With default (dev-only)
css-1qtu1e0-StyledHomePage e1lgw2vu1
With never
css-1445odi e1lgw2vu1
From a quick look at the source code I think the problem lies here:
neefrehman
changed the title
/babel-plugin's autoLabel outputting verbose classNames in production by default
@emotion/babel-plugin's autoLabel outputting verbose classNames in production by default
Dec 2, 2020
Current behavior:
Using
@emotion/babel-plugin
is generating longer classNames than expected in production. I can see that after build each component has two classNames: one longer one that contains the component name and references it's styles, and one shorter one that is only a hash, and has no references to any styles. Changing the config for this option tonever
improved things, but still contained the (seemingly) extraneous className? Results from testing below:css-1vj8at2
dev-only
)css-1qtu1e0-StyledHomePage e1lgw2vu1
never
css-1445odi e1lgw2vu1
From a quick look at the source code I think the problem lies here:
emotion/packages/babel-plugin/src/utils/get-styled-options.js
Line 33 in fa97767
I think a fix might be to use something like:
Although that would still add the extraneous className when set to
never
(likee1lgw2vu1
above), I'm not sure if that's a separate bug?To reproduce:
run npm run build && npm run start
.babelrc
Expected behavior:
A production build with the babel plugin should output only the least verbose classNames for elements.
Environment information:
react
version: 17.0.1next
version: 10.0.3@emotion/react
version: 11.1.1@emotion/styled
version: 11.0.0@emotion/babel-plugin
version: 11.0.0The text was updated successfully, but these errors were encountered: