babel-plugin-emotion-rename
Advanced tools
Comparing version 1.0.0-beta.14 to 1.0.0-beta.15
@@ -172,5 +172,7 @@ "use strict"; | ||
ImportDeclaration: function ImportDeclaration(path, state) { | ||
var isReactEmotionImport = path.node.source.value === "react-emotion"; | ||
var importPackageName = path.node.source.value; | ||
if (isReactEmotionImport) { | ||
if (importPackageName === "emotion") { | ||
path.node.source = t.stringLiteral("@emotion/css"); | ||
} else if (importPackageName === "react-emotion") { | ||
var _path$node$specifiers, _path$node$specifiers2, _styledDefaultNode$lo; | ||
@@ -199,3 +201,3 @@ | ||
if (nonStyled.length && isReactEmotionImport) { | ||
if (nonStyled.length) { | ||
path.node.specifiers = path.node.specifiers.filter(function (s) { | ||
@@ -220,12 +222,4 @@ return s.type !== "ImportDefaultSpecifier"; | ||
REP.forEach(function (_ref2) { | ||
var original = _ref2.original, | ||
replacement = _ref2.replacement; | ||
var value = path.node.source.value; | ||
if (isModule(value, original)) { | ||
path.node.source = source(value, original, replacement); | ||
} | ||
}); | ||
} else if (path.node.source.value === "@emotion/styled") { | ||
path.node.source = t.stringLiteral("@emotion/css"); | ||
} else if (importPackageName === "@emotion/styled") { | ||
var _styledDefaultNode = path.node.specifiers.find(function (s) { | ||
@@ -239,8 +233,14 @@ return s.type === "ImportDefaultSpecifier"; | ||
CallExpression: function CallExpression(path, state) { | ||
REP.forEach(function (_ref3) { | ||
var original = _ref3.original, | ||
replacement = _ref3.replacement; | ||
REP.forEach(function (_ref2) { | ||
var original = _ref2.original, | ||
replacement = _ref2.replacement; | ||
var node = path.node; | ||
if (node.callee.name === "require" && node.arguments && node.arguments.length === 1 && t.isStringLiteral(node.arguments[0]) && isModule(node.arguments[0].value, original)) { | ||
/** | ||
* @TODO | ||
* handle commonjs require('emotion')... | ||
*/ | ||
console.log("call-exp"); | ||
if (path.scope.bindings.styled && /(react-)?emotion/.test(node.arguments[0].value)) { | ||
@@ -247,0 +247,0 @@ path.node.arguments = [t.stringLiteral("@emotion/styled")]; |
{ | ||
"name": "babel-plugin-emotion-rename", | ||
"version": "1.0.0-beta.14", | ||
"version": "1.0.0-beta.15", | ||
"description": "Babel plugin to rename old Emotion 9 import to new Emotion 10+ import", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
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
16736