babel-plugin-styled-components
Advanced tools
Comparing version 1.12.1 to 1.13.0-test
@@ -39,2 +39,14 @@ "use strict"; | ||
const existingConfig = getExistingConfig(t)(path); | ||
if (existingConfig && existingConfig.arguments.length && !existingConfig.arguments[0].properties.some(prop => ['displayName', 'componentId'].includes(prop.key.name))) { | ||
existingConfig.arguments[0].properties.push(...withConfigProps); | ||
return; | ||
} | ||
if (path.node.callee && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name == 'withConfig' && path.node.callee.arguments.length && !path.node.callee.arguments[0].properties.some(prop => ['displayName', 'componentId'].includes(prop.key.name))) { | ||
path.node.callee.arguments[0].properties.push(...withConfigProps); | ||
return; | ||
} | ||
if (path.node.tag) { | ||
@@ -48,2 +60,12 @@ // Replace x`...` with x.withConfig({ })`...` | ||
const getExistingConfig = t => path => { | ||
if (path.node.callee && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name == 'withConfig') { | ||
return path.node.callee; | ||
} | ||
if (path.node.callee && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.object && path.node.callee.callee.object.callee && path.node.callee.callee.object.callee.property && path.node.callee.callee.object.callee.property.name === 'withConfig') { | ||
return path.node.callee.callee.object; | ||
} | ||
}; | ||
const getBlockName = file => { | ||
@@ -132,3 +154,3 @@ const name = _path.default.basename(file.opts.filename, _path.default.extname(file.opts.filename)); | ||
// Prefix the identifier with a character because CSS classes cannot start with a number | ||
return `${(0, _options.useNamespace)(state)}${(0, _prefixDigit.default)(getFileHash(state))}-${getNextId(state)}`; | ||
return `${(0, _options.useNamespace)(state)}sc-${getFileHash(state)}-${getNextId(state)}`; | ||
}; | ||
@@ -141,3 +163,4 @@ | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && !t.isMemberExpression(path.node.callee.callee) || // styled(x).attrs()({}) | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name !== 'withConfig') { | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name !== 'withConfig' || // styled(x).withConfig({}) | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name == 'withConfig' && !path.node.callee.arguments[0].properties.some(prop => ['displayName', 'componentId'].includes(prop.key.name))) { | ||
const displayName = (0, _options.useDisplayName)(state) && getDisplayName(t)(path, (0, _options.useFileName)(state) && state); | ||
@@ -144,0 +167,0 @@ addConfig(t)(path, displayName && displayName.replace(/[^_a-zA-Z0-9-]/g, ''), (0, _options.useSSR)(state) && getComponentId(state)); |
@@ -164,7 +164,7 @@ "use strict"; | ||
while (!t.isProgram(parent.parentPath)) { | ||
while (!t.isProgram(parent)) { | ||
parent = parent.parentPath; | ||
} | ||
injector = nodeToInsert => parent.insertBefore(nodeToInsert); | ||
injector = nodeToInsert => parent.pushContainer('body', nodeToInsert); | ||
} | ||
@@ -171,0 +171,0 @@ |
{ | ||
"version": "1.12.1", | ||
"version": "1.13.0-test", | ||
"name": "babel-plugin-styled-components", | ||
@@ -4,0 +4,0 @@ "description": "Improve the debugging experience and add server-side rendering support to styled-components", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
37115
685
2