Here's how im thinking to solve rendering the minimal amount of CSS on the server while also not blowing out the bundle size 馃憞
1
3
1. Context on the server. It's the only solution because of async ssr. Singleton won't work like I thought it could before (and tbh the api was yuck, having a flush func to call after SSR? Gross!) Each compiled component needs to both be a context provider and consumer.
2
I assumed there needs to be a provider *somewhere* above any compiled component, but not necessarily wrapping every compiled component. What am I missing?
1
1
that's why (on the server) every compiled component will be BOTH a provider AND a consumer it keeps it 0 config - so you as a consumer don't have to worry about it
1
so the top most compiled component will be the one to create the actual data - and then every child will read from it
2
one thing i want to see if we can accomplish is 0 context on the client. even for theming.

Apr 20, 2020 路 1:07 AM UTC

One thing that caught me out with using emotion is rendering content into an iframe (this story wasn't well supported until emotion 10). I would imagine this use case would be harder to support without using context.
2
whats the use case? dipping into an iframe from a parent host and rendering a component?
1
Yeah, thats the main one - custom style container (iframe)
1
1
U playing the compiler game - support for context can be added behind a flag, rigjt?
1
1
yeah, i still need to understand the ^ use case but anythings possible
1
Isolation - rendering a preview component on the parent page, emotion is actually quite popular among shadow dom crowd because they can target where styles are being injected
1
1
ah so you're choosing what head you want to render into with the emotion provider? probably something we can look at later.
1