emotion-js / emotion

👩‍🎤 CSS-in-JS library designed for high performance style composition
https://emotion.sh/
MIT License
17.4k stars 1.11k forks source link

SSR Breaks when a template tag is used #2040

Open teleaziz opened 3 years ago

teleaziz commented 3 years ago

Current behavior:

SSR styles breaks when wrapping components under template tags.

To reproduce:

Minimum reproduction is in this commit https://github.com/teleaziz/gatsby-shopify-starter/commit/1727738b71019bd6032edef0ec15589fdbcf51b3

Expected behavior: Styles to be included in the SSR styles

Environment information:

"@emotion/core": "10.0.35",
"react": "^16.11.0",
Andarist commented 3 years ago

This is caused by the use of <template> that is really context-sensitive and Emotion lacks any information of this context so it cannot handle this well. I'm not sure what's your exact use case - are you trying to use web components with this somehow? How do u expect this to later work at runtime? I can see a couple of ways how you could solve this but I'm afraid that this just won't work using our default 0 config strategy.

Could you describe how you are exactly planning to use this <template>? You could also join our Slack to discuss this with me in a quicker manner.

teleaziz commented 3 years ago

Hi @Andarist appreciate your response, we use template tags on the server to render multiple variations of the same component to be replaced before hydration by a script, this allow us to a/b test and personalize content on SSR pages.

How can I join your Slack?

Andarist commented 3 years ago

I think it should be possible to register here: https://emotion-slack.slack.com/

Or you can always reach out to me on Twitter - my DMs are open: https://twitter.com/AndaristRake

mix3d commented 5 months ago

Any updates on this one, almost 4 years later?

Andarist commented 5 months ago

No extra information has been provided about this in all that time. How do you expect it to get fixed if I don't understand the use case and the constraints of the OP? You are more than welcome to fix this yourself too - we accept PRs.

mix3d commented 4 months ago

Forgive me, the thread ended with info about off-github comms, incorrectly assumed additional info had been passed / discussed there.