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
Ahhh we are just switching from styled components to @emotion as its recommended by @mui. Hope to see this work soon!
Reacted by Tomasz Przysiwek, fillon, l1qu1d, Excigma, Adrian Payne, Jack G., Sebastian, Mark Lyck, Daniele Tortora, Dennis Gonzales and 9 more
Reacted by RangerCoder99, Adrian Payne and Daniele Tortora
Reacted by Jackson Blankenship, Andrew Nagy, Adrian Payne, Mark Lyck, Daniele Tortora and Omri
Reacted by Jens Fosgerau, Antoine, AndrÃĐ Silva, Patryk RzucidÅo, Jan Hesters, joziahg, Mauricio Andrian, Bryan Mendoza, Andrei Sirotin, Andrew Nagy and 2 more
@sanderkooger Same we just did the same! We tried using styled components with MUI5 initially, but that was a mess. MUI5 had pretty bad support/documentation for swapping their styling engine from Emotion to Styled Components, so we ended up having quite some issues... With emotion it worked out of the box. Expect many Next users using MUI5 to swap soon :)
Reacted by Sander Kooger, Mauricio Andrian, Bryan Mendoza, rtritto, Andrew Nagy, Excigma, Ãanna Glavin and Christophe S
@opolo same, after migrating to MUI5, swapping styled-components to emotion was really painless as lots of things worked quite similarly. altho shouldForwardProp is an annoying thing.
Reacted by opolo, Tomasz Przysiwek, Brandon C. Roberts, Andrew Nagy, Excigma, Sebastian, Folkert de Vries and Pablo Navarro
Reacted by Roberto Baldin, Jens Fosgerau, Brandon C. Roberts, Simon RudÃĐn, Mark McDermid, Jan Hesters, Vladimir Makarevich, Patrik SmÄlÃ―, Dimitri, Ivan Tyrnov and 28 more
Reacted by Mark McDermid, Ivan Tyrnov, Andrey Izotov, Brandon C. Roberts, Adrian Payne, Peter Barker, Daniel Steele, David Vaness, alirstm, matt morris and 2 more
Reacted by matt morris, Peter Barker and Mark Lyck
Things like that make me, dislike the Mui team. But same hopefully SWC will work with @emotion soon!
Yup same. Upgrading 15+ packages to new major versions (including NextJS to 12) took a couple of hours. We spent 3-4 days trying to upgrade to MUI5 from 4 with our styled-component implementation (and their own example didnt work, they have since removed it .__.)... It was a kick in the face for our senior-developer, when he after those days removed styled-components in favor of Emotion, not knowing the knew consequences it brought (fortunately none so far, it seems... Except slower upgrade to using SWC now :D )
FYI if your project is flexible to it and you're fine missing out on the extra optimizations of the babel plugin, I haven't had any problems at my company using the emotion ESLint plugin to just auto-add the JSX pragma at the top of any file that needs it, and not relying on the babel plugin at all. would be nice to have this but that option isn't the end of the world.
Reacted by l1qu1d, vxna, Vanya Dymovsky, Saenyakorn Siangsanoh, Adrian Payne, Alvaro Almendros Gala, NoahBrink-Goodman, Allan Zhang, Jon Lambert, LukÃĄÅĄ Fuchs and 2 more
I've posted an update on the feedback thread recently: #30174 (comment)
If someone wants to work on it before Heyang gets around to work on it I'd be happy to land a PR for the transform if it matches the babel plugin, you can have a look at the styled-components transform in packages/next-swc to get started.
Reacted by Grzegorz Dominiczak, Allan Zhang, Connor, BartÅomiej Krakowski, Abdullah, Max Greenwald, siobhÃĄn, Salem, Andrey Izotov, Dennis Gonzales and 4 more
hey, could you elaborate on why swc emotion transform plugin is in next.js package, not directly in swc? is it backmerged later on, or there is different workflow here? Thank you!
First of all thank you for the great work!
Not sure if I should open another issue but I'm still having a problem after trying out the emotion transform.
Component selectors can only be used in conjunction with @emotion/babel-plugin
@Brooooooklyn Sorry, I was trying it with the canary version locally but didn't use it in the reproduction repo. I found out that I have to use an "extended" styled component as a selector for it to break.
Perhaps I'm being stupid @macko911@tills13, how do I use standard styled components? Trying styled.div gives me the error Property 'div' does not exist on type 'CreateMUIStyled<Theme>'.
Perhaps I'm being stupid @macko911@tills13, how do I use standard styled components? Trying styled.div gives me the error Property 'div' does not exist on type 'CreateMUIStyled<Theme>'.
Perhaps I'm being stupid @macko911@tills13, how do I use standard styled components? Trying styled.div gives me the error Property 'div' does not exist on type 'CreateMUIStyled<Theme>'.
Is this usable with Jest? I see the following error when I try to use it: Component selectors can only be used in conjunction with @emotion/babel-plugin.
Is this usable with Jest? I see the following error when I try to use it: Component selectors can only be used in conjunction with @emotion/babel-plugin.
I am getting the same error. There is an issue related to it. #35661
@timneutkens I tried turning on the experimental feature for emotion but am now experiencing issues related to twin.macro (which many people use for tailwind css with emotion/styled-components):
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Activity
sanderkooger commentedon Nov 16, 2021
Ahhh we are just switching from styled components to @emotion as its recommended by @mui. Hope to see this work soon!
opolo commentedon Nov 19, 2021
@sanderkooger Same we just did the same! We tried using styled components with MUI5 initially, but that was a mess. MUI5 had pretty bad support/documentation for swapping their styling engine from Emotion to Styled Components, so we ended up having quite some issues... With emotion it worked out of the box. Expect many Next users using MUI5 to swap soon :)
andrei9669 commentedon Nov 21, 2021
@opolo same, after migrating to MUI5, swapping styled-components to emotion was really painless as lots of things worked quite similarly. altho shouldForwardProp is an annoying thing.
RangerCoder99 commentedon Nov 29, 2021
Any process or status on this?
MonstraG commentedon Dec 3, 2021
Mui folks just stopped trying to make styled-components work with SSR, my team patiently waits for SWC to support @emotion for now
RangerCoder99 commentedon Dec 3, 2021
Things like that make me, dislike the Mui team. But same hopefully SWC will work with @emotion soon!
opolo commentedon Dec 3, 2021
Yup same. Upgrading 15+ packages to new major versions (including NextJS to 12) took a couple of hours. We spent 3-4 days trying to upgrade to MUI5 from 4 with our styled-component implementation (and their own example didnt work, they have since removed it .__.)... It was a kick in the face for our senior-developer, when he after those days removed styled-components in favor of Emotion, not knowing the knew consequences it brought (fortunately none so far, it seems... Except slower upgrade to using SWC now :D )
fillon commentedon Dec 18, 2021
osdiab commentedon Dec 27, 2021
FYI if your project is flexible to it and you're fine missing out on the extra optimizations of the babel plugin, I haven't had any problems at my company using the emotion ESLint plugin to just auto-add the JSX pragma at the top of any file that needs it, and not relying on the babel plugin at all. would be nice to have this but that option isn't the end of the world.
KLaci commentedon Dec 29, 2021
CloutProject commentedon Jan 2, 2022
@sanderkooger
Considering SWC is disabled when a project has a babel config and most people use babel-plugin-import to minimize bundle size with MUI, as well as @emotion/babel-plugin to use component selectors, I'm wondering how can we make a MUI v5 project work with SWC?
dominiczaq commentedon Jan 20, 2022
is there any roadmap for supporting @emotion/babel-plugin? Is there any work that community can help with to push this forward?
timneutkens commentedon Jan 20, 2022
I've posted an update on the feedback thread recently: #30174 (comment)
If someone wants to work on it before Heyang gets around to work on it I'd be happy to land a PR for the transform if it matches the babel plugin, you can have a look at the styled-components transform in
packages/next-swcto get started.9 remaining items
dominiczaq commentedon Mar 15, 2022
hey, could you elaborate on why swc emotion transform plugin is in next.js package, not directly in swc? is it backmerged later on, or there is different workflow here? Thank you!
macko911 commentedon Mar 17, 2022
First of all thank you for the great work!
Not sure if I should open another issue but I'm still having a problem after trying out the emotion transform.
Component selectors can only be used in conjunction with @emotion/babel-pluginHere is an example repo with the issue. https://github.com/macko911/next-swc-emotion-component-selector
Basically I've added only this component to the with-emotion-swc example from the Next.js repo.
Is this a feature that might come later, or will I have to refactor my code so that it doesn't rely on the component selector API?
Brooooooklyn commentedon Mar 17, 2022
@macko911 this feature hasn't been released to the stable channel, so you need to change https://github.com/macko911/next-swc-emotion-component-selector/blob/main/package.json#L11 to
canarymacko911 commentedon Mar 21, 2022
@Brooooooklyn Sorry, I was trying it with the canary version locally but didn't use it in the reproduction repo. I found out that I have to use an "extended" styled component as a selector for it to break.
With this code I get the error even on the latest canary release. I've updated the repo.
tills13 commentedon Mar 21, 2022
Just to clarify @macko911's example, standard styled components as selectors are fine e.g.
but extending or wrapping an existing component with
styleddoes notAgain, thanks for putting this together. I'm excited to use it in my projects.
spencermehta commentedon Mar 22, 2022
Perhaps I'm being stupid @macko911 @tills13, how do I use standard styled components? Trying
styled.divgives me the errorProperty 'div' does not exist on type 'CreateMUIStyled<Theme>'.MonstraG commentedon Mar 22, 2022
Mui doesn't support that yet, use
styled("div")instead.spencermehta commentedon Mar 22, 2022
Unfortunately that then reintroduces the
Error: Component selectors can only be used in conjunction with @emotion/babel-plugin.errorkarlhorky commentedon Mar 25, 2022
Looks like
v12.1.1-canary.18includes the fix for the component selector problem (fixed in #35527)bart-krakowski commentedon Mar 27, 2022
Is this usable with Jest? I see the following error when I try to use it:
Component selectors can only be used in conjunction with @emotion/babel-plugin.markcnunes commentedon Apr 4, 2022
I am getting the same error. There is an issue related to it. #35661
tettoffensive commentedon Apr 16, 2022
@timneutkens I tried turning on the experimental feature for emotion but am now experiencing issues related to twin.macro (which many people use for tailwind css with emotion/styled-components):
ben-rogerson/twin.macro#664
vjpr commentedon Apr 21, 2022
@tettoffensive
twin.macrorelies onbabel-plugin-macroswhich needs to be ported to swc, and thentwin.macroneeds to be ported to swc too.twin.macroshould probably be rewritten directly as an swc plugin.github-actions commentedon May 22, 2022
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.