Coder Social home page Coder Social logo

Preparing for version 3.0 about classnames HOT 9 OPEN

jonkoops avatar jonkoops commented on August 28, 2024 1
Preparing for version 3.0

from classnames.

Comments (9)

jonkoops avatar jonkoops commented on August 28, 2024 3

Or is there going to be some advantage of classnames v3 over clsx?

I personally have been toying with the idea of simplifying the API of classnames to reduce the complexity of our code, and hopefully increase performance while we're at it. But this will still require some discussion on what the final implementation should be.

I'd also like to offer an even more basic version of classnames that only accepts strings (much like clsx), as you can pretty much express all you need with string | false, but might be considered non-preferential for most users stylistically (objects are kinda nice).

Aside from that we offer style binding (e.g. for CSS modules), and a unique 'dedupe' alternative. We still have to decide what needs to be preserved from this, or revisited in API. I myself would like to refactor the style binding variant to have a more intuitive API, I think there is still value in that for our users.

As for the 'dedupe' variant, I don't really see any practical cases where you would want to dedupe classes, or even run into a scenario where your expressions have become so complex it would occur naturally. Also the impact of having a class duplicated is virtually non-existent, but perhaps there are historical reasons for this.

Stupid idea maybe, but would it make sense to just say the next version of classnames is clsx?

I don't think this is a stupid idea at all, one of the many issues in the JavaScript ecosystem is the choice overload that persists. And we have a lot of overlap with clsx, so it does make a lot of sense to see if we can combine our efforts here.

I think there are a couple of differences between our philosophies though (note personal opinion ahead), we both strive for excellent performance (note we are pretty competitive), but clsx obsesses a bit about file-size to the point where I think the returns are diminishing, we're only shipping a single utility function after all.

Another point we differ is that clsx is backwards compatible all the way back to Node.js v0.10.0 and Internet Explorer 8. Which is impressive, but I sincerely doubt that it is being executed in any such runtime that still exists in the wild. I prefer more modern syntax support if that can open up the gates to better performance (e.g. using Set for de-duplication), but further testing is required to confirm this is the case.

We also have plans to possibly drop UMD and CommonJS and favor a purely ESM distribution (#349), as I believe there is a lot of value in finally settling on a common set of primitives around modules. Note, we will continue to support v2 for the foreseeable future to bridge that gap.

That said, perhaps our differences can be settled, APIs combined, and we can make a better alternative to all involved. For now at least work will continue on classnames, and we're actively looking to the future, whatever that may be.

cc @lukeed @jorgebucaran

from classnames.

jonkoops avatar jonkoops commented on August 28, 2024

@dcousens @JedWatson WDYT? Is this strategy something you can get behind as well?

from classnames.

agrant-1 avatar agrant-1 commented on August 28, 2024

from classnames.

jonkoops avatar jonkoops commented on August 28, 2024

@agrant-1 Please refrain from sending e-mails to this GitHub thread, it will not unsubscribe you. Do so by selecting 'Unwatch' on the main page of the repository.

from classnames.

dcousens avatar dcousens commented on August 28, 2024

Sounds good to me, but I wouldn't bother with a v2 branch unless we need to go back to that branch - as you say, it's unlikely. git has the history.

from classnames.

jonkoops avatar jonkoops commented on August 28, 2024

Perfect, I've created a v2.0 branch for now (we can always delete it), so that if we make changes in the docs we can link there for users that might want to read the 'legacy' docs.

from classnames.

jonkoops avatar jonkoops commented on August 28, 2024

Let's keep this issue open to coordinate the work needed for 3.0 in general.

from classnames.

jonkoops avatar jonkoops commented on August 28, 2024

I went ahead and deleted the next branch, as there was nothing of great value there left to port over.

from classnames.

dumbmatter avatar dumbmatter commented on August 28, 2024

Stupid idea maybe, but would it make sense to just say the next version of classnames is clsx? Or is there going to be some advantage of classnames v3 over clsx? Currently clsx claims to be faster and smaller, and it's also now more popular.

from classnames.

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.