diff --git a/package.json b/package.json index 29fd214e2..2ab26551f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "eslint-plugin-standard": "^3.0.1", "flow-bin": "^0.61.0", "gatsby-react-router-scroll": "^1.0.7", + "get-lerna-packages": "^0.1.0", "hoist-non-react-statics": "^2.3.1", "jest": "^21.2.1", "jest-cli": "^20.0.4", diff --git a/packages/create-emotion-styled/package.json b/packages/create-emotion-styled/package.json index 03d5f414f..99c3a2a84 100644 --- a/packages/create-emotion-styled/package.json +++ b/packages/create-emotion-styled/package.json @@ -16,7 +16,7 @@ "watch": "rollup -c ../../rollup.config.js --watch" }, "dependencies": { - "@emotion/is-prop-valid": "^0.5.2", + "@emotion/is-prop-valid": "^0.6.1", "emotion-utils": "^9.1.0" }, "peerDependencies": { diff --git a/packages/create-emotion-styled/src/utils.js b/packages/create-emotion-styled/src/utils.js index 6282f3a31..0cab1e1f4 100644 --- a/packages/create-emotion-styled/src/utils.js +++ b/packages/create-emotion-styled/src/utils.js @@ -1,5 +1,4 @@ // @flow -import { memoize } from 'emotion-utils' import isPropValid from '@emotion/is-prop-valid' import type { Interpolations } from 'create-emotion' @@ -7,9 +6,8 @@ export function setTheme(theme: Object) { this.setState({ theme }) } -export const testPickPropsOnStringTag: (key: string) => boolean = memoize( - isPropValid -) +export const testPickPropsOnStringTag = isPropValid + export const testPickPropsOnComponent = (key: string) => key !== 'theme' && key !== 'innerRef' export const testAlwaysTrue = () => true diff --git a/packages/emotion-utils/package.json b/packages/emotion-utils/package.json index 23b19334f..26105415b 100644 --- a/packages/emotion-utils/package.json +++ b/packages/emotion-utils/package.json @@ -28,6 +28,9 @@ "bugs": { "url": "https://github.com/emotion-js/emotion/issues" }, + "dependencies": { + "@emotion/memoize": "^0.6.1" + }, "devDependencies": { "babel-plugin-emotion": "^8.0.2-7", "npm-run-all": "^4.0.2", diff --git a/packages/emotion-utils/src/index.js b/packages/emotion-utils/src/index.js index a362010b4..d7abc4674 100644 --- a/packages/emotion-utils/src/index.js +++ b/packages/emotion-utils/src/index.js @@ -1,12 +1,6 @@ // @flow -export const memoize = (fn: string => any) => { - const cache = {} - return (arg: string) => { - if (cache[arg] === undefined) cache[arg] = fn(arg) - return cache[arg] - } -} +export { default as memoize } from '@emotion/memoize' export const STYLES_KEY = '__emotion_styles' diff --git a/rollup.config.js b/rollup.config.js index ecd47b5de..c1de21fab 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,8 +5,12 @@ import babel from 'rollup-plugin-babel' import alias from 'rollup-plugin-alias' import cjs from 'rollup-plugin-commonjs' import path from 'path' +import getLernaPackages from 'get-lerna-packages' import { rollup as lernaAliases } from 'lerna-alias' +const flatMap = (iteratee, arr) => [].concat(...arr.map(iteratee)) +const uniq = arr => [...new Set(arr)] + const pkg = require(path.resolve(process.cwd(), './package.json')) const basePlugins = [ @@ -40,13 +44,18 @@ const baseConfig = { const baseExternal = ['react', 'prop-types', 'preact'] const mainConfig = Object.assign({}, baseConfig, { - external: baseExternal.concat([ - 'emotion', - 'emotion-utils', - 'hoist-non-react-statics', - 'stylis-rule-sheet', - '@emotion/is-prop-valid' - ]), + external: uniq( + baseExternal.concat( + flatMap(dir => { + const { + dependencies = {}, + peerDependencies = {} + } = require(`${dir}/package.json`) + + return [...Object.keys(dependencies), ...Object.keys(peerDependencies)] + }, getLernaPackages()) + ) + ), plugins: basePlugins, output: [ { file: pkg.main, format: 'cjs' }, diff --git a/yarn.lock b/yarn.lock index b37d0b396..9607fd0a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -659,9 +659,15 @@ unist-util-remove-position "^1.1.1" xtend "^4.0.1" -"@emotion/is-prop-valid@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.5.2.tgz#4f47717c2bcce8759e11997520e6bcb14326f54a" +"@emotion/is-prop-valid@^0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.6.1.tgz#98a255ac341064ddcf0d84f823b45ae9fb228f91" + dependencies: + "@emotion/memoize" "^0.6.1" + +"@emotion/memoize@^0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.6.1.tgz#b2de5184e49f518b7115a5e6d0e727643ec531cf" "@types/node@*": version "8.0.49" @@ -3524,14 +3530,6 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" -create-react-class@^15.6.0: - version "15.6.3" - resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.3.tgz#2d73237fb3f970ae6ebe011a9e66f46dbca80036" - dependencies: - fbjs "^0.8.9" - loose-envify "^1.3.1" - object-assign "^4.1.1" - cross-env@^3.1.1: version "3.2.4" resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-3.2.4.tgz#9e0585f277864ed421ce756f81a980ff0d698aba" @@ -5875,6 +5873,12 @@ get-caller-file@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5" +get-lerna-packages@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/get-lerna-packages/-/get-lerna-packages-0.1.0.tgz#f7cf4b358584d98f24cd931451e56ee9d37094e5" + dependencies: + glob "^7.1.2" + get-params@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/get-params/-/get-params-0.1.2.tgz#bae0dfaba588a0c60d7834c0d8dc2ff60eeef2fe" @@ -11032,16 +11036,7 @@ react-dev-utils@^4.2.1: strip-ansi "3.0.1" text-table "0.2.0" -react-dom@^15.6.0: - version "15.6.2" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.2.tgz#41cfadf693b757faf2708443a1d1fd5a02bef730" - dependencies: - fbjs "^0.8.9" - loose-envify "^1.1.0" - object-assign "^4.1.0" - prop-types "^15.5.10" - -react-dom@^16.0.0, react-dom@^16.2.0: +react-dom@^15.6.0, react-dom@^16.0.0, react-dom@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.2.0.tgz#69003178601c0ca19b709b33a83369fe6124c044" dependencies: @@ -11155,17 +11150,7 @@ react-test-renderer@^16.2.0: object-assign "^4.1.1" prop-types "^15.6.0" -react@^15.6.0: - version "15.6.2" - resolved "https://registry.yarnpkg.com/react/-/react-15.6.2.tgz#dba0434ab439cfe82f108f0f511663908179aa72" - dependencies: - create-react-class "^15.6.0" - fbjs "^0.8.9" - loose-envify "^1.1.0" - object-assign "^4.1.0" - prop-types "^15.5.10" - -react@^16.0.0, react@^16.2.0: +react@^15.6.0, react@^16.0.0, react@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba" dependencies: