RFC: Streaming SSR and it's impacts
See original GitHub issueEdit: Update 6/Oct/2020
Because we’ve pivoted to atomic CSS things now are made more complicated. We still however need to maintain this story.
A note on design decisions - Right now Compileds primary goal is to introduce constraints that make it impossible to write unperformant CSS in JS. If we can solve the 90% here that is good enough.
Currently we operate essentially the same as Emotion’s default config.
SSR rendered markup:
<style>...</style>
<div class="abc">...</div>
Client markup:
<head>
<style>...</style>
</head>
..
<div class="abc">...</div>
While this means SSR is 0 config and it just works (with streaming as a bonus) - it makes using any nth
selectors annoying/shitty to use.
:first-child
:nth-child
:nth-of-type
:nth-last-of-type
:nth-last-child
:first-of-type
:last-child
* + *
I really want to solve this without re-architecting how things work for the default implementation. We need to investigate if we can do some CSS magic to create equivalent selectors for the 90% case that:
- works for ssr before js has executed (style before the component atm)
- works for client after js has executed (style in the head now)
Remember: The style
element will move when JS executes. We need to handle both states.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15 (2 by maintainers)
Cheers will do 🙂
cc @pgmanutd had some good discussion today ^
On Tue, 6 Oct 2020, 6:28 pm Jonathan Pollak, notifications@github.com wrote:
Feature queries (
@supports
blocks) also come to mind in the same way as media queries, but I’m sure there are other edge cases I’m just not thinking about right now.I’m also not at all certain that the JS boilerplate required for the inline
script
based solution will be larger than duplication, especially in non-trivially sized applications.As an aside, regardless of how the server-side application of styles will happen, for the client-side
style
element insertion, I’d recommend Fela’s approach to style elements, as it enables a very clear separation of concerns (global, fonts, media query), and by so eases the task of sorting rulesets.