-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Dependencies] Update Emotion 10 to 11 #910
Conversation
…r of moduleNameMapper
@@ -158,8 +158,8 @@ | |||
"tinycolor2": "^1.4.1" | |||
}, | |||
"peerDependencies": { | |||
"@emotion/core": "10.0.35", | |||
"@emotion/styled": "10.0.27", | |||
"@emotion/react": "~11.4.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit risky, because in the past even patch version changes have caused regressions: #136
However we can see if that was just a one-off and not something that happens most of the time, which gives some more flexibility in the compatible versions.
Longer-term we might want a stronger/more explicit strategy for the shared dependencies in our consumer repos.
This reverts commit d9a2b75.
I'm so excited for this! @michaeljaltamirano you got it figured out so soon. I'll take a look sometime soon, but ultimately, I'll leave it up to @chrisq21 to approve as the Gatsby v3 upgrade is now relevant to his cycle project. |
|
||
&:visited, | ||
&:hover { | ||
opacity: 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we no longer want to change the opacity
and color
on visited
and hover
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah never mind, this makes sense since those values weren’t actually being changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, and it seems like the redundant styling, paired with how we apply conditional styles, is part of what is causing the CI issues. 🤷
* Until Storybook migrates its own internal @emotion usage from | ||
* v10 to v11, this allows us to maintain compatibility | ||
*/ | ||
const emotion11CompatibleConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, nice discovery.
|
||
declare module '@emotion/react' { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface Theme extends ThemeType {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we no longer need those files (this PR removes those equivalents here). This file will be the new standard: https://emotion.sh/docs/typescript#define-a-theme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Thanks for setting up this update so quickly.
We'll be doing a lot of regression testing on the Gatsby V3 update, so I'll let you know if we find any radiance-ui
or emotion
related issues.
Side-note: I wasn't aware of the Chromatic visual UI tool. That sounds really useful.
* [Dependencies] Update Emotion 10 to 11 (#910) * Bump all emotion packages to ^11, update emotion peerDependencies * WIP * Prefer useTheme over in-line usage that pulls in context anyway * Undo preset change * Try and update stylis version for test fix * Restore babel config, remove moduleDirectories src resolution in favor of moduleNameMapper * Restore some dependencies too * Update snapshots for new stylis version * Add Storybook emotion 11 compat * Remove some since-deleted files * Remove styled-base (included in styled, now) * Use new styled base import path to fix build * Add styled/base comment to memorialize inclusion * Try babel plugin instead for test-js regression test * Bump emotion/react * Try again without css prop plugin * Attempt to bust cache in CI * Restore css preset usage * Use built-in wrapper after fixing overwrite issue * Nest test (it) blocks in describe block * Bump @emotion packages * Test arrow on CI regression with portal container * Test container, no child * Try modifying hover selector for consistency * Try inherit * Force snapshots to update in CI after new style was not expected to show up but did (seems buggy) * Undo CI changes * Update snapshots * Fix css prop typing in stories directory * Try swapping alphabetization of hover and visited * Revert "Try swapping alphabetization of hover and visited" This reverts commit 1fc1e6a. * Try without cache * Reduce diff * Clean up stylis artifacts * Try another DialogModal change * Try more specific selector syntax * Test out what happens when we remove the initial snapshots, to see if the other new snapshots now break * Try with css usage * Try with separating svg styling for Field * Restore runInBand * Remove redundant disabled opacity text color style * Try with no cache * Try and simplify carousel styles to try and fix jest serializer * Play snapshot roulette again * Dedupe * Upgrade emotion, suppress storybook webpack babel warning * Try CI cache bust, it is reaching into other branches like the browserslist PR * Skip difficult tests * Adjust test threshold after skipping tests * Reduce config.yml diff * Some cleanup, skip precisely snapshots, not other tests * Set emotion version to patch-level * Diff reduction * Undo roundButton diff * Reduce button and field diff * Revert arrow test changes * Revert carousel style diff * Remove redundant disabled style * Try with portal container again * Revert "Undo roundButton diff" This reverts commit d9a2b75. * [TypeScript] Prefer React.FC For Component Typing (#983) * Prefer React.FC for component typing, fix prop-types errors, export Icon type * Refine code comment * Ignore new exported prop type, fix Alert component definition * Update BORDER_RADIUS_PROP_TYPES internals * Fix some storybook prop typing issues * v22.0.0-beta.1 * DialogModal type refinement (#984) * v22.0.0-beta.3 * Unskip carousel briefly * Skip carousel again * [Emotion] Prefer autoLabel: true for output (#1001) * [Container] Moves types-only definition into types.ts file (#1003) * [Tooltip] Modify Hover Logic (#1002) * Misc asterisk fix * Move body styling into TooltipBox, remove Global style application * Update test config * Drop threshold down 1%
What and Why
This PR updates our
@emotion
dependency to use version 11 instead of version 10. See docs for more details.eslint-plugin-emotion
is now@emotion/eslint-plugin
)@emotion/pkg-renaming
eslint rule (with--fix
) as codemodpaths
usage in favor of new emotion.d.ts standardstorybook
is compatible with our version 11 usage (since it still relies on version 10 internally)babel
warning to make an implied setting explicityarn run test -u
to update the snapshots with the new serializer logic.emotion
classnames (e.g.emotion-0
) with other classnames.Skipped Snapshot Tests
This PR has been so long-standing because there has been a snapshot serialization regression in CI that I've tried long and hard without success to debug. It happens as follows:
src/shared-components/field/test.tsx
, fully failed in CI.radiance-ui
repository from that SSH instance to my local disk, and then running the test suite locally was not able to reproduce the issue.I'm not sure why I can't find instances of this in CI, but here is a link where you can see the failing snapshots, and see that the issue is that the serialization order is changing very insigificantly, but nothing else: https://app.circleci.com/pipelines/github/curology/radiance-ui/2469/workflows/65276136-7360-4103-9e7e-41dff0a89393/jobs/7590/parallel-runs/0/steps/0-105
UPDATE: I actually ran into this again while trying to reduce the diff to make the PR easier to review, and also to remove all trace of my attempts to work around the issue. Interestingly, just changing the syntax of applying styles conditionally (PR diff, to fix the issue) broke the order of the serialized styles (CI link). This suggests that the fix to the other issues might be similarly more explicitly falsy/nullish handling. One additional test on the Accordion component was not successful, though, so the instances that cause it may be non-obvious.
Ultimately, I decided to skip these snapshot tests entirely. Now that we have visual regression testing, they are already of diminished value. I also kept the non-snapshot tests in the component tests, if present.
Considerations
@emotion
, since we rely on it so heavily, but doing so would also allow us to more easily experiment with other 3rd party libraries that have no runtime element, like Linaria.Release Plan
This PR is based to
next
. After it is merged in, I will cut a beta version ofradiance-ui@^22.x.x
. I will pull this into my own consumer app for testing, and it can also be pulled into ourgatsby
pages for testing. This will allow us to:radiance-ui@^21.x.x
without emotion major version changes blocking in.22.0.0
instead of immediately patching it.