Loading a second emotion bundle shouldn't break the first
See original GitHub issueCurrent behavior:
I’m trying to run emotion 11 in a browser extension content script. The trouble is if that content script then runs in a page that is already running an emotion 11 app, then the app styles break. After a chat with @Andarist on the emotion-slack, he suggested I open an issue here and that this is probably the culprit: https://github.com/emotion-js/emotion/blob/1e10d8c9aa91ce443d29661a7f830190d42aae92/packages/cache/src/index.js#L55-L60
To reproduce:
- Build and install a browser extension that uses emotion 11 in a content script (I’ve made a test extension here: https://github.com/craigsketchley/emotion-11-extension).
- Visit a page that uses emotion 11 in production mode (I’ve made a test app here: https://github.com/craigsketchley/emotion-11-app).
- Watch styles break as soon as the content script loads.
Expected behavior:
Loading a second bundle which includes emotion 11 shouldn’t break the styles of the existing emotion 11 app already running in the page.
Environment information:
In the app and extension:
react
version: 16.13.1@emotion/cache
version: 11.0.0-next.13@emotion/react
version: 11.0.0-next.13@emotion/styled
version: 11.0.0-next.13
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Emotion 11
Emotion 11 is a slight evolution over the Emotion 10. It focuses mainly on the developer experience, TS types improvements, switches internals to...
Read more >External component libraries using emotion not rendering ...
When the page first loads my components, none of the emotion injected styles are active on the components, and then after a second...
Read more >Why We're Breaking Up with CSS-in-JS - DEV Community
I'm using Emotion with server-side rendering and MUI/Mantine/(another Emotion-powered component library) and it's not working because... While ...
Read more >Rising Strong by Brené Brown - Book Summary - MeaningfulHQ
Brown tells us that our bodies respond to EMOTION FIRST, and they often direct us ... We can't pack down hurt, nor can...
Read more >FAQs - styled-components
If you are a library author, we recommend that you should not bundle and ship styled-components module with your library. There are two...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I finally got to it and prepared a PR for this, you can track it here: https://github.com/emotion-js/emotion/pull/2028
@Andarist sorry for the false alarm. I have a project inside a monorepo with multiple yarn workspaces and packages, and somehow the webpack bundled older version of /styled and /react package from the root folder causing the issue. Running “yarn upgrade” in the root of the repo and then in the extension workspace solved the problem