Skip to content

Commit

Permalink
Remove react native bundles for core and cache in favour of different…
Browse files Browse the repository at this point in the history
… isBrowser detection (#1482)
  • Loading branch information
emmatown committed Aug 27, 2019
1 parent 66cda64 commit 10514a8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .changeset/popular-mayflies-sell/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"releases": [
{ "name": "@emotion/cache", "type": "patch" },
{ "name": "@emotion/core", "type": "patch" }
],
"dependents": []
}
1 change: 1 addition & 0 deletions .changeset/popular-mayflies-sell/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove react native bundles in favour of different isBrowser detection
8 changes: 0 additions & 8 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
"./dist/cache.cjs.js": "./dist/cache.browser.cjs.js",
"./dist/cache.esm.js": "./dist/cache.browser.esm.js"
},
"react-native": {
"./dist/cache.cjs.js": "./dist/cache.native.cjs.js",
"./dist/cache.esm.js": "./dist/cache.native.esm.js"
},
"sketch": {
"./dist/cache.cjs.js": "./dist/cache.native.cjs.js",
"./dist/cache.esm.js": "./dist/cache.native.esm.js"
},
"types": "types/index.d.ts",
"license": "MIT",
"repository": "https://github.com/emotion-js/emotion/tree/master/packages/cache",
Expand Down
8 changes: 0 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
"./dist/core.cjs.js": "./dist/core.browser.cjs.js",
"./dist/core.esm.js": "./dist/core.browser.esm.js"
},
"react-native": {
"./dist/core.cjs.js": "./dist/core.native.cjs.js",
"./dist/core.esm.js": "./dist/core.native.esm.js"
},
"sketch": {
"./dist/core.cjs.js": "./dist/core.native.cjs.js",
"./dist/core.esm.js": "./dist/core.native.esm.js"
},
"types": "types/index.d.ts",
"files": [
"src",
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import createCache from '@emotion/cache'
import { isBrowser } from './utils'

let EmotionCacheContext: React.Context<EmotionCache | null> = React.createContext(
isBrowser ? createCache() : null
// we're doing this to avoid preconstruct's dead code elimination in this one case
// because this module is primarily intended for the browser and node
// but it's also required in react native and similar environments sometimes
// and we could have a special build just for that
// but this is much easier and the native packages
// might use a different theme context in the future anyway
typeof HTMLElement !== 'undefined' ? createCache() : null
)

export let ThemeContext = React.createContext<Object>({})
Expand Down

0 comments on commit 10514a8

Please sign in to comment.