@homebound/truss 2.11.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/plugin/index.js
CHANGED
|
@@ -2861,6 +2861,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2861
2861
|
const sites = [];
|
|
2862
2862
|
const errorMessages = [];
|
|
2863
2863
|
let hasCssPropsCall = false;
|
|
2864
|
+
let hasJsxCssAttribute = false;
|
|
2864
2865
|
traverse2(ast, {
|
|
2865
2866
|
// -- Css.*.$ chain collection --
|
|
2866
2867
|
MemberExpression(path) {
|
|
@@ -2886,9 +2887,16 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2886
2887
|
if (t4.isMemberExpression(callee) && !callee.computed && t4.isIdentifier(callee.object, { name: cssBindingName }) && t4.isIdentifier(callee.property, { name: "props" })) {
|
|
2887
2888
|
hasCssPropsCall = true;
|
|
2888
2889
|
}
|
|
2890
|
+
},
|
|
2891
|
+
// -- JSX css={...} attribute detection (so we don't bail when there are only css props) --
|
|
2892
|
+
JSXAttribute(path) {
|
|
2893
|
+
if (hasJsxCssAttribute) return;
|
|
2894
|
+
if (t4.isJSXIdentifier(path.node.name, { name: "css" })) {
|
|
2895
|
+
hasJsxCssAttribute = true;
|
|
2896
|
+
}
|
|
2889
2897
|
}
|
|
2890
2898
|
});
|
|
2891
|
-
if (sites.length === 0 && !hasCssPropsCall) return null;
|
|
2899
|
+
if (sites.length === 0 && !hasCssPropsCall && !hasJsxCssAttribute) return null;
|
|
2892
2900
|
const chains = sites.map((s) => s.resolvedChain);
|
|
2893
2901
|
const { rules, needsMaybeInc } = collectAtomicRules(chains, mapping);
|
|
2894
2902
|
const cssText = generateCssText(rules);
|