Skip to content
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

Move Emotion and MDX packages to peerDeps #1867

Merged
merged 7 commits into from Dec 21, 2021
Merged

Move Emotion and MDX packages to peerDeps #1867

merged 7 commits into from Dec 21, 2021

Conversation

hasparus
Copy link
Member

@hasparus hasparus commented Jul 19, 2021

Having Emotion and MDX packages in dependencies leads to a bunch of problems that repeatedly popped up over last few years.

In general, if something depends on a React context, we can't really hide it as dependency from the user, as a version conflict can lead to a context mismatch (we pass the theme to context, but it's read from another one).

We install Emotion for the user, but the abstraction leaks — without knowing that we use Emotion these context mismatch errors can be absurdly hard to debug.

Changes in this PR:

  • Move @emotion/react and @emotion/styled to peer deps.
  • Move MDX packages to peer deps.
  • Adapt all npm install guildelines to include peerDeps.
  • Write release notes describing the breaking change.

Connected issues:

Release notes

BREAKING CHANGE: @emotion/react and @mdx-js/react were moved to peerDependencies of theme-ui, @theme-ui/mdx and @theme-ui/sidenav and must be installed separately. This is a revert of change from Theme UI v0.3, and it's meant to help solve version clashes and context mismatch bugs on user side. Connected issues: #1793, #1531, #1530, #1388, #1345, #1130.


📦 Published PR as canary version: 0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0

✨ Test out this PR locally via:

npm install @theme-ui/color-modes@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/color@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/components@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/core@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/css@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/custom-properties@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/editor@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install gatsby-plugin-theme-ui@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install gatsby-theme-style-guide@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install gatsby-theme-ui-layout@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/match-media@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/mdx@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/parse-props@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-base@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-bootstrap@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-bulma@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-dark@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-deep@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-funk@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-future@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-polaris@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-roboto@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-sketchy@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-swiss@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-system@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-tailwind@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/preset-tosh@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/presets@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/prism@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/sidenav@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/style-guide@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/tailwind@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/theme-provider@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install theme-ui@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
npm install @theme-ui/typography@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
# or 
yarn add @theme-ui/color-modes@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/color@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/components@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/core@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/css@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/custom-properties@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/editor@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add gatsby-plugin-theme-ui@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add gatsby-theme-style-guide@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add gatsby-theme-ui-layout@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/match-media@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/mdx@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/parse-props@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-base@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-bootstrap@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-bulma@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-dark@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-deep@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-funk@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-future@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-polaris@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-roboto@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-sketchy@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-swiss@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-system@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-tailwind@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/preset-tosh@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/presets@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/prism@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/sidenav@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/style-guide@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/tailwind@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/theme-provider@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add theme-ui@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0
yarn add @theme-ui/typography@0.13.0--canary.1867.408bee0d2d84fbaf22e6f2ca925d50f4c82ad1db.0

@hasparus hasparus added this to the v0.10 milestone Jul 19, 2021
@vercel
Copy link

vercel bot commented Jul 19, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/systemui/theme-ui/8fMZ6Yf9pT7wW2dLr8bLwsCFKDFZ
✅ Preview: https://theme-ui-git-peer-deps-systemui.vercel.app

@hasparus hasparus added the minor Increment the minor version when merged label Jul 19, 2021
@Swizec
Copy link

Swizec commented Nov 16, 2021

Any prediction when this is getting merged? We keep tripping over it every few months when someone tries to upgrade packages.

Copy link
Collaborator

@flo-sch flo-sch left a comment

Choose a reason for hiding this comment

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

Just some imports I am not fully sure about

packages/core/package.json Show resolved Hide resolved
packages/parse-props/package.json Outdated Show resolved Hide resolved
@hasparus
Copy link
Member Author

@Swizec, I'll reluctantly say soon™. It's been a while since somebody messaged about this problem so I hoped other libs updated to Emotion 11 and it's not occuring so often 😓

@Swizec
Copy link

Swizec commented Nov 17, 2021

@hasparus we recently ran into it because everything updated to latest. But it was like emotion 11.6.0 in one place and 11.5.0 in another 💩

Made up example version numbers but something like that. We had to carefully ensure everything used the exact same version and it was a pain to figure out what the problem was.

Copy link
Collaborator

@beerose beerose left a comment

Choose a reason for hiding this comment

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

(was asked by @hasparus to take a look at this PR)

LGTM

@hasparus hasparus merged commit 07e067c into develop Dec 21, 2021
@hasparus hasparus deleted the peer-deps branch December 21, 2021 17:53
@hasparus
Copy link
Member Author

🚀 PR was released in v0.13.0 🚀

@hasparus hasparus added the released This issue/pull request has been released. label Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use peerDependencies to avoid context provider version clash
4 participants