Skip to content

Commit

Permalink
Merge pull request #229 from QwikDev/fix-inline-comp
Browse files Browse the repository at this point in the history
fix: inline component transforms
  • Loading branch information
thejackshelton authored Jan 25, 2025
2 parents 7b5856f + 292c849 commit 0ee52c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changeset/late-dots-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@qwikdev/astro": patch
---

fix: better handling for jsx transforms in inline components

fix: when in Astro client router, conditionally affect the string append rather than the html return for visible task support.
16 changes: 12 additions & 4 deletions libs/qwikdev-astro/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ 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 - _jsxC - _jsxS
*
* 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")) &&
component.name !== "QwikComponent"
);
const qwikJsxIdentifiers = ["_jsxq", "_jsxc", "_jsxs", "jsxsplit"];
return qwikJsxIdentifiers.some(id => codeStr.includes(id)) && component.name !== "QwikComponent";
}

function isQwikComponent(component: unknown) {
Expand Down

0 comments on commit 0ee52c4

Please sign in to comment.