-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use emotion without Babel? #163
Comments
@screendriver hi there, AFAIK emotion is integrated deeply into babel toolchain. You need babel to use emotion. If you don't want to add babel, you can use others alternative CSS-in-JS styling solution like styled-component/glamarous |
This is a pity 😞 The only answer that I didn't want to hear. The |
You can use the raw api that babel converts the strings into. It would be verbose but it is very fast. You don't get extraction either. import { css } from 'emotion'
const H1 = css(['css-H1-duiy4a'], [colorVariable], function createEmotionStyles(colorVariable) {
return [`.css-H1-duiy4a { color:${colorVariable} }`]
}) |
@screendriver You do not need babel to run emotion as version 8. |
@tkh44 I'm considering replacing Are there any plans to port the babel plugin to typescript? |
IMHO that would be a duplicated effort
Upcoming emotion@10 is going to support all features out of the box - babel plugin will be used merely to optimize (like bundle size) the output. |
That's great news! Thanks for the update :) |
@Brooooooklyn that awesome!!! Are you planning to get your transformer to feature parity with the Babel plugin? |
@elektronik2k5 yes, we are planning to use emotion in production, and I will keep developing this plugin. |
@Andarist it's not exatly clear to me if the babel plugin just minifies, or is it optimizing something more important like the parsing of css string literals into AST? |
@dominictobias - no, AST is not produced at build time. Babel is used only for minifying, source map generation, label insertion, and similar. It's supposed to enhance the developer experience but it doesn't influence the overall perf characteristics too much. |
This is not a bug report but a general question: is it possible to use
emotion
without Babel and the correspondingemotion/babel
plugin? I'm not using Babel, webpack and React. Instead I use TypeScript, fuse-box and Preact.It seems a little bit overblown to add Babel, the emotion Babel plugin and expand my build chain only "just" for emotion.
I would be grateful for any help.
The text was updated successfully, but these errors were encountered: