@homebound/truss 2.11.1 → 2.11.2
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
|
@@ -2848,7 +2848,7 @@ function hasExistingAttribute(path, attrName) {
|
|
|
2848
2848
|
var traverse2 = _traverse2.default ?? _traverse2;
|
|
2849
2849
|
var generate2 = _generate2.default ?? _generate2;
|
|
2850
2850
|
function transformTruss(code, filename, mapping, options = {}) {
|
|
2851
|
-
if (!code.includes("Css")) return null;
|
|
2851
|
+
if (!code.includes("Css") && !code.includes("css=")) return null;
|
|
2852
2852
|
const ast = parse(code, {
|
|
2853
2853
|
sourceType: "module",
|
|
2854
2854
|
plugins: ["typescript", "jsx"],
|
|
@@ -2856,7 +2856,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2856
2856
|
});
|
|
2857
2857
|
const cssImportBinding = findCssImportBinding(ast);
|
|
2858
2858
|
const cssBindingName = cssImportBinding ?? findCssBuilderBinding(ast);
|
|
2859
|
-
if (!cssBindingName) return null;
|
|
2860
2859
|
const cssIsImported = cssImportBinding !== null;
|
|
2861
2860
|
const sites = [];
|
|
2862
2861
|
const errorMessages = [];
|
|
@@ -2865,6 +2864,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2865
2864
|
traverse2(ast, {
|
|
2866
2865
|
// -- Css.*.$ chain collection --
|
|
2867
2866
|
MemberExpression(path) {
|
|
2867
|
+
if (!cssBindingName) return;
|
|
2868
2868
|
if (!t4.isIdentifier(path.node.property, { name: "$" })) return;
|
|
2869
2869
|
if (path.node.computed) return;
|
|
2870
2870
|
const chain = extractChain(path.node.object, cssBindingName);
|
|
@@ -2882,7 +2882,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2882
2882
|
},
|
|
2883
2883
|
// -- Css.props() detection (so we don't bail early when there are no Css.*.$ sites) --
|
|
2884
2884
|
CallExpression(path) {
|
|
2885
|
-
if (hasCssPropsCall) return;
|
|
2885
|
+
if (!cssBindingName || hasCssPropsCall) return;
|
|
2886
2886
|
const callee = path.node.callee;
|
|
2887
2887
|
if (t4.isMemberExpression(callee) && !callee.computed && t4.isIdentifier(callee.object, { name: cssBindingName }) && t4.isIdentifier(callee.property, { name: "props" })) {
|
|
2888
2888
|
hasCssPropsCall = true;
|
|
@@ -2919,7 +2919,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2919
2919
|
rewriteExpressionSites({
|
|
2920
2920
|
ast,
|
|
2921
2921
|
sites,
|
|
2922
|
-
cssBindingName,
|
|
2922
|
+
cssBindingName: cssBindingName ?? "",
|
|
2923
2923
|
filename: basename(filename),
|
|
2924
2924
|
debug: options.debug ?? false,
|
|
2925
2925
|
mapping,
|
|
@@ -2947,9 +2947,9 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
2947
2947
|
}
|
|
2948
2948
|
let reusedCssImportLine = false;
|
|
2949
2949
|
if (cssIsImported) {
|
|
2950
|
-
reusedCssImportLine = runtimeImports.length > 0 && findImportDeclaration(ast, "@homebound/truss/runtime") === null && replaceCssImportWithNamedImports(ast,
|
|
2950
|
+
reusedCssImportLine = runtimeImports.length > 0 && findImportDeclaration(ast, "@homebound/truss/runtime") === null && replaceCssImportWithNamedImports(ast, cssImportBinding, "@homebound/truss/runtime", runtimeImports);
|
|
2951
2951
|
if (!reusedCssImportLine) {
|
|
2952
|
-
removeCssImport(ast,
|
|
2952
|
+
removeCssImport(ast, cssImportBinding);
|
|
2953
2953
|
}
|
|
2954
2954
|
}
|
|
2955
2955
|
if (runtimeImports.length > 0 && !reusedCssImportLine) {
|