Skip to content

[babel-plugin] Better options for processStylexRules #1062

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

Open
necolas opened this issue May 15, 2025 · 4 comments · May be fixed by #1072
Open

[babel-plugin] Better options for processStylexRules #1062

necolas opened this issue May 15, 2025 · 4 comments · May be fixed by #1072

Comments

@necolas
Copy link
Contributor

necolas commented May 15, 2025

In particular, we should be able to support generating CSS files that:

  • Order CSS correctly but don't use @layer or a polyfill.
    • CSS layers aren't needed for many use cases.
  • Use native @layer.
    • Useful for explicitly controlling order, including when generating multiple sheets.
  • Polyfill @layer.
@jeongminsang
Copy link

jeongminsang commented May 21, 2025

I've implemented this solution, but I have some about a breaking change. Please take a look and let me know your thoughts. More details are available in the PR description. #1072

@nmn
Copy link
Collaborator

nmn commented May 22, 2025

Order CSS correctly but don't use @layer or a polyfill.

This is not entirely possible. Based on the StyleX design for media queries and pseudo classes, all longhand styles should have higher specificity than shorthand styles.

This is also needed for RN support to work correctly.

Therefore, we need a plain .margin-top to override a .margin:hover

This means we need some way to bump the specificity, which means a @layer or a polyfill for bumping specificity.

@jeongminsang
Copy link

I've carefully reviewed the feedback on the #1072 and am currently working on addressing the points. I'll update the PR soon.

@nmn,

I now fully understand that for StyleX's design and RN support, ensuring longhand styles override shorthand styles requires achieving higher specificity, which in turn necessitates the use of @layer or a polyfill.

Considering this situation, I'd appreciate hearing the maintainers' thoughts on the future direction of this issue.

  • Would it be best to proceed with the current #1072, excluding the "order CSS correctly without @layer or a polyfill" requirement?
  • Alternatively, regarding the StyleX specificity issue that would require @layer or a polyfill, I'm open to discussing and exploring solutions if maintainers can provide clear guidelines.

I'm keen to help resolve this issue.

@necolas
Copy link
Contributor Author

necolas commented May 24, 2025

You can do it without adding "none" for now. We don't use any layers stuff internally, but that won't be the case for long so we might not need "none" for long anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants