babel-plugin-emotion-rename
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.7
@@ -140,3 +140,5 @@ "use strict"; | ||
ImportDeclaration: function ImportDeclaration(path, state) { | ||
if (path.node.source.value === "react-emotion") { | ||
var isReactEmotionImport = path.node.source.value === "react-emotion"; | ||
if (isReactEmotionImport) { | ||
var _path$node$specifiers, _path$node$specifiers2, _styledDefaultNode$lo; | ||
@@ -155,44 +157,44 @@ | ||
STYLED_LOCAL_NAME = styledLocalName || "styled"; | ||
} else if (path.node.source.value === "@emotion/styled") { | ||
var _styledDefaultNode = path.node.specifiers.find(function (s) { | ||
return s.type === "ImportDefaultSpecifier"; | ||
}); | ||
_styledDefaultNode.local.name = STYLED_LOCAL_NAME; | ||
} | ||
var _getStyled = getStyled(path), | ||
hasStyled = _getStyled.hasStyled, | ||
nonStyled = _getStyled.nonStyled; | ||
var _getStyled = getStyled(path), | ||
hasStyled = _getStyled.hasStyled, | ||
nonStyled = _getStyled.nonStyled; | ||
if (nonStyled.length && isReactEmotionImport) { | ||
path.node.specifiers = path.node.specifiers.filter(function (s) { | ||
return s.type !== "ImportDefaultSpecifier"; | ||
}); | ||
} | ||
/** | ||
* if there is only exactly one default import styled | ||
* e.g. import styled from 'emotion/react-emotion' | ||
*/ | ||
if (nonStyled.length) { | ||
path.node.specifiers = path.node.specifiers.filter(function (s) { | ||
return s.type !== "ImportDefaultSpecifier"; | ||
}); | ||
} | ||
/** | ||
* if there is only exactly one default import styled | ||
* e.g. import styled from 'emotion/react-emotion' | ||
*/ | ||
if (!nonStyled.length && hasStyled.length) { | ||
path.node.source = t.stringLiteral("@emotion/styled"); | ||
return; | ||
} | ||
if (!nonStyled.length && hasStyled.length) { | ||
path.node.source = t.stringLiteral("@emotion/styled"); | ||
return; | ||
} | ||
if (hasStyled.length && !imported) { | ||
imported = true; | ||
root.unshiftContainer("body", importDeclaration); | ||
} | ||
if (hasStyled.length && !imported) { | ||
imported = true; | ||
root.unshiftContainer("body", importDeclaration); | ||
} | ||
REP.forEach(function (_ref2) { | ||
var original = _ref2.original, | ||
replacement = _ref2.replacement; | ||
var value = path.node.source.value; | ||
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") { | ||
var _styledDefaultNode = path.node.specifiers.find(function (s) { | ||
return s.type === "ImportDefaultSpecifier"; | ||
}); | ||
if (isModule(value, original)) { | ||
path.node.source = source(value, original, replacement); | ||
} | ||
}); | ||
_styledDefaultNode.local.name = STYLED_LOCAL_NAME; | ||
} | ||
}, | ||
@@ -199,0 +201,0 @@ CallExpression: function CallExpression(path, state) { |
{ | ||
"name": "babel-plugin-emotion-rename", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.7", | ||
"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
15378
219