babel-plugin-emotion
Advanced tools
Comparing version 8.0.6 to 8.0.9
@@ -9,2 +9,3 @@ 'use strict'; | ||
exports.hashArray = hashArray; | ||
exports.hoistPureArgs = hoistPureArgs; | ||
exports.replaceCssWithCallExpression = replaceCssWithCallExpression; | ||
@@ -76,2 +77,11 @@ exports.buildStyledCallExpression = buildStyledCallExpression; | ||
(0, _cssProp2.default)(path, state, t); | ||
if (state.opts.hoist) { | ||
path.traverse({ | ||
CallExpression: function CallExpression(callExprPath) { | ||
if (callExprPath.node.callee.name === state.importedNames.css || callExprPath.node.callee.name === '_' + state.importedNames.css) { | ||
hoistPureArgs(callExprPath); | ||
} | ||
} | ||
}); | ||
} | ||
}, | ||
@@ -102,2 +112,6 @@ CallExpression: function CallExpression(path, state) { | ||
path.replaceWith(buildStyledObjectCallExpression(path, state, identifier, t)); | ||
if (state.opts.hoist) { | ||
hoistPureArgs(path); | ||
} | ||
} | ||
@@ -177,2 +191,14 @@ } catch (e) { | ||
function hoistPureArgs(path) { | ||
var args = path.get('arguments'); | ||
if (args && Array.isArray(args)) { | ||
args.forEach(function (arg) { | ||
if (!arg.isIdentifier() && arg.isPure()) { | ||
arg.hoist(); | ||
} | ||
}); | ||
} | ||
} | ||
function replaceCssWithCallExpression(path, identifier, state, t) { | ||
@@ -210,3 +236,9 @@ var staticCSSSrcCreator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (src) { | ||
return path.replaceWith(t.callExpression(identifier, new _astObject2.default((0, _babelUtils.minify)(src), path.node.quasi.expressions, t).toExpressions())); | ||
path.replaceWith(t.callExpression(identifier, new _astObject2.default((0, _babelUtils.minify)(src), path.node.quasi.expressions, t).toExpressions())); | ||
if (state.opts.hoist) { | ||
hoistPureArgs(path); | ||
} | ||
return; | ||
} catch (e) { | ||
@@ -213,0 +245,0 @@ if (path) { |
@@ -36,3 +36,3 @@ 'use strict'; | ||
}); | ||
return [_convertSourceMap2.default.fromObject(generator).toComment({ multiline: true }), '/*@ sourceURL=' + state.file.opts.sourceFileName + ' */'].join('\n'); | ||
return _convertSourceMap2.default.fromObject(generator).toComment({ multiline: true }); | ||
} |
{ | ||
"name": "babel-plugin-emotion", | ||
"version": "8.0.6", | ||
"version": "8.0.9", | ||
"description": "A recommended babel preprocessing plugin for emotion, the The Next Generation of CSS-in-JS.", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"convert-source-map": "^1.5.0", | ||
"emotion-utils": "^8.0.6", | ||
"emotion-utils": "^8.0.9", | ||
"source-map": "^0.5.7", | ||
@@ -24,0 +24,0 @@ "touch": "^1.0.0" |
@@ -24,2 +24,14 @@ // @flow weak | ||
export function hoistPureArgs(path) { | ||
const args = path.get('arguments') | ||
if (args && Array.isArray(args)) { | ||
args.forEach(arg => { | ||
if (!arg.isIdentifier() && arg.isPure()) { | ||
arg.hoist() | ||
} | ||
}) | ||
} | ||
} | ||
export function replaceCssWithCallExpression( | ||
@@ -57,3 +69,3 @@ path, | ||
return path.replaceWith( | ||
path.replaceWith( | ||
t.callExpression( | ||
@@ -68,2 +80,8 @@ identifier, | ||
) | ||
if (state.opts.hoist) { | ||
hoistPureArgs(path) | ||
} | ||
return | ||
} catch (e) { | ||
@@ -220,2 +238,14 @@ if (path) { | ||
cssProps(path, state, t) | ||
if (state.opts.hoist) { | ||
path.traverse({ | ||
CallExpression(callExprPath) { | ||
if ( | ||
callExprPath.node.callee.name === state.importedNames.css || | ||
callExprPath.node.callee.name === `_${state.importedNames.css}` | ||
) { | ||
hoistPureArgs(callExprPath) | ||
} | ||
} | ||
}) | ||
} | ||
}, | ||
@@ -260,2 +290,6 @@ CallExpression(path, state) { | ||
) | ||
if (state.opts.hoist) { | ||
hoistPureArgs(path) | ||
} | ||
} | ||
@@ -262,0 +296,0 @@ } catch (e) { |
@@ -25,6 +25,3 @@ import { SourceMapGenerator } from 'source-map' | ||
}) | ||
return [ | ||
convert.fromObject(generator).toComment({ multiline: true }), | ||
`/*@ sourceURL=${state.file.opts.sourceFileName} */` | ||
].join('\n') | ||
return convert.fromObject(generator).toComment({ multiline: true }) | ||
} |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
55798
16
1350
0
196
Updatedemotion-utils@^8.0.9