From 0013b58dd0e9bda525ee8590b76887c4f63a4d12 Mon Sep 17 00:00:00 2001 From: thejackshelton Date: Thu, 23 Jan 2025 23:09:08 -0600 Subject: [PATCH 1/3] fix: inline component transforms --- .changeset/late-dots-beam.md | 5 +++++ libs/qwikdev-astro/server.ts | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .changeset/late-dots-beam.md diff --git a/.changeset/late-dots-beam.md b/.changeset/late-dots-beam.md new file mode 100644 index 0000000..7c2e301 --- /dev/null +++ b/.changeset/late-dots-beam.md @@ -0,0 +1,5 @@ +--- +"@qwikdev/astro": patch +--- + +fix: better handling for jsx transforms in inline components diff --git a/libs/qwikdev-astro/server.ts b/libs/qwikdev-astro/server.ts index 82a54eb..6302197 100644 --- a/libs/qwikdev-astro/server.ts +++ b/libs/qwikdev-astro/server.ts @@ -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" ); } From 9b2a663b23da584177ed1d8fb450f1bdbe730946 Mon Sep 17 00:00:00 2001 From: thejackshelton Date: Sat, 25 Jan 2025 12:08:34 -0600 Subject: [PATCH 2/3] fix: inline components with props --- libs/qwikdev-astro/server.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libs/qwikdev-astro/server.ts b/libs/qwikdev-astro/server.ts index 6302197..a04bd9c 100644 --- a/libs/qwikdev-astro/server.ts +++ b/libs/qwikdev-astro/server.ts @@ -20,7 +20,7 @@ type RendererContext = { * * We currently identify them through the jsx transform function call. * - * In Qwik v1, the identifiers are _jsxq and _jsxc + * In Qwik v1, the identifiers are _jsxQ - _jsxC - _jsxS * * In Qwik v2, it is jsxsplit and I believe jsxSorted * @@ -30,12 +30,8 @@ function isInlineComponent(component: unknown): boolean { return false; } const codeStr = component?.toString().toLowerCase(); - return ( - (codeStr.includes("_jsxq") || - codeStr.includes("_jsxc") || - 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) { From 292c849134f60715fe9b80f84edc1967d0e0fdd1 Mon Sep 17 00:00:00 2001 From: thejackshelton Date: Sat, 25 Jan 2025 12:10:41 -0600 Subject: [PATCH 3/3] changeset --- .changeset/late-dots-beam.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/late-dots-beam.md b/.changeset/late-dots-beam.md index 7c2e301..ea46e76 100644 --- a/.changeset/late-dots-beam.md +++ b/.changeset/late-dots-beam.md @@ -3,3 +3,5 @@ --- 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.