Skip to content

Commit

Permalink
chore: upgrade to babel-plugin-emotion
Browse files Browse the repository at this point in the history
I didn't do __extensive__ testing, but the tests pass and @kentcdodds said there were no breaking changes…

fixes #515
  • Loading branch information
Haroenv committed Jan 9, 2018
1 parent b1db578 commit d579245
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"babel-eslint": "^7.2.3",
"babel-flow-types": "^1.2.2",
"babel-jest": "^20.0.3",
"babel-macros": "^1.2.0",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-closure-elimination": "^1.3.0",
"babel-plugin-codegen": "^1.2.0",
"babel-plugin-external-helpers": "^6.22.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ from `createEmotion`,

## Babel Macros

Instead of using `babel-plugin-emotion`, you can use emotion with [`babel-macros`](https://github.com/kentcdodds/babel-macros). Add `babel-macros` to your babel config and import whatever you want from emotion but add `/macro` to the end. Currently every API except for the css prop is supported by the macro.
Instead of using `babel-plugin-emotion`, you can use emotion with [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros). Add `babel-plugin-macros` to your babel config and import whatever you want from emotion but add `/macro` to the end. Currently every API except for the css prop is supported by the macro.

```jsx
import styled from 'react-emotion/macro'
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@babel/helper-module-imports": "7.0.0-beta.32",
"babel-macros": "^1.2.0",
"babel-plugin-macros": "^2.0.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"convert-source-map": "^1.5.0",
"emotion-utils": "^9.0.0-0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/src/macro-styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from './index'
import { buildMacroRuntimeNode, omit } from './babel-utils'
import emotionMacro from './macro'
import { createMacro } from 'babel-macros'
import { createMacro } from 'babel-plugin-macros'

module.exports = createMacro(macro)

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/src/macro.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import { replaceCssWithCallExpression } from './index'
import { buildMacroRuntimeNode, addRuntimeImports } from './babel-utils'
import { createMacro } from 'babel-macros'
import { createMacro } from 'babel-plugin-macros'

module.exports = createMacro(macro)

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/test/macro/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"env",
{
"loose": true,
"exclude": ["transform-es2015-typeof-symbol"]
"exclude": ["transform-es2015-typeof-symbol"]
}
],
"stage-0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ require('module-alias').addAliases({
'emotion/macro': path.join(__dirname, '../../src/macro')
})

module.exports = require('babel-macros')
module.exports = require('babel-plugin-macros')
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const createMacroTester = transform => opts => {
transform(opts.code, {
plugins: [
[
require('babel-macros'),
require('babel-plugin-macros'),
{
...opts.opts
}
Expand Down
2 changes: 1 addition & 1 deletion packages/benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"babel-loader": "^7.1.1",
"babel-macros": "^1.0.2",
"babel-plugin-macros": "^2.0.0",
"babel-polyfill": "^6.26.0",
"cli-chart": "^0.3.1",
"cli-table": "^0.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/benchmarks/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
'react',
'stage-0'
],
plugins: ['babel-macros'],
plugins: ['babel-plugin-macros'],
cacheDirectory: true
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/emotion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ minimizes the runtime cost of css-in-js dramatically by parsing your styles with
- [fontFace](https://github.com/emotion-js/emotion/tree/master/docs/font-face.md)
- [injectGlobal](https://github.com/emotion-js/emotion/tree/master/docs/inject-global.md)

- [Usage with babel-macros](https://github.com/emotion-js/emotion/tree/master/docs/babel.md#usage-with-babel-macros)
- [Usage with babel-plugin-macros](https://github.com/emotion-js/emotion/tree/master/docs/babel.md#usage-with-babel-macros)
- [Usage with Preact](https://github.com/emotion-js/emotion/tree/master/docs/preact.md)

- Ecosystem
Expand Down
8 changes: 7 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ babel-loader@^7.1.1:
loader-utils "^1.0.2"
mkdirp "^0.5.1"

babel-macros@^1.0.0, babel-macros@^1.0.2:
babel-macros@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/babel-macros/-/babel-macros-1.0.2.tgz#04475889990243cc58a0afb5ea3308ec6b89e797"

Expand Down Expand Up @@ -1453,6 +1453,12 @@ babel-plugin-jest-hoist@^21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-21.2.0.tgz#2cef637259bd4b628a6cace039de5fcd14dbb006"

babel-plugin-macros@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-2.0.0.tgz#fd3aee135f7dec0b82898b7c8f1aed6fa75f9af9"
dependencies:
cosmiconfig "3.1.0"

babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
Expand Down

0 comments on commit d579245

Please sign in to comment.