Skip to content

chore: Update Emotion to v11 - #55736

Merged
noahtallen merged 15 commits into
trunkfrom
update/emotion-11
Aug 30, 2021
Merged

noahtallen merged 15 commits into
trunkfrom
update/emotion-11

Conversation

@noahtallen

@noahtallen noahtallen commented Aug 26, 2021 •

Copy link
Copy Markdown
Contributor

Changes proposed in this Pull Request

Update Emotion packages to v11.

The main changes needed were:

  1. Rename the packages per https://emotion.sh/docs/emotion-11. (E.g. @emotion/core -> @emotion/react)
  2. Update to the new way of defining themes in Typescript (via a module declaration on @emotion/react, and then import styled directly from @emotion/styled)
  3. Manually resolve emotion 11 in storybook. Storybook internally tries to resolve emotion 10 still, which breaks things.
  4. Add some return types to appease typescript
  5. Remove manual PropTypes in some cases. Emotion 11 has better typescript support, so if the PropTypes did not exactly match the typescript types, it would fail. So I removed manual PropTypes declarations in two places. (They now rely on the Typescript prop types)

Testing instructions

  1. TeamCity should pass, other than some style issues related to use before define (fixed in Remove TS no-use-before-define rule #55806)
  2. yarn should succeed locally
  3. Storybook should work. In particular, try composite-checkout:storybook:start and verify that the components show up in the browser.
  4. yarn start/build should work.
  5. Smoke test calypso.live

@noahtallen
noahtallen requested a review from a team as a code owner August 26, 2021 02:15
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 26, 2021
@github-actions

github-actions Bot commented Aug 26, 2021 •

Copy link
Copy Markdown

@noahtallen noahtallen changed the title [chore]: Update Emotion to v11 (wip) [chore]: Update Emotion to v11 Aug 26, 2021
@matticbot

Copy link
Copy Markdown
Contributor

This PR modifies the release build for editing-toolkit

To test your changes on WordPress.com, run install-plugin.sh editing-toolkit update/emotion-11 on your sandbox.

To deploy your changes after merging, see the documentation: PCYsg-mMA-p2

@matticbot

matticbot commented Aug 27, 2021 •

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 (~499 bytes removed 📉 [gzipped])

Details
name                   parsed_size           gzip_size
entry-main                  +814 B  (+0.1%)     +195 B  (+0.1%)
entry-gutenboarding         -239 B  (-0.0%)     -637 B  (-0.1%)
entry-login                  -56 B  (-0.0%)      +57 B  (+0.0%)
entry-domains-landing        -56 B  (-0.0%)      +57 B  (+0.0%)
entry-browsehappy            -56 B  (-0.1%)      +57 B  (+0.2%)

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

Sections (~77022 bytes added 📈 [gzipped])

Details
name                          parsed_size           gzip_size
email                            +21770 B  (+4.6%)    +8535 B  (+6.2%)
plans                            +21762 B  (+3.0%)    +8303 B  (+4.1%)
site-purchases                   +20868 B  (+1.8%)    +8253 B  (+2.7%)
marketplace                      +20867 B  (+3.5%)    +8712 B  (+5.0%)
purchases                        +20778 B  (+1.5%)    +8415 B  (+2.3%)
checkout                          -1810 B  (-0.1%)     -534 B  (-0.1%)
signup                             +914 B  (+0.4%)     -332 B  (-0.6%)
jetpack-cloud-partner-portal       -652 B  (-0.3%)      -55 B  (-0.1%)
settings-security                  +339 B  (+0.1%)     +177 B  (+0.2%)
settings-discussion                +339 B  (+0.1%)     +221 B  (+0.3%)
reader                             -277 B  (-0.0%)     +407 B  (+0.3%)
settings-performance               +259 B  (+0.1%)     -481 B  (-0.4%)
wp-super-cache                     +236 B  (+0.1%)     +198 B  (+0.2%)
notification-settings              -236 B  (-0.1%)      +38 B  (+0.0%)
jetpack-cloud-pricing              +236 B  (+0.1%)     +163 B  (+0.2%)
domains                            +236 B  (+0.0%)    +1069 B  (+0.3%)
account-close                      -236 B  (-0.1%)     +115 B  (+0.1%)
privacy                            -133 B  (-0.0%)       -8 B  (-0.0%)
me                                 -133 B  (-0.0%)      -37 B  (-0.0%)
people                             +130 B  (+0.0%)     +422 B  (+0.4%)
import                             +130 B  (+0.1%)     +420 B  (+0.5%)
gutenberg-editor                   +128 B  (+0.0%)     +436 B  (+0.3%)
zoninator                          +102 B  (+0.0%)     +405 B  (+0.6%)
woocommerce-installation           +102 B  (+0.1%)     +405 B  (+0.8%)
woocommerce                        +102 B  (+0.1%)     +403 B  (+0.8%)
themes                             +102 B  (+0.0%)     +405 B  (+0.3%)
theme                              +102 B  (+0.0%)     +405 B  (+0.5%)
sites                              +102 B  (+0.1%)     +405 B  (+1.2%)
sensei                             +102 B  (+0.1%)     +405 B  (+1.1%)
scan                               +102 B  (+0.0%)     +403 B  (+0.4%)
preview                            +102 B  (+0.1%)     +405 B  (+0.9%)
migrate                            +102 B  (+0.1%)     +405 B  (+0.8%)
jetpack-search                     +102 B  (+0.1%)     +403 B  (+0.8%)
jetpack-cloud-settings             +102 B  (+0.0%)     +405 B  (+0.6%)
jetpack-cloud                      +102 B  (+0.1%)     +405 B  (+1.1%)
hosting                            +102 B  (+0.0%)     +405 B  (+0.5%)
home                               +102 B  (+0.0%)     +461 B  (+0.4%)
hello-dolly                        +102 B  (+0.1%)     +405 B  (+1.0%)
google-my-business                 +102 B  (+0.0%)     +414 B  (+0.4%)
customize                          +102 B  (+0.1%)     +405 B  (+0.8%)
concierge                          +102 B  (+0.0%)     +405 B  (+0.5%)
comments                           +102 B  (+0.0%)     +405 B  (+0.3%)
beta-testing                       +102 B  (+0.1%)     +405 B  (+0.8%)
backup                             +102 B  (+0.0%)     +403 B  (+0.3%)
activity                           +102 B  (+0.0%)     +405 B  (+0.3%)
stats                               +94 B  (+0.0%)     +331 B  (+0.2%)
export                              -81 B  (-0.0%)     -292 B  (-0.5%)
devdocs                             +77 B  (+0.0%)      +49 B  (+0.1%)
help                                +75 B  (+0.0%)      -38 B  (-0.0%)
site-blocks                         -53 B  (-0.0%)     +290 B  (+0.3%)
security                            -53 B  (-0.0%)     +350 B  (+0.2%)
posts-custom                        +53 B  (+0.0%)     -270 B  (-0.2%)
posts                               +53 B  (+0.0%)     -270 B  (-0.2%)
media                               +53 B  (+0.0%)     -481 B  (-0.1%)
marketing                           +53 B  (+0.0%)     -826 B  (-0.6%)
happychat                           -53 B  (-0.0%)     +235 B  (+0.2%)
account                             -53 B  (-0.0%)     +421 B  (+0.3%)
plugins                             -50 B  (-0.0%)     +157 B  (+0.1%)
earn                                -50 B  (-0.0%)     -205 B  (-0.2%)
settings-writing                    -28 B  (-0.0%)     -183 B  (-0.1%)
jetpack-connect                     -28 B  (-0.0%)     -142 B  (-0.1%)

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 (~2348 bytes added 📈 [gzipped])

Details
name                                                                           parsed_size           gzip_size
async-load-calypso-blocks-editor-checkout-modal                                    -1840 B  (-0.2%)     -584 B  (-0.2%)
async-load-signup-steps-plans                                                       -654 B  (-0.3%)     +273 B  (+0.4%)
async-load-calypso-blocks-inline-help-popover                                       +285 B  (+0.1%)    +1339 B  (+1.3%)
async-load-calypso-blocks-inline-help                                               +270 B  (+0.3%)      +40 B  (+0.2%)
async-load-signup-steps-plans-atomic-store                                          +183 B  (+0.1%)     +591 B  (+1.4%)
async-load-calypso-extensions-woocommerce-app-store-stats                           +183 B  (+0.1%)     +625 B  (+1.4%)
async-load-quick-language-switcher                                                  -152 B  (-0.1%)     -319 B  (-0.7%)
async-load-design-playground                                                        +134 B  (+0.0%)     -520 B  (-0.1%)
async-load-design                                                                   +134 B  (+0.0%)     -520 B  (-0.1%)
async-load-design-wordpress-components-gallery                                      -130 B  (-0.0%)     -692 B  (-0.4%)
async-load-calypso-reader-site-stream                                               -130 B  (-0.2%)     -494 B  (-2.1%)
async-load-calypso-reader-search-stream                                             -130 B  (-0.1%)     -378 B  (-1.0%)
async-load-calypso-reader-following-manage                                          -130 B  (-0.1%)     -378 B  (-0.8%)
async-load-calypso-reader-feed-stream                                               -130 B  (-0.2%)     -494 B  (-2.1%)
async-load-block-editor                                                             -130 B  (-0.0%)     -692 B  (-0.1%)
async-load-signup-steps-site-picker                                                 +102 B  (+0.1%)     +405 B  (+1.9%)
async-load-calypso-my-sites-resume-editing                                          +102 B  (+0.2%)     +405 B  (+2.0%)
async-load-calypso-layout-guided-tours-component                                    +102 B  (+0.1%)     +312 B  (+1.5%)
async-load-calypso-components-sites-popover                                         +102 B  (+0.2%)     +405 B  (+2.1%)
async-load-signup-steps-domains                                                      -72 B  (-0.0%)       +0 B
async-load-design-blocks                                                             -71 B  (-0.0%)      +27 B  (+0.0%)
async-load-calypso-post-editor-editor-media-modal                                    +31 B  (+0.0%)     -236 B  (-0.1%)
async-load-automattic-search                                                         +31 B  (+0.0%)      +65 B  (+0.2%)
async-load-publish                                                                   +27 B  (+0.1%)      +11 B  (+0.1%)
async-load-calypso-layout-guided-tours                                               +27 B  (+0.3%)      +12 B  (+0.4%)
async-load-calypso-my-sites-marketplace-pages-marketplace-plugin-setup-status        +15 B  (+0.0%)      +11 B  (+0.1%)
async-load-calypso-components-web-preview-component                                  +13 B  (+0.0%)     +411 B  (+0.3%)

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.

@noahtallen
noahtallen requested a review from a team August 27, 2021 22:15
@noahtallen noahtallen changed the title (wip) [chore]: Update Emotion to v11 [chore]: Update Emotion to v11 Aug 27, 2021

@sirbrillig sirbrillig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On behalf of Payments: the code looks good and checkout still appears to work and look correct. Thank you!

Comment thread packages/components/.storybook/main.js Resolved
@scinos

scinos commented Aug 28, 2021

Copy link
Copy Markdown
Contributor

Shouldn't we need to declare a dependency on @emotion v11 in some package.json?

@ciampo ciampo 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.

Hey Noah, great job! Thank you for looking into the migration to Emotion 11.

Although I'm not directly involved, I've had a look and left a few inline comments :)

Comment thread package.json Resolved
@noahtallen

Copy link
Copy Markdown
Contributor Author

Shouldn't we need to declare a dependency on @emotion v11 in some package.json?

According to https://emotion.sh/docs/install, we just need @emotion/react. This used to be named @emotion/core

@noahtallen

noahtallen commented Aug 30, 2021 •

Copy link
Copy Markdown
Contributor Author

I've had a look and left a few inline comments

Thanks for all the TS tips!! I'll defer to you on those, as I don't have much experience with best practices :)

@noahtallen
noahtallen requested review from a team, ciampo and scinos August 30, 2021 20:38
Comment thread apps/editing-toolkit/tsconfig.json Outdated

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.

Not for this PR, but I suspect we can remove @emotion/react from here. Probably even remove types entirely.

Comment thread client/package.json Resolved
Comment thread yarn.lock Resolved
@noahtallen
noahtallen merged commit 672b06d into trunk Aug 30, 2021
@noahtallen
noahtallen deleted the update/emotion-11 branch August 30, 2021 22:26
@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 Aug 30, 2021
noahtallen added a commit that referenced this pull request Aug 30, 2021
noahtallen added a commit that referenced this pull request Aug 30, 2021
@noahtallen
noahtallen restored the update/emotion-11 branch August 30, 2021 23:02
@ciampo

ciampo commented Aug 31, 2021

Copy link
Copy Markdown
Contributor

Manually resolve emotion 11 in storybook. Storybook internally tries to resolve emotion 10 still, which breaks things.

It looks like Storybook won't support Emotion 11 for a while, and that potentially may move away from Emotion at some point: storybookjs/storybook#13145 (comment)

@noahtallen noahtallen changed the title [chore]: Update Emotion to v11 chore: Update Emotion to v11 Sep 3, 2021
@rrsai

rrsai commented Dec 3, 2021 •

Copy link
Copy Markdown

After much debugging of the clash between versions of emotion used in storybook and in app, and for those who come after me, I found that storybook has now provided a feature flag to avoid clashing with later versions of emotion: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#emotion11-quasi-compatibility
I tested it and it works well to prevent emotion version-out-of-sync problems in storybook, and is a 3 line change.

@noahtallen

noahtallen commented Dec 6, 2021 •

Copy link
Copy Markdown
Contributor Author

I found that storybook has now provided a feature flag to avoid clashing with later versions of emotion

Nice find! Edit: Since it's only available in newer versions, I'm looking at doing that in #58880

@noahtallen noahtallen mentioned this pull request Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants