-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[Performance]: Replace classnames
usage with clsx
#47760
[Performance]: Replace classnames
usage with clsx
#47760
Conversation
classnames
usage with clsx
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
Hi @kmanijak, @woocommerce/woo-fse Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Just a heads up, something we should do on all these PRs (we dont have automation yet for, but should) is run |
Oh and you'll also be able to validate if classnames was actually removed as a dependency :) because there might be underlying deps relying on it it might not change bundle size (or could increase it, although if clsx runtime perf is better it might be worth!) |
Likely, won't be completely gone until the upstream WP packages that include it are also released with the changes. With that said, along with what Sam mentioned, it'd be good to identify what external packages are pulling in |
@samueljseay @nerrad @danielwrobert thanks for the reviews & my apologies for the slight delay as I had to switch focus to other higher priorities + had an AFK this week :)
@samueljseay thanks for the suggestion! I see you already opened a PR for the automation so that's great: #47880 looking forward to seeing it in place 🎉 . I did compare the bundle sizes on trunk versus on this branch and it is slightly bigger indeed:
Given that:
How about we merge the changes here and work on additional PRs/steps to investigate reducing the size of the build separately? This PR is already rather big and the runtime performance improvement is worth the change, not to mention it is aligned with what Gutenberg is doing. |
@nefeline more than happy to merge this based on runtime perf benefits alone! 🚢 |
* Replace classnames with clsx within woocommerce-blocks. * Undo unnecessary change to getClassnames const. * Replace classnames with clsx within woocommerce-admin. * Add changelog. * Update the pnpm lock file * Address lint. * Address lint errors for the block-library.
Submission Review Guidelines:
Changes proposed in this Pull Request:
Replace
classnames
withclsx
across WooCommerce, which is a faster and lighter alternative.This is aligned with the equivalent recent change made on Gutenberg on WordPress/gutenberg#61138
Closes #47602
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
No visible changes should be observed to the end user.
Changelog entry
Significance
Type
Message
Replaced
classnames
package with the faster and smallerclsx
package.Comment