Skip to content

Commit

Permalink
fix: inline component transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Jan 24, 2025
1 parent 7b5856f commit 0013b58
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/late-dots-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@qwikdev/astro": patch
---

fix: better handling for jsx transforms in inline components
14 changes: 13 additions & 1 deletion libs/qwikdev-astro/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ type RendererContext = {
result: SSRResult;
};

/**
* Because inline components are very much like normal functions, it's hard to distinguish them from normal functions.
*
* We currently identify them through the jsx transform function call.
*
* In Qwik v1, the identifiers are _jsxq and _jsxc
*
* In Qwik v2, it is jsxsplit and I believe jsxSorted
*
*/
function isInlineComponent(component: unknown): boolean {
if (typeof component !== "function") {
return false;
}
const codeStr = component?.toString().toLowerCase();
return (
(codeStr.includes("_jsxq") || codeStr.includes("jsxsplit")) &&
(codeStr.includes("_jsxq") ||
codeStr.includes("_jsxc") ||
codeStr.includes("jsxsplit")) &&
component.name !== "QwikComponent"
);
}
Expand Down

0 comments on commit 0013b58

Please sign in to comment.