babel-plugin-emotion
Advanced tools
Comparing version 10.0.23 to 11.0.0-next.0
# babel-plugin-emotion | ||
## 11.0.0-next.0 | ||
### Major Changes | ||
- [`302bdba1`](https://github.com/emotion-js/emotion/commit/302bdba1a6b793484c09edeb668815c5e31ea555) [#1600](https://github.com/emotion-js/emotion/pull/1600) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Ensure packages are major bumped so that pre-release versions of the linked packages are consistent in the major number | ||
### Patch Changes | ||
- [`b0ad4f0c`](https://github.com/emotion-js/emotion/commit/b0ad4f0c628813a42c4637857be9a969429db6f0) [#1600](https://github.com/emotion-js/emotion/pull/1600) Thanks [@Andarist](https://github.com/Andarist)! - Avoid transpiling vanilla emotion calls in already transpiled code to avoid double labels and such | ||
## 10.0.23 | ||
@@ -4,0 +14,0 @@ |
@@ -604,2 +604,31 @@ 'use strict'; | ||
var isAlreadyTranspiled = function isAlreadyTranspiled(path) { | ||
if (!path.isCallExpression()) { | ||
return false; | ||
} | ||
var firstArgPath = path.get('arguments.0'); | ||
if (!firstArgPath) { | ||
return false; | ||
} | ||
if (!firstArgPath.isConditionalExpression()) { | ||
return false; | ||
} | ||
var alternatePath = firstArgPath.get('alternate'); | ||
if (!alternatePath.isObjectExpression()) { | ||
return false; | ||
} | ||
var properties = new Set(alternatePath.get('properties').map(function (p) { | ||
return p.node.key.name; | ||
})); | ||
return ['name', 'styles'].every(function (p) { | ||
return properties.has(p); | ||
}); | ||
}; | ||
var createEmotionMacro = function createEmotionMacro(instancePath) { | ||
@@ -633,2 +662,7 @@ return babelPluginMacros.createMacro(function macro(_ref) { | ||
var path = reference.parentPath; | ||
if (isAlreadyTranspiled(path)) { | ||
return; | ||
} | ||
reference.replaceWith(t.cloneDeep(runtimeNode)); | ||
@@ -635,0 +669,0 @@ |
@@ -287,2 +287,15 @@ "use strict"; | ||
return t.objectExpression(properties); | ||
}, isAlreadyTranspiled = function(path) { | ||
if (!path.isCallExpression()) return !1; | ||
var firstArgPath = path.get("arguments.0"); | ||
if (!firstArgPath) return !1; | ||
if (!firstArgPath.isConditionalExpression()) return !1; | ||
var alternatePath = firstArgPath.get("alternate"); | ||
if (!alternatePath.isObjectExpression()) return !1; | ||
var properties = new Set(alternatePath.get("properties").map(function(p) { | ||
return p.node.key.name; | ||
})); | ||
return [ "name", "styles" ].every(function(p) { | ||
return properties.has(p); | ||
}); | ||
}, createEmotionMacro = function(instancePath) { | ||
@@ -303,10 +316,12 @@ return babelPluginMacros.createMacro(function(_ref) { | ||
var path = reference.parentPath; | ||
reference.replaceWith(t.cloneDeep(runtimeNode)), isPure && path.addComment("leading", "#__PURE__"); | ||
var node = transformExpressionWithStyles({ | ||
babel: babel, | ||
state: state, | ||
path: path, | ||
shouldLabel: !0 | ||
}).node; | ||
node && (path.node.arguments[0] = node); | ||
if (!isAlreadyTranspiled(path)) { | ||
reference.replaceWith(t.cloneDeep(runtimeNode)), isPure && path.addComment("leading", "#__PURE__"); | ||
var node = transformExpressionWithStyles({ | ||
babel: babel, | ||
state: state, | ||
path: path, | ||
shouldLabel: !0 | ||
}).node; | ||
node && (path.node.arguments[0] = node); | ||
} | ||
}); | ||
@@ -313,0 +328,0 @@ break; |
@@ -598,2 +598,31 @@ import nodePath from 'path'; | ||
var isAlreadyTranspiled = function isAlreadyTranspiled(path) { | ||
if (!path.isCallExpression()) { | ||
return false; | ||
} | ||
var firstArgPath = path.get('arguments.0'); | ||
if (!firstArgPath) { | ||
return false; | ||
} | ||
if (!firstArgPath.isConditionalExpression()) { | ||
return false; | ||
} | ||
var alternatePath = firstArgPath.get('alternate'); | ||
if (!alternatePath.isObjectExpression()) { | ||
return false; | ||
} | ||
var properties = new Set(alternatePath.get('properties').map(function (p) { | ||
return p.node.key.name; | ||
})); | ||
return ['name', 'styles'].every(function (p) { | ||
return properties.has(p); | ||
}); | ||
}; | ||
var createEmotionMacro = function createEmotionMacro(instancePath) { | ||
@@ -627,2 +656,7 @@ return createMacro(function macro(_ref) { | ||
var path = reference.parentPath; | ||
if (isAlreadyTranspiled(path)) { | ||
return; | ||
} | ||
reference.replaceWith(t.cloneDeep(runtimeNode)); | ||
@@ -629,0 +663,0 @@ |
{ | ||
"name": "babel-plugin-emotion", | ||
"version": "10.0.23", | ||
"version": "11.0.0-next.0", | ||
"description": "A recommended babel preprocessing plugin for emotion, The Next Generation of CSS-in-JS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/babel-plugin-emotion.cjs.js", |
@@ -6,2 +6,30 @@ // @flow | ||
const isAlreadyTranspiled = path => { | ||
if (!path.isCallExpression()) { | ||
return false | ||
} | ||
const firstArgPath = path.get('arguments.0') | ||
if (!firstArgPath) { | ||
return false | ||
} | ||
if (!firstArgPath.isConditionalExpression()) { | ||
return false | ||
} | ||
const alternatePath = firstArgPath.get('alternate') | ||
if (!alternatePath.isObjectExpression()) { | ||
return false | ||
} | ||
const properties = new Set( | ||
alternatePath.get('properties').map(p => p.node.key.name) | ||
) | ||
return ['name', 'styles'].every(p => properties.has(p)) | ||
} | ||
export let createEmotionMacro = (instancePath: string) => | ||
@@ -28,2 +56,6 @@ createMacro(function macro({ references, state, babel, isEmotionCall }) { | ||
if (isAlreadyTranspiled(path)) { | ||
return | ||
} | ||
reference.replaceWith(t.cloneDeep(runtimeNode)) | ||
@@ -30,0 +62,0 @@ if (isPure) { |
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 v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
151201
3435
1