Socket
Socket
Sign inDemoInstall

babel-plugin-emotion-rename

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-emotion-rename - npm Package Compare versions

Comparing version 1.0.0-beta.6 to 1.0.0-beta.7

72

lib/index.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc