-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
styled-components v6 #3333
Comments
There's also |
@kitten @mxstbr What are your thoughts on getting https://spectrum.chat/styled-components/general/feat-req-add-prop-to-allow-for-encapsulating-selectors-to-component~1ec08108-05df-41f7-b8a3-08d99751c6ea into the new version of styled-components? I've been wanting to do this since I started using styled-components years ago. 😿 |
Can we have a better support for micro-frontends? |
@motevallian I mean, I'd love for that to happen, however it ain't going to happen unless the boundaries of apps is clear. So for instance, if we allow the Generally, this is why I'd recommend people to set up federate micro-frontends with shared instance of React, React DOM, styled-components, [all things that are needed globally]. Ultimately that means you're sharing the "brunt force" of all vendored libraries. Obviously, that depends also on your approach and it isn't always possible to federate and build at once, or at least, to share even a few dependencies at all times. Because of that we also considered sharing the sheet code in a separate package. That means that more libraries could access a shared sheet and that the Apart from that, if we do encounter breaking sheet changes, we can still fall back to adding special "version tags" to the tag output and global variable, and all other efforts for federation/multi-SC on a page could be layered on top of this measure, i.e. in cc @probablyup: Wdyt? I can likely make sure that we make a separate sheet library. I can send a DM soon so we can discuss the details that aren't interesting beyond this thread |
I would love to see better typescript support around theming, particularly when nesting themes |
Hmm... after some research I found that I had to declare and export the DefaultTheme interface in a styled.ts file in order to activate autocomplete. I didn't try it but I think that that is the solution. (https://medium.com/rbi-tech/theme-with-styled-components-and-typescript-209244ec15a3) |
There is currently some hype around build-time css-in-js due to performance. Any hope this concept could be integrated into styled-components? See https://pustelto.com/blog/css-vs-css-in-js-perf/ for context. |
I think most of this is becoming clearer now.
This is related to a Chromium issue, and as it's browser specific it may not be wise to work around it: https://bugs.chromium.org/p/chromium/issues/detail?id=1216451
Unchanged situation / limited support. See #3146
We likely will drop IE11 support in v6. There'll be no special effort to support it anymore, but similarly there'll be no special effort needed to drop support. Currently, for us this does mean dropping the non-CSSOM sheet implementation. A refactor could then make it a bit more compact.
Work on
Depends on the prior TypeScript refactor and dropping IE11 support. This can likely be parallelised. Micro frontends: If we extract the styling/sheet system, there's a chance we can improve how styles are shared by sharing the underlying system and tags. This requires the extraction of the system first, and we'd need some input from people working on module federation and micro frontends. However, in general, there's a lot we can improve here.
Not really. It does work correctly, however folding and We may want to find ways to limit the impact of the aforementioned Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1216451
Not considered for v6 / no discussion occurred, as this would've been a major change of our approach.
This would need some kind of parser. It's unlikely that we'll find a way to shoehorn this into the library, unless we can build on some stylis upgrades. However, this would mean specificity changes, so for now, this isn't in scope for v6 at least.
The refactors listed should help us implement this. Our build pipeline needs a desperate upgrade, but I'll likely address this as we go.
See above; very much build system related. There's some refactors we can do around our error system and such due to the TypeScript refactor. |
Should we take care of this for v6? reactwg/react-18#110 |
There was a v6.0.0-beta.6 published @lunaris just yesterday. Which is good. I can't seem to find relevant umbrella issue for v6 release as a whole with ETA and react 18 support mentioned anywhere. Can anyone point me in the right direction? |
There’s a pinned issue for v6 beta. No current ETA, but I’m hoping to have a RC ready by the winter holidays at the latest. I have not spent much time considering React 18 to be honest, if there’s someone that wants to pitch in for the server-side changes that would be helpful. |
That being said, we are using useInsertionEffect for cGS where available |
What happens to
@font-face
?Context: There's a Chrome quirk that reloads fonts and images on each change to the
CSSStyleSheet
(which is definitely unintended) which can cause a flash of fonts when no cache header has been added. It's also possible that this is already fixed in newer versions. Investigation needed.Nothing, special behaviour could still remain dropped, although it's possible we could have a workaround that directly mutates the inserted
@font-face
at-rule to swap out the URL with something else in development to make this issue less apparent.What happens to
@import
?Nothing, special behaviour could still remain dropped, although a warning would be welcome.
Do we support IE11 in v6?
It'd be great to drop IE11 and this may just now be possible since people could stop upgrading when they need IE11 support since v4/v5 have been relatively stable (as long as we still patch bugs)
Do we start with a rewrite?
Current Answer: A TypeScript rewrite would be welcome. We can still auto-generate typings for Flow and Flow in general is "falling out of popularity." Meanwhile a TypeScript rewrite is just ergonomically nicer for ourselves.
Currently we believe that a rewrite to get rid of old legacy code paths and questionable implementation details is the way forward.
What happens to the style system?
We can split out our style management system into a separate non-React subpackage that is usable by other libraries so that other style systems can better cooperate with styled-components.
Is our specificity approach ripe for an upgrade?
In the current systems we have an elaborate system that ensures that style ordering is predictable and solid because of composition. This is really important, but hinders optimisations for static styles. It's possible that we may be able to come up with more or better solutions for this. Investigation needed.
What about atomic rules?
In theory atomic rules in production could help with a lot of optimisations. However that means we'll have to ensure that it runs identically to a non-atomic system in terms of specificity and ordering.
Targeting other components or using
+ &
would also still need component IDs, so Investigation needed.What about bundle size?
Just by getting rid of the
TextNode
fallback / alternative and usingProxy
for the styled aliases we'd get rid of a large chunk of complexity.In theory the
$
prefix, i.e.$variant
syntax would get rid of prop filtering too.Do we utilise new approaches around CSS Custom Properties?
With the above we should also put this up for a question. If we split styling up into static and dynamic parts we could even split that static parts into value changes that can be expressed with custom properties.
That being said, if we do want to do this, our specificity and ordering approach will break!
What about our theming system?
Even in a TypeScript rewrite this will be an issue as no type can be spread out via the
ThemeProvider
. So either we need a factory here or another system that distributes the theme type better. Investigation needed.What about ENV-based switches?
Apart from
NODE_ENV: 'production' | 'development'
no switch should be required. We moved to SSR having its ownStyleSheetManager
and it's highly likely that no other switch will be needed to prefer client v server logic anymore. So notypeof
checks on globals should be performed in v6.This list is still incomplete
The text was updated successfully, but these errors were encountered: