* Revert "Fix invalid hook usage for exports (#4385)"
This reverts commit 8164fa6f1a
.
* Adding a changeset
This commit is contained in:
parent
ba1ca7e61f
commit
78334b9765
2 changed files with 20 additions and 28 deletions
5
.changeset/short-cats-kiss.md
Normal file
5
.changeset/short-cats-kiss.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes regression with JSX in Solid library
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue