Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inline component transforms #229

Merged
merged 3 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading