Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.22 to 1.0.0-beta.23

lib/types.d.js

46

lib/index.js

@@ -90,2 +90,12 @@ "use strict";

}
/**
* if css var is within an anon function
*/
if (MAP_CSS_LIST[cssName]) {
var _MAP_CSS_LIST$cssName;
if ((_MAP_CSS_LIST$cssName = MAP_CSS_LIST[cssName].path.node) !== null && _MAP_CSS_LIST$cssName !== void 0 && _MAP_CSS_LIST$cssName.tag) {
MAP_CSS_LIST[cssName].path.node.tag.name = "css2";
}
}
cssArgs.forEach(function (arg) {

@@ -136,2 +146,3 @@ if (ALL_CSS_NAMES[cssName][arg] === 1) {

// console.log(">>", MAP_STYLED_VARS);
/**

@@ -185,5 +196,24 @@ * Cleanups

TaggedTemplateExpression: function TaggedTemplateExpression(path) {
var _path$node$tag$object;
if (((_path$node$tag$object = path.node.tag.object) === null || _path$node$tag$object === void 0 ? void 0 : _path$node$tag$object.name) === STYLED_LOCAL_NAME) {
var _path$parentPath, _path$parentPath$node, _path$parentPath$node2;
var _path$node, _path$node$tag, _path$node$tag$object;
if (((_path$node = path.node) === null || _path$node === void 0 ? void 0 : (_path$node$tag = _path$node.tag) === null || _path$node$tag === void 0 ? void 0 : _path$node$tag.name) === CSS_LOCAL_NAME) {
var _path$parentPath, _path$parentPath$scop, _path$parentPath$scop2, _path$parentPath$scop3, _path$parentPath$scop4;
var taggedCssVarName = path === null || path === void 0 ? void 0 : (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : (_path$parentPath$scop = _path$parentPath.scope) === null || _path$parentPath$scop === void 0 ? void 0 : (_path$parentPath$scop2 = _path$parentPath$scop.path) === null || _path$parentPath$scop2 === void 0 ? void 0 : (_path$parentPath$scop3 = _path$parentPath$scop2.container) === null || _path$parentPath$scop3 === void 0 ? void 0 : (_path$parentPath$scop4 = _path$parentPath$scop3.id) === null || _path$parentPath$scop4 === void 0 ? void 0 : _path$parentPath$scop4.name;
if (!taggedCssVarName) {
return;
}
var taggedVars = path.node.quasi.expressions.filter(function (exp) {
return exp.type === "Identifier";
}).map(function (exp) {
return exp.name;
});
var taggedMap = taggedVars.reduce(function (a, c) {
return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, c, 1));
}, {});
MAP_CSS_LIST[taggedCssVarName] = {
path: path,
_type: "tte"
};
ALL_CSS_NAMES[taggedCssVarName] = taggedMap;
} else if (((_path$node$tag$object = path.node.tag.object) === null || _path$node$tag$object === void 0 ? void 0 : _path$node$tag$object.name) === STYLED_LOCAL_NAME) {
var _path$parentPath2, _path$parentPath2$nod, _path$parentPath2$nod2;
var taggedStyledVars = path.node.quasi.expressions.filter(function (exp) {

@@ -197,3 +227,3 @@ return exp.type === "Identifier";

}, {});
var taggedStyledName = path === null || path === void 0 ? void 0 : (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : (_path$parentPath$node = _path$parentPath.node) === null || _path$parentPath$node === void 0 ? void 0 : (_path$parentPath$node2 = _path$parentPath$node.id) === null || _path$parentPath$node2 === void 0 ? void 0 : _path$parentPath$node2.name;
var taggedStyledName = path === null || path === void 0 ? void 0 : (_path$parentPath2 = path.parentPath) === null || _path$parentPath2 === void 0 ? void 0 : (_path$parentPath2$nod = _path$parentPath2.node) === null || _path$parentPath2$nod === void 0 ? void 0 : (_path$parentPath2$nod2 = _path$parentPath2$nod.id) === null || _path$parentPath2$nod2 === void 0 ? void 0 : _path$parentPath2$nod2.name;
if (taggedStyledName) {

@@ -278,4 +308,4 @@ ALL_STYLED_NAMES[taggedStyledName] = taggedStyledIdsMap;

if (path.node.callee.name === STYLED_LOCAL_NAME && path.node.arguments && path.node.arguments.length) {
var _path$parentPath2, _path$parentPath2$par, _path$parentPath2$par2;
var styledVarName = path === null || path === void 0 ? void 0 : (_path$parentPath2 = path.parentPath) === null || _path$parentPath2 === void 0 ? void 0 : (_path$parentPath2$par = _path$parentPath2.parent) === null || _path$parentPath2$par === void 0 ? void 0 : (_path$parentPath2$par2 = _path$parentPath2$par.id) === null || _path$parentPath2$par2 === void 0 ? void 0 : _path$parentPath2$par2.name;
var _path$parentPath3, _path$parentPath3$par, _path$parentPath3$par2;
var styledVarName = path === null || path === void 0 ? void 0 : (_path$parentPath3 = path.parentPath) === null || _path$parentPath3 === void 0 ? void 0 : (_path$parentPath3$par = _path$parentPath3.parent) === null || _path$parentPath3$par === void 0 ? void 0 : (_path$parentPath3$par2 = _path$parentPath3$par.id) === null || _path$parentPath3$par2 === void 0 ? void 0 : _path$parentPath3$par2.name;
var styledIdsList = path.parent.arguments.filter(function (a) {

@@ -298,3 +328,3 @@ return a.type === "Identifier";

if (path.node.callee.name === CSS_LOCAL_NAME && path.node.arguments && path.node.arguments.length) {
var _path$parentPath3, _path$parentPath3$sco, _path$parentPath3$sco2, _path$parentPath3$sco3, _path$parent, _path$parent$id3, _path$parent2, _path$parent2$id;
var _path$parentPath4, _path$parentPath4$sco, _path$parentPath4$sco2, _path$parentPath4$sco3, _path$parent, _path$parent$id3, _path$parent2, _path$parent2$id;
var cssIdsList = path.node.arguments.filter(function (a) {

@@ -308,3 +338,3 @@ return a.type === "Identifier";

}, {});
var fnName = path === null || path === void 0 ? void 0 : (_path$parentPath3 = path.parentPath) === null || _path$parentPath3 === void 0 ? void 0 : (_path$parentPath3$sco = _path$parentPath3.scope) === null || _path$parentPath3$sco === void 0 ? void 0 : (_path$parentPath3$sco2 = _path$parentPath3$sco.block) === null || _path$parentPath3$sco2 === void 0 ? void 0 : (_path$parentPath3$sco3 = _path$parentPath3$sco2.id) === null || _path$parentPath3$sco3 === void 0 ? void 0 : _path$parentPath3$sco3.name;
var fnName = path === null || path === void 0 ? void 0 : (_path$parentPath4 = path.parentPath) === null || _path$parentPath4 === void 0 ? void 0 : (_path$parentPath4$sco = _path$parentPath4.scope) === null || _path$parentPath4$sco === void 0 ? void 0 : (_path$parentPath4$sco2 = _path$parentPath4$sco.block) === null || _path$parentPath4$sco2 === void 0 ? void 0 : (_path$parentPath4$sco3 = _path$parentPath4$sco2.id) === null || _path$parentPath4$sco3 === void 0 ? void 0 : _path$parentPath4$sco3.name;
if (path.parent.type === "ReturnStatement" && fnName) {

@@ -311,0 +341,0 @@ ALL_CSS_NAMES[fnName] = cssIdsMap;

4

package.json
{
"name": "babel-plugin-emotion-rename",
"version": "1.0.0-beta.22",
"version": "1.0.0-beta.23",
"description": "Babel plugin to rename old Emotion 9 import to new Emotion 10+ import",

@@ -9,3 +9,3 @@ "main": "lib/index",

"test:babel": "node src/index.spec.js",
"tmp": "babel --config-file=./babel-example.config.js examples/src/. -d examples/out/.",
"tmp": "babel --config-file=./babel-example.config.js examples/src/c-moderncase.js -d examples/out/.",
"test": "npm-run-all test:*",

@@ -12,0 +12,0 @@ "prepublish": "npm run build"

@@ -22,2 +22,6 @@ # babel-plugin-emotion-rename [![npm][npm-image]][npm-url]

### Known issues:
- If you import a variable from another file, and that variable is used within styled/css tagged template literal, then it's currently impossible to statically analyze and rename the import
## Install

@@ -24,0 +28,0 @@

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