babel-plugin-styled-components
Advanced tools
Comparing version 1.10.1-ej1 to 1.10.1-ej2
@@ -33,10 +33,9 @@ "use strict"; | ||
var importName = t.identifier((0, _detectors.importLocalName)('default', state, true)); | ||
var importName = state.customImportName || t.identifier((0, _detectors.importLocalName)('default', state)); | ||
var bindings = program.scope.bindings; // Insert import if it doesn't exist yet | ||
if (!bindings[importName.name]) { | ||
(0, _helperModuleImports.addDefault)(program, 'styled-components', { | ||
if (!importName || !bindings[importName.name]) { | ||
state.customImportName = importName = (0, _helperModuleImports.addDefault)(path, 'styled-components', { | ||
nameHint: 'styled' | ||
}); | ||
importName = t.identifier((0, _detectors.importLocalName)('default', state, true)); | ||
} | ||
@@ -80,3 +79,3 @@ | ||
if (!css) return; | ||
if (!css) return console.log('no css to transpile'); | ||
elem.node.attributes = elem.node.attributes.filter(function (attr) { | ||
@@ -107,7 +106,6 @@ return attr !== path.node; | ||
return acc; | ||
}, []); // Add the tagged template expression and then requeue the newly added node | ||
// so Babel runs over it again | ||
}, []); // Add the tagged template expression, it will be processed | ||
// in the second pass of all other visitors after the Program visitor | ||
var length = program.node.body.push(t.variableDeclaration('var', [t.variableDeclarator(id, t.taggedTemplateExpression(styled, css))])); | ||
program.requeue(program.get('body')[length - 1]); | ||
program.node.body.push(t.variableDeclaration('var', [t.variableDeclarator(id, t.taggedTemplateExpression(styled, css))])); | ||
}; | ||
@@ -114,0 +112,0 @@ }; |
{ | ||
"version": "1.10.1-ej1", | ||
"version": "1.10.1-ej2", | ||
"name": "babel-plugin-styled-components", | ||
@@ -4,0 +4,0 @@ "description": "Improve the debugging experience and add server-side rendering support to styled-components", |
36268
711