From 8b95502814450ddc1b1956003e6135ebe5e15881 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 25 Aug 2022 11:11:40 -0400 Subject: [PATCH 1/2] Revert "Fix invalid hook usage for exports (#4385)" This reverts commit 8164fa6f1a01152f00542be33baebecd8ac60818. --- packages/astro/src/vite-plugin-jsx/tag.ts | 43 ++++++++--------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/packages/astro/src/vite-plugin-jsx/tag.ts b/packages/astro/src/vite-plugin-jsx/tag.ts index 7f21a556220e..12bb3bcdd5b7 100644 --- a/packages/astro/src/vite-plugin-jsx/tag.ts +++ b/packages/astro/src/vite-plugin-jsx/tag.ts @@ -55,34 +55,21 @@ export default function tagExportsWithRenderer({ if (node.exportKind === 'type') return; if (node.type === 'ExportAllDeclaration') return; - const addTag = (id: string) => { - const tags = state.get('astro:tags') ?? []; - state.set('astro:tags', [...tags, id]); - }; - - if (node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration') { - if (t.isIdentifier(node.declaration)) { - addTag(node.declaration.name); - } else if (t.isFunctionDeclaration(node.declaration) && node.declaration.id?.name) { - addTag(node.declaration.id.name); - } else if (t.isVariableDeclaration(node.declaration)) { - node.declaration.declarations?.forEach((declaration) => { - if (t.isArrowFunctionExpression(declaration.init) && t.isIdentifier(declaration.id)) { - addTag(declaration.id.name); - } - }); - } else if (t.isObjectExpression(node.declaration)) { - node.declaration.properties?.forEach((property) => { - if (t.isProperty(property) && t.isIdentifier(property.key)) { - addTag(property.key.name); - } - }); - } else if (t.isExportNamedDeclaration(node)) { - node.specifiers.forEach((specifier) => { - if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) { - addTag(specifier.local.name); - } - }); + if (node.type === 'ExportNamedDeclaration') { + if (t.isFunctionDeclaration(node.declaration)) { + if (node.declaration.id?.name) { + const id = node.declaration.id.name; + const tags = state.get('astro:tags') ?? []; + state.set('astro:tags', [...tags, id]); + } + } + } else if (node.type === 'ExportDefaultDeclaration') { + if (t.isFunctionDeclaration(node.declaration)) { + if (node.declaration.id?.name) { + const id = node.declaration.id.name; + const tags = state.get('astro:tags') ?? []; + state.set('astro:tags', [...tags, id]); + } } } }, From 66ec6f1be05f04781ccacc94f8f28ba2276ff978 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 25 Aug 2022 11:13:22 -0400 Subject: [PATCH 2/2] Adding a changeset --- .changeset/short-cats-kiss.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/short-cats-kiss.md diff --git a/.changeset/short-cats-kiss.md b/.changeset/short-cats-kiss.md new file mode 100644 index 000000000000..c65c1608db82 --- /dev/null +++ b/.changeset/short-cats-kiss.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes regression with JSX in Solid library