Skip to content

Dependencies: Replace classnames with clsx - v2 - #91408

Merged
tyxla merged 1 commit into
trunkfrom
try/clsx-2
Jun 3, 2024
Merged

tyxla merged 1 commit into
trunkfrom
try/clsx-2

Conversation

@tyxla

@tyxla tyxla commented Jun 3, 2024 •

Copy link
Copy Markdown
Member

Proposed Changes

This PR replaces classnames with clsx across Calypso, which is a faster and lighter alternative. (v1 was #89843 but it was quite stale).

@DaniGuardiola introduced it in Gutenberg in WordPress/gutenberg#61138 recently.

We can now replace it since we updated to the latest @wordpress packages in #91366.

Testing Instructions

  • All should be green.

@tyxla tyxla added Enhancement Changes to an existing feature — removing, adding, or changing parts of it Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jun 3, 2024
@tyxla
tyxla requested a review from a team June 3, 2024 13:19
@tyxla tyxla self-assigned this Jun 3, 2024
@tyxla
tyxla requested review from a team as code owners June 3, 2024 13:19
@tyxla
tyxla requested a review from a team June 3, 2024 13:19
@tyxla
tyxla requested a review from a team as a code owner June 3, 2024 13:19
@tyxla
tyxla requested review from aneeshd16 and chad1008 and removed request for a team June 3, 2024 13:19
@github-actions

github-actions Bot commented Jun 3, 2024 •

Copy link
Copy Markdown

@matticbot

Copy link
Copy Markdown
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • blaze-dashboard
  • command-palette-wp-admin
  • editing-toolkit
  • happy-blocks
  • notifications
  • o2-blocks
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug try/clsx-2 on your sandbox.

@matticbot

Copy link
Copy Markdown
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~488 bytes removed 📉 [gzipped])

Details
name                   parsed_size           gzip_size
entry-login                 -903 B  (-0.1%)     -380 B  (-0.1%)
entry-subscriptions         -865 B  (-0.1%)     -346 B  (-0.1%)
entry-stepper               -861 B  (-0.0%)     -341 B  (-0.1%)
entry-main                  -845 B  (-0.0%)     -335 B  (-0.1%)
entry-browsehappy           -784 B  (-0.3%)     -295 B  (-0.4%)
entry-domains-landing       -328 B  (-0.1%)     -143 B  (-0.1%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~4584 bytes removed 📉 [gzipped])

Details
name                                parsed_size           gzip_size
settings                                 -795 B  (-0.1%)     -208 B  (-0.1%)
a8c-for-agencies-referrals               +793 B  (+0.2%)     +238 B  (+0.2%)
sites-dashboard                          +723 B  (+0.1%)     +212 B  (+0.1%)
site-monitoring                          +683 B  (+0.1%)     +184 B  (+0.1%)
site-logs                                +683 B  (+0.1%)     +184 B  (+0.1%)
jetpack-cloud-manage-pricing             -675 B  (-0.2%)     -218 B  (-0.2%)
dev-tools                                +647 B  (+0.1%)     +204 B  (+0.1%)
github-deployments                       +635 B  (+0.1%)     +171 B  (+0.1%)
jetpack-cloud-agency-sites-v2            +595 B  (+0.0%)      -50 B  (-0.0%)
hosting                                  +552 B  (+0.0%)     +104 B  (+0.0%)
staging-site                             +528 B  (+0.0%)     +100 B  (+0.0%)
a8c-for-agencies-sites                   +476 B  (+0.0%)     -113 B  (-0.0%)
media                                    -459 B  (-0.0%)     -230 B  (-0.1%)
backup                                   -413 B  (-0.0%)     -335 B  (-0.1%)
plugins                                  -409 B  (-0.0%)     -250 B  (-0.0%)
purchases                                -396 B  (-0.0%)     -168 B  (-0.0%)
site-purchases                           -378 B  (-0.0%)     -118 B  (-0.0%)
checkout                                 -367 B  (-0.0%)      -93 B  (-0.0%)
earn                                     -359 B  (-0.0%)     -161 B  (-0.1%)
scan                                     -358 B  (-0.0%)     -184 B  (-0.1%)
home                                     -345 B  (-0.0%)     -281 B  (-0.1%)
email                                    -344 B  (-0.0%)     -136 B  (-0.1%)
jetpack-cloud-plugin-management          -306 B  (-0.0%)     -208 B  (-0.0%)
security                                 -296 B  (-0.0%)     -146 B  (-0.1%)
domains                                  -294 B  (-0.0%)     -206 B  (-0.0%)
write-flow                               -292 B  (-0.0%)     -224 B  (-0.1%)
build-flow                               -292 B  (-0.0%)     -220 B  (-0.1%)
import-flow                              -291 B  (-0.0%)     -304 B  (-0.0%)
activity                                 -281 B  (-0.0%)     -228 B  (-0.1%)
posts-custom                             -278 B  (-0.0%)     -137 B  (-0.1%)
posts                                    -278 B  (-0.0%)     -137 B  (-0.1%)
settings-performance                     -273 B  (-0.0%)      -88 B  (-0.1%)
reader                                   -271 B  (-0.0%)     -206 B  (-0.1%)
videopress-flow                          -267 B  (-0.0%)     -236 B  (-0.1%)
settings-podcast                         -267 B  (-0.0%)      -99 B  (-0.1%)
settings-writing                         -259 B  (-0.0%)     -121 B  (-0.1%)
people                                   -255 B  (-0.0%)     -186 B  (-0.1%)
theme                                    -249 B  (-0.0%)     -141 B  (-0.1%)
comments                                 -249 B  (-0.0%)     -130 B  (-0.1%)
marketing                                -246 B  (-0.0%)     -104 B  (-0.0%)
settings-security                        -245 B  (-0.0%)     -146 B  (-0.1%)
jetpack-search                           -245 B  (-0.0%)     -121 B  (-0.1%)
account                                  -237 B  (-0.0%)     -133 B  (-0.1%)
settings-newsletter                      -235 B  (-0.0%)     -116 B  (-0.1%)
import                                   -225 B  (-0.0%)     -165 B  (-0.1%)
settings-jetpack                         -223 B  (-0.0%)      -92 B  (-0.1%)
themes                                   -221 B  (-0.0%)     -110 B  (-0.0%)
settings-discussion                      -221 B  (-0.0%)     -132 B  (-0.1%)
jetpack-cloud-settings                   -219 B  (-0.0%)      -85 B  (-0.0%)
google-my-business                       -219 B  (-0.0%)     -118 B  (-0.1%)
jetpack-connect                          -218 B  (-0.0%)     -136 B  (-0.0%)
jetpack-cloud-features-comparison        -212 B  (-0.0%)     -163 B  (-0.1%)
import-hosted-site-flow                  -212 B  (-0.0%)     -266 B  (-0.1%)
jetpack-cloud-overview                   -211 B  (-0.0%)     -143 B  (-0.1%)
notification-settings                    -209 B  (-0.0%)     -141 B  (-0.1%)
concierge                                -207 B  (-0.0%)      -95 B  (-0.1%)
pages                                    -195 B  (-0.0%)     -121 B  (-0.1%)
account-close                            -190 B  (-0.0%)     -124 B  (-0.1%)
migrate                                  -186 B  (-0.0%)      -89 B  (-0.1%)
woocommerce-installation                 -181 B  (-0.0%)      -66 B  (-0.1%)
subscribers                              -181 B  (-0.0%)      -88 B  (-0.0%)
export                                   -181 B  (-0.0%)      -87 B  (-0.1%)
settings-reading                         -179 B  (-0.0%)      -73 B  (-0.1%)
jetpack-social                           -178 B  (-0.0%)      -68 B  (-0.0%)
jetpack-cloud-pricing                    -172 B  (-0.0%)      -90 B  (-0.0%)
jetpack-cloud                            -171 B  (-0.0%)      -97 B  (-0.1%)
help                                     -168 B  (-0.0%)     -115 B  (-0.0%)
developer                                -168 B  (-0.0%)     -128 B  (-0.1%)
site-blocks                              -162 B  (-0.0%)     -111 B  (-0.0%)
privacy                                  -162 B  (-0.0%)     -120 B  (-0.1%)
me                                       -162 B  (-0.0%)     -119 B  (-0.1%)
jetpack-cloud-partner-portal             -153 B  (-0.0%)     -142 B  (-0.1%)
promote-post-i2                          -149 B  (-0.0%)      -96 B  (-0.1%)
marketplace                              -149 B  (-0.0%)     -112 B  (-0.0%)
add-ons                                  -143 B  (-0.0%)      -64 B  (-0.1%)
a8c-for-agencies-overview                -142 B  (-0.1%)      -74 B  (-0.1%)
link-in-bio-tld-flow                     -138 B  (-0.0%)     -283 B  (-0.1%)
a8c-for-agencies-marketplace             -138 B  (-0.0%)      -72 B  (-0.0%)
customize                                -137 B  (-0.0%)      -58 B  (-0.0%)
preview                                  -131 B  (-0.0%)      -59 B  (-0.0%)
gutenberg-editor                         -131 B  (-0.0%)      -59 B  (-0.0%)
a8c-for-agencies-migrations              -120 B  (-0.1%)      -76 B  (-0.1%)
stats                                    -116 B  (-0.0%)     -213 B  (-0.1%)
accept-invite                            -115 B  (-0.1%)      -76 B  (-0.1%)
woocommerce                              -107 B  (-0.0%)      -53 B  (-0.0%)
a8c-for-agencies-settings                -102 B  (-0.1%)      -65 B  (-0.1%)
a8c-for-agencies-plugins                 -102 B  (-0.1%)      -74 B  (-0.2%)
a8c-for-agencies-partner-directory       -102 B  (-0.1%)      -71 B  (-0.1%)
a8c-for-agencies-purchases                -95 B  (-0.0%)      -72 B  (-0.1%)
plans                                     -74 B  (-0.0%)     -127 B  (-0.0%)
a8c-for-agencies-landing                  -70 B  (-0.1%)      -47 B  (-0.2%)
domain-user-transfer-flow                 -68 B  (-0.0%)      -41 B  (-0.1%)
update-design-flow                        +64 B  (+0.0%)     -118 B  (-0.0%)
jetpack-app                               +62 B  (+0.0%)       -3 B  (-0.0%)
jetpack-cloud-agency-signup               -60 B  (-0.1%)      -35 B  (-0.2%)
devdocs                                   -60 B  (-0.0%)       -1 B  (-0.0%)
a8c-for-agencies-signup                   -56 B  (-0.1%)       -9 B  (-0.0%)
site-profiler                             -50 B  (-0.0%)      -66 B  (-0.1%)
purchase-product                          -48 B  (-0.0%)      -40 B  (-0.1%)
copy-site-flow                            -34 B  (-0.0%)     -121 B  (-0.1%)
podcasts-flow                             -33 B  (-0.0%)      -71 B  (-0.0%)
plugin-bundle-flow                        -24 B  (-0.0%)      -52 B  (-0.1%)
newsletter-post-setup-flow                -22 B  (-0.0%)      -26 B  (-0.1%)
link-in-bio-post-setup-flow               -22 B  (-0.0%)      -26 B  (-0.1%)
signup                                    -20 B  (-0.0%)      -28 B  (-0.0%)
patterns                                  +20 B  (+0.0%)      -15 B  (-0.0%)
domain-connect-authorize                  -20 B  (-0.1%)       -6 B  (-0.1%)
switch-site                               -12 B  (-0.0%)      -18 B  (-0.0%)
sensei-flow                               +11 B  (+0.0%)      -59 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~1924 bytes removed 📉 [gzipped])

Details
name                                                                              parsed_size           gzip_size
async-load-design-blocks                                                               -532 B  (-0.0%)     -282 B  (-0.0%)
async-load-design                                                                      -443 B  (-0.0%)     -245 B  (-0.0%)
async-load-design-playground                                                           -412 B  (-0.0%)     -203 B  (-0.1%)
async-load-calypso-post-editor-editor-media-modal                                      -306 B  (-0.0%)     -156 B  (-0.0%)
async-load-calypso-post-editor-media-modal                                             -234 B  (-0.0%)     -135 B  (-0.0%)
async-load-calypso-my-sites-checkout-modal                                             -192 B  (-0.0%)      -53 B  (-0.0%)
async-load-calypso-components-web-preview-component                                    -163 B  (-0.0%)     -137 B  (-0.1%)
async-load-calypso-blocks-editor-checkout-modal                                        -144 B  (-0.0%)       +5 B  (+0.0%)
async-load-signup-steps-user                                                           -110 B  (-0.1%)      -79 B  (-0.2%)
async-load-store-app-store-stats                                                        -97 B  (-0.0%)     -106 B  (-0.1%)
async-load-calypso-lib-account-settings-helper                                          -88 B  (-0.1%)      -36 B  (-0.1%)
async-load-calypso-reader-sidebar                                                       -74 B  (-0.0%)      -22 B  (-0.0%)
async-load-signup-steps-clone-credentials                                               -70 B  (-0.1%)      -67 B  (-0.2%)
async-load-signup-steps-plans-theme-preselected                                         +66 B  (+0.0%)      -41 B  (-0.0%)
async-load-signup-steps-plans                                                           +66 B  (+0.0%)      -41 B  (-0.0%)
async-load-signup-steps-rewind-form-creds                                               -58 B  (-0.1%)      -51 B  (-0.2%)
async-load-signup-steps-site                                                            -56 B  (-0.1%)      -45 B  (-0.2%)
async-load-signup-steps-emails                                                          -55 B  (-0.1%)      -39 B  (-0.1%)
async-load-store-app-store-stats-listview                                               -54 B  (-0.0%)      -41 B  (-0.1%)
async-load-signup-steps-website-content                                                 -50 B  (-0.0%)      -38 B  (-0.1%)
async-load-signup-steps-p2-site                                                         -50 B  (-0.1%)      -37 B  (-0.2%)
async-load-signup-steps-site-picker                                                     -45 B  (-0.0%)      -49 B  (-0.1%)
async-load-signup-steps-difm-site-picker                                                -45 B  (-0.0%)      -50 B  (-0.1%)
async-load-signup-steps-website-content-section-types                                   -44 B  (-0.1%)      -19 B  (-0.1%)
async-load-calypso-components-sites-popover                                             -43 B  (-0.1%)      -32 B  (-0.1%)
async-load-calypso-layout-community-translator                                          -40 B  (-0.1%)      -21 B  (-0.3%)
async-load-calypso-jetpack-cloud-sections-sidebar-navigation-manage-selected-...        -40 B  (-0.0%)      -23 B  (-0.1%)
async-load-calypso-components-jetpack-portal-nav                                        -40 B  (-0.1%)      -37 B  (-0.2%)
async-load-signup-steps-new-user-survey                                                 -38 B  (-0.1%)      -46 B  (-0.3%)
async-load-signup-steps-domains                                                         -38 B  (-0.0%)      -82 B  (-0.0%)
async-load-signup-steps-clone-point                                                     -38 B  (-0.0%)      -35 B  (-0.1%)
async-load-automattic-help-center                                                       +34 B  (+0.0%)      -60 B  (-0.0%)
async-load-signup-steps-site-options                                                    -32 B  (-0.0%)      -47 B  (-0.2%)
async-load-masterbar-launchpad-navigator                                                -30 B  (-0.1%)      -22 B  (-0.1%)
async-load-calypso-reader-list-manage                                                   -30 B  (-0.1%)      -10 B  (-0.1%)
async-load-calypso-layout-command-palette                                               -30 B  (-0.0%)      -53 B  (-0.1%)
async-load-calypso-blocks-jitm-templates-sidebar-banner                                 -30 B  (-0.1%)      -22 B  (-0.1%)
async-load-calypso-blocks-jitm-templates-notice                                         -30 B  (-0.1%)      -21 B  (-0.1%)
async-load-calypso-blocks-jitm-templates-default                                        -30 B  (-0.1%)      -23 B  (-0.2%)
async-load-calypso-notifications                                                        +28 B  (+0.0%)       +5 B  (+0.0%)
async-load-signup-steps-social-profiles                                                 -26 B  (-0.0%)      -47 B  (-0.3%)
async-load-signup-steps-page-picker                                                     -26 B  (-0.0%)      -43 B  (-0.0%)
async-load-signup-steps-clone-destination                                               -26 B  (-0.0%)      -45 B  (-0.3%)
async-load-automattic-design-preview                                                    -26 B  (-0.0%)      -35 B  (-0.0%)
async-load-design-wordpress-components-gallery                                          -24 B  (-0.0%)       -8 B  (-0.0%)
async-load-calypso-my-sites-current-site-notice                                         -24 B  (-0.0%)      -19 B  (-0.1%)
async-load-calypso-blocks-login-two-factor-authentication-two-factor-content            -22 B  (-0.1%)       -9 B  (-0.1%)
async-load-calypso-my-sites-site-settings-seo-settings-form                             -21 B  (-0.0%)      -19 B  (-0.0%)
async-load-signup-steps-store-features                                                  -20 B  (-0.0%)      -26 B  (-0.1%)
async-load-signup-steps-site-or-domain                                                  -20 B  (-0.0%)      -37 B  (-0.2%)
async-load-signup-steps-intent                                                          -20 B  (-0.0%)      -20 B  (-0.1%)
async-load-calypso-my-sites-stats-summary                                               +20 B  (+0.0%)       +7 B  (+0.0%)
async-load-signup-steps-theme-selection                                                 -18 B  (-0.0%)      -25 B  (-0.0%)
async-load-signup-steps-new-user-survey-components                                      -18 B  (-0.4%)      -15 B  (-0.9%)
async-load-purchase-modal-wrapper                                                       -18 B  (-0.0%)       +5 B  (+0.0%)
async-load-my-sites-checkout-purchase-modal-is-eligible-for-one-click-checkou...        -18 B  (-0.0%)      -10 B  (-0.0%)
async-load-calypso-my-sites-stats-pages-insights                                        +18 B  (+0.0%)       +3 B  (+0.0%)
async-load-calypso-layout-masterbar-drafts-popover                                      -18 B  (-0.1%)       -4 B  (-0.0%)
async-load-calypso-blocks-jitm-templates-home-task                                      -18 B  (-0.1%)      -10 B  (-0.1%)
async-load-signup-steps-clone-jetpack                                                   -16 B  (-0.0%)      -47 B  (-0.3%)
async-load-calypso-layout-popup-search                                                  -16 B  (-0.1%)       +6 B  (+0.1%)
async-load-calypso-layout-guided-tours-component                                        -16 B  (-0.0%)      -27 B  (-0.2%)
async-load-signup-steps-woocommerce-install-step-store-address                          -14 B  (-0.0%)      -30 B  (-0.1%)
async-load-signup-steps-starting-point                                                  -14 B  (-0.0%)      -31 B  (-0.2%)
async-load-signup-steps-p2-join-workspace                                               -14 B  (-0.0%)      -27 B  (-0.2%)
async-load-signup-steps-p2-complete-profile                                             -14 B  (-0.0%)      -51 B  (-0.2%)
async-load-signup-steps-new-or-existing-site                                            -14 B  (-0.0%)      -25 B  (-0.1%)
async-load-calypso-my-sites-stats-pages-subscribers                                     -14 B  (-0.0%)      -31 B  (-0.1%)
async-load-calypso-blocks-app-banner                                                    -14 B  (-0.0%)       -4 B  (-0.0%)
async-load-calypso-reader-site-subscriptions-manager-pending-subscriptions-ma...        -12 B  (-0.0%)       -9 B  (-0.1%)
async-load-calypso-reader-site-subscriptions-manager-comment-subscriptions-ma...        -12 B  (-0.0%)       -9 B  (-0.1%)
async-load-calypso-reader-search-stream                                                 -12 B  (-0.0%)      -18 B  (-0.1%)
async-load-calypso-layout-masterbar-checkout-tsx                                        -12 B  (-0.0%)      +13 B  (+0.0%)
async-load-calypso-layout-masterbar-checkout                                            -12 B  (-0.0%)      +16 B  (+0.1%)
async-load-calypso-components-global-notices                                            -12 B  (-0.2%)       -7 B  (-0.4%)
async-load-calypso-blocks-upload-drop-zone                                              -12 B  (-0.1%)       -6 B  (-0.2%)
async-load-automattic-design-carousel                                                   -12 B  (-0.0%)       -5 B  (-0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@DaniGuardiola DaniGuardiola left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Due to the large amount of changes, and to GitHub being annoying and not loading diffs past certain amount of files, I couldn't review every single file properly. I did review every package.json file and most of the ones that GitHub did load.

I did look for more instances of the cx name, you'll find comments on them.

import { useCallback, useEffect, useState } from '@wordpress/element';
import { registerPlugin } from '@wordpress/plugins';
import cx from 'classnames';
import cx from 'clsx';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename to clsx for consistency?

@@ -1,7 +1,7 @@
import config from '@automattic/calypso-config';
import { Button, Gridicon } from '@automattic/components';
import styled from '@emotion/styled';
import cx from 'classnames';
import cx from 'clsx';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other comment. We could rename to clsx for consistency.

@@ -2,7 +2,7 @@
import './styles.scss';
import { getDesignPreviewUrl } from '@automattic/design-picker';
import { MShotsImage, MShotsOptions } from '@automattic/onboarding';
import cx from 'classnames';
import cx from 'clsx';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other comment. We could rename to clsx for consistency.

@@ -2,7 +2,7 @@
import { useFocusTrap } from '@automattic/tour-kit';
import { __ } from '@wordpress/i18n';
import { globe, Icon, chevronUp, chevronDown } from '@wordpress/icons';
import cx from 'classnames';
import cx from 'clsx';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other comment. We could rename to clsx for consistency.

@@ -1,5 +1,5 @@
import { __ } from '@wordpress/i18n';
import cx from 'classnames';
import cx from 'clsx';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other comment. We could rename to clsx for consistency.

@tyxla

tyxla commented Jun 3, 2024

Copy link
Copy Markdown
Member Author

Thanks @DaniGuardiola 🙌

I'll follow-up with the rename in another PR - this PR is already huge as it is.

@tyxla
tyxla merged commit d2f640d into trunk Jun 3, 2024
@tyxla
tyxla deleted the try/clsx-2 branch June 3, 2024 13:57
@github-actions github-actions Bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 3, 2024
@tyxla

tyxla commented Jun 3, 2024

Copy link
Copy Markdown
Member Author

@DaniGuardiola #91413 is a follow-up PR to address your feedback from above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it Framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants