File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @emotion/react ' : patch
3
+ ---
4
+
5
+ Fix error loading @emotion/react in alternative JS environments
Original file line number Diff line number Diff line change @@ -20,7 +20,14 @@ if (process.env.NODE_ENV !== 'production') {
20
20
const isJest = typeof jest !== 'undefined'
21
21
22
22
if ( isBrowser && ! isJest ) {
23
- const globalContext = isBrowser ? window : global
23
+ // globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
24
+ const globalContext =
25
+ // $FlowIgnore
26
+ typeof globalThis !== 'undefined'
27
+ ? globalThis // eslint-disable-line no-undef
28
+ : isBrowser
29
+ ? window
30
+ : global
24
31
const globalKey = `__EMOTION_REACT_${ pkg . version . split ( '.' ) [ 0 ] } __`
25
32
if ( globalContext [ globalKey ] ) {
26
33
console . warn (
You can’t perform that action at this time.
0 commit comments