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
3. Use context to mark when some CSS has already rendered. If it has already been done - don't render anything!
This is essentially how Emotion does it right now.
1
1
Working proof here github.com/atlassian-labs/co…
Still need to setup the browser bundle building though.
Apr 19, 2020 · 11:31 PM UTC

