Giter VIP home page Giter VIP logo

Comments (6)

sachin-hg avatar sachin-hg commented on May 27, 2024 1

We really liked the idea of this RFC and implemented something which works.

Our implementation focuses on @linaria/atomic. But i guess a similar implementation should be possible with in compiled as well.

Because both are build time css-in-js libraries which just manipulate the classnames at runtime.

compiled uses the the ax function and linaria does something similar with a cx function.

Our implementation should be able to handle the safe and "not safe" cases mentioned in the RFC above by @itsdouges without needing to add additional selectors.

You can checkout this article for more details: https://medium.com/engineering-housing/css-pipeline-housing-com-ab8bc09ee4da

The corresponding implementations for linaria's cx function and the function to generate classnames can be found here and here

What we haven't been able to solve for though is long-term caching. how to ensure that we get consistent results across builds. We have done an implementation which requires storing the generated classnames in firebase DB. But we would love to do away with that approach. Looking out for suggestions and comments!

from compiled.

itsdouges avatar itsdouges commented on May 27, 2024

Tangent thought: Explicit disabling of composition/conditional CSS. It means when baked we can simplify it down to something tiny.

from compiled.

albertogasparin avatar albertogasparin commented on May 27, 2024

I'll add an idea for a step in between: having better mapped shorthands for known properties.
For instance, instead of width: 10px becoming _1p1dangw, why cannot we make it just _w_10?
CSS has a limited dictionary and we could provide compact shorthands for the most used properties.
For values, we could expose a babel config to declare the most used unit (px/em/rem/...) and compact those while preserving hashes for all others.
It might not be a massive saving but given how often things like position: relative, padding-left: Xunit, ... are used, might have sizeable impact on DOM (even if gzip compression mitigates a lot)

from compiled.

liamqma avatar liamqma commented on May 27, 2024

Hey @albertogasparin ,

For values, we could expose a babel config to declare the most used unit (px/em/rem/...) and compact those while preserving hashes for all others.

Can you give an example please?

from compiled.

albertogasparin avatar albertogasparin commented on May 27, 2024
[
  "@compiled/babel-plugin",
  {
    "parserBabelPlugins": ["typescript", "jsx"],
    "mostCommonUnit": "px"
  }
]

This is leveraging the fact that projects generally have a recommended unit of measure that most values adopt (usually px or rem). But thinking more about it, in our case with the push for css vars for spacing, we might find very little benefit as most might end up being padding: var(--spacing-xs) 🙈

from compiled.

astahmer avatar astahmer commented on May 27, 2024

not really related but vanilla-extract also does this with the identifier option

from compiled.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.