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

babel-plugin-split-styles

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-split-styles - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

13

dist/index.js

@@ -51,8 +51,2 @@ "use strict";

let cssProp = path.parentPath.node.attributes.find(node => node.name.name === 'css'); // if there is a cssProp it must contain a objectExpression
if (cssProp && !t.isObjectExpression(cssProp.value.expression)) {
return;
}
if (t.isJSXExpressionContainer(path.node.value)) {

@@ -75,8 +69,3 @@ const extracted = extractStylesFromPath(t, path.get('value.expression'), state);

if (staticStyle.length !== 0) {
if (!cssProp) {
cssProp = t.jsxAttribute(t.jsxIdentifier('css'), t.jsxExpressionContainer(t.objectExpression([])));
path.parentPath.node.attributes.unshift(cssProp);
}
cssProp.value.expression.properties.push(...staticStyle);
path.parentPath.node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier('css'), t.jsxExpressionContainer(t.objectExpression(staticStyle))));
}

@@ -83,0 +72,0 @@ }

2

package.json
{
"name": "babel-plugin-split-styles",
"version": "0.0.1",
"version": "0.0.2",
"description": "Splitting dynamic and static styles into style and css prop.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -50,3 +50,4 @@ // Path is an object expression;

!t.isObjectExpression(path.node.value.expression) ||
path.node.name.name !== 'style'
path.node.name.name !== 'style' ||
path.parent.attributes.some(node => node.name.name === 'css')
) {

@@ -56,11 +57,2 @@ return;

let cssProp = path.parentPath.node.attributes.find(
node => node.name.name === 'css'
);
// if there is a cssProp it must contain a objectExpression
if (cssProp && !t.isObjectExpression(cssProp.value.expression)) {
return;
}
if (t.isJSXExpressionContainer(path.node.value)) {

@@ -83,11 +75,8 @@ const extracted = extractStylesFromPath(

if (staticStyle.length !== 0) {
if (!cssProp) {
cssProp = t.jsxAttribute(
path.parentPath.node.attributes.unshift(
t.jsxAttribute(
t.jsxIdentifier('css'),
t.jsxExpressionContainer(t.objectExpression([]))
);
path.parentPath.node.attributes.unshift(cssProp);
}
cssProp.value.expression.properties.push(...staticStyle);
t.jsxExpressionContainer(t.objectExpression(staticStyle))
)
);
}

@@ -94,0 +83,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