babel-plugin-emotion
Advanced tools
Comparing version 7.3.1 to 7.3.2
@@ -32,3 +32,3 @@ 'use strict'; | ||
var importedNames = specifiers.filter(function (v) { | ||
return ['default', 'css'].includes(v.imported); | ||
return ['default', 'css', 'keyframes', 'injectGlobal', 'fontFace'].indexOf(v.imported) !== -1; | ||
}).reduce(function (acc, _ref2) { | ||
@@ -109,18 +109,16 @@ var _extends2; | ||
} else if (t.isIdentifier(path.node.tag)) { | ||
if (path.node.tag.name === state.importedNames.css) { | ||
replaceCssWithCallExpression(path, t.identifier(state.importedNames.css), state, t); | ||
} else if (path.node.tag.name === 'keyframes') { | ||
replaceCssWithCallExpression(path, t.identifier('keyframes'), state, t, function (name, hash, src) { | ||
if (path.node.tag.name === state.importedNames.css || path.node.tag === state.cssPropIdentifier) { | ||
replaceCssWithCallExpression(path, path.node.tag, state, t); | ||
} else if (path.node.tag.name === state.importedNames.keyframes) { | ||
replaceCssWithCallExpression(path, path.node.tag, state, t, function (name, hash, src) { | ||
return '@keyframes ' + name + '-' + hash + ' { ' + src + ' }'; | ||
}); | ||
} else if (path.node.tag.name === 'fontFace') { | ||
replaceCssWithCallExpression(path, t.identifier('fontFace'), state, t, function (name, hash, src) { | ||
} else if (path.node.tag.name === state.importedNames.fontFace) { | ||
replaceCssWithCallExpression(path, path.node.tag, state, t, function (name, hash, src) { | ||
return '@font-face {' + src + '}'; | ||
}, true); | ||
} else if (path.node.tag.name === 'injectGlobal') { | ||
replaceCssWithCallExpression(path, t.identifier('injectGlobal'), state, t, function (name, hash, src) { | ||
} else if (path.node.tag.name === state.importedNames.injectGlobal) { | ||
replaceCssWithCallExpression(path, path.node.tag, state, t, function (name, hash, src) { | ||
return src; | ||
}, true); | ||
} else if (state.cssPropIdentifier && path.node.tag === state.cssPropIdentifier) { | ||
replaceCssWithCallExpression(path, state.cssPropIdentifier, state, t); | ||
} | ||
@@ -340,3 +338,6 @@ } | ||
styled: 'styled', | ||
css: 'css' | ||
css: 'css', | ||
keyframes: 'keyframes', | ||
injectGlobal: 'injectGlobal', | ||
fontFace: 'fontFace' | ||
}; |
{ | ||
"name": "babel-plugin-emotion", | ||
"version": "7.3.1", | ||
"version": "7.3.2", | ||
"description": "A recommended babel preprocessing plugin for emotion, the The Next Generation of CSS-in-JS.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -233,3 +233,6 @@ // @flow weak | ||
styled: 'styled', | ||
css: 'css' | ||
css: 'css', | ||
keyframes: 'keyframes', | ||
injectGlobal: 'injectGlobal', | ||
fontFace: 'fontFace' | ||
} | ||
@@ -254,3 +257,12 @@ | ||
const importedNames = specifiers | ||
.filter(v => ['default', 'css'].includes(v.imported)) | ||
.filter( | ||
v => | ||
[ | ||
'default', | ||
'css', | ||
'keyframes', | ||
'injectGlobal', | ||
'fontFace' | ||
].indexOf(v.imported) !== -1 | ||
) | ||
.reduce( | ||
@@ -388,21 +400,19 @@ (acc, { imported, local }) => ({ | ||
} else if (t.isIdentifier(path.node.tag)) { | ||
if (path.node.tag.name === state.importedNames.css) { | ||
if ( | ||
path.node.tag.name === state.importedNames.css || | ||
path.node.tag === state.cssPropIdentifier | ||
) { | ||
replaceCssWithCallExpression(path, path.node.tag, state, t) | ||
} else if (path.node.tag.name === state.importedNames.keyframes) { | ||
replaceCssWithCallExpression( | ||
path, | ||
t.identifier(state.importedNames.css), | ||
path.node.tag, | ||
state, | ||
t | ||
) | ||
} else if (path.node.tag.name === 'keyframes') { | ||
replaceCssWithCallExpression( | ||
path, | ||
t.identifier('keyframes'), | ||
state, | ||
t, | ||
(name, hash, src) => `@keyframes ${name}-${hash} { ${src} }` | ||
) | ||
} else if (path.node.tag.name === 'fontFace') { | ||
} else if (path.node.tag.name === state.importedNames.fontFace) { | ||
replaceCssWithCallExpression( | ||
path, | ||
t.identifier('fontFace'), | ||
path.node.tag, | ||
state, | ||
@@ -413,6 +423,6 @@ t, | ||
) | ||
} else if (path.node.tag.name === 'injectGlobal') { | ||
} else if (path.node.tag.name === state.importedNames.injectGlobal) { | ||
replaceCssWithCallExpression( | ||
path, | ||
t.identifier('injectGlobal'), | ||
path.node.tag, | ||
state, | ||
@@ -423,12 +433,2 @@ t, | ||
) | ||
} else if ( | ||
state.cssPropIdentifier && | ||
path.node.tag === state.cssPropIdentifier | ||
) { | ||
replaceCssWithCallExpression( | ||
path, | ||
state.cssPropIdentifier, | ||
state, | ||
t | ||
) | ||
} | ||
@@ -435,0 +435,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78916
2128