@homebound/truss 2.20.1 → 2.21.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/index.js +67 -34
- package/build/index.js.map +1 -1
- package/build/plugin/index.js +1 -31
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/build/plugin/index.js
CHANGED
|
@@ -3136,7 +3136,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
3136
3136
|
const errorMessages = [];
|
|
3137
3137
|
let hasCssPropsCall = false;
|
|
3138
3138
|
let hasBuildtimeJsxCssAttribute = false;
|
|
3139
|
-
let hasRuntimeStyleCssUsage = false;
|
|
3140
3139
|
traverse2(ast, {
|
|
3141
3140
|
// -- Css.*.$ chain collection --
|
|
3142
3141
|
MemberExpression(path) {
|
|
@@ -3145,10 +3144,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
3145
3144
|
if (path.node.computed) return;
|
|
3146
3145
|
const chain = extractChain(path.node.object, cssBindingName);
|
|
3147
3146
|
if (!chain) return;
|
|
3148
|
-
if (isInsideRuntimeStyleCssObject(path)) {
|
|
3149
|
-
hasRuntimeStyleCssUsage = true;
|
|
3150
|
-
return;
|
|
3151
|
-
}
|
|
3152
3147
|
if (isInsideWhenObjectValue(path, cssBindingName)) {
|
|
3153
3148
|
return;
|
|
3154
3149
|
}
|
|
@@ -3175,7 +3170,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
3175
3170
|
// -- JSX css={...} attribute detection (so we don't bail when there are only css props) --
|
|
3176
3171
|
JSXAttribute(path) {
|
|
3177
3172
|
if (!t4.isJSXIdentifier(path.node.name, { name: "css" })) return;
|
|
3178
|
-
if (isRuntimeStyleCssAttribute2(path)) return;
|
|
3179
3173
|
hasBuildtimeJsxCssAttribute = true;
|
|
3180
3174
|
}
|
|
3181
3175
|
});
|
|
@@ -3229,7 +3223,7 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
3229
3223
|
runtimeImports.push({ importedName: "__injectTrussCSS", localName: "__injectTrussCSS" });
|
|
3230
3224
|
}
|
|
3231
3225
|
let reusedCssImportLine = false;
|
|
3232
|
-
if (cssIsImported
|
|
3226
|
+
if (cssIsImported) {
|
|
3233
3227
|
reusedCssImportLine = runtimeImports.length > 0 && findImportDeclaration(ast, "@homebound/truss/runtime") === null && replaceCssImportWithNamedImports(ast, cssImportBinding, "@homebound/truss/runtime", runtimeImports);
|
|
3234
3228
|
if (!reusedCssImportLine) {
|
|
3235
3229
|
removeCssImport(ast, cssImportBinding);
|
|
@@ -3277,30 +3271,6 @@ function transformTruss(code, filename, mapping, options = {}) {
|
|
|
3277
3271
|
const outputCode = preserveBlankLineAfterImports(code, output.code);
|
|
3278
3272
|
return { code: outputCode, map: output.map, css: cssText, rules };
|
|
3279
3273
|
}
|
|
3280
|
-
function isInsideRuntimeStyleCssObject(path) {
|
|
3281
|
-
let current = path.parentPath;
|
|
3282
|
-
while (current) {
|
|
3283
|
-
if (current.isJSXExpressionContainer()) {
|
|
3284
|
-
const attrPath = current.parentPath;
|
|
3285
|
-
if (!attrPath || !attrPath.isJSXAttribute()) return false;
|
|
3286
|
-
return t4.isObjectExpression(current.node.expression) && isRuntimeStyleCssAttribute2(attrPath);
|
|
3287
|
-
}
|
|
3288
|
-
if (current.isCallExpression() && isUseRuntimeStyleCall(current.node)) {
|
|
3289
|
-
return true;
|
|
3290
|
-
}
|
|
3291
|
-
current = current.parentPath;
|
|
3292
|
-
}
|
|
3293
|
-
return false;
|
|
3294
|
-
}
|
|
3295
|
-
function isUseRuntimeStyleCall(node) {
|
|
3296
|
-
return t4.isIdentifier(node.callee, { name: "useRuntimeStyle" });
|
|
3297
|
-
}
|
|
3298
|
-
function isRuntimeStyleCssAttribute2(path) {
|
|
3299
|
-
if (!t4.isJSXIdentifier(path.node.name, { name: "css" })) return false;
|
|
3300
|
-
const openingElementPath = path.parentPath;
|
|
3301
|
-
if (!openingElementPath || !openingElementPath.isJSXOpeningElement()) return false;
|
|
3302
|
-
return t4.isJSXIdentifier(openingElementPath.node.name, { name: "RuntimeStyle" });
|
|
3303
|
-
}
|
|
3304
3274
|
function isInsideWhenObjectValue(path, cssBindingName) {
|
|
3305
3275
|
let current = path.parentPath;
|
|
3306
3276
|
while (current) {
|