Skip JSX tagging for export statements with source (#5057)

This commit is contained in:
Bjorn Lu 2022-10-12 20:25:54 +08:00 committed by GitHub
parent 8d2d0c3c03
commit baf88ee9e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Skip JSX tagging for export statements with source

View file

@ -104,7 +104,7 @@ export default function tagExportsWithRenderer({
addTag(property.key.name);
}
});
} else if (t.isExportNamedDeclaration(node)) {
} else if (t.isExportNamedDeclaration(node) && !node.source) {
node.specifiers.forEach((specifier) => {
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
addTag(specifier.local.name);

View file

@ -1,5 +1,7 @@
import { useState } from "react"
export { ListExportTestComponent } from './ListExportTestComponent'
const ListExport = () => {
const [example] = useState('Example')
return <h2 id="default_list_export">{example}</h2>

View file

@ -0,0 +1,6 @@
import { useState } from "react"
export const ListExportTestComponent = () => {
const [example] = useState('Example')
return <h2 id="list_export_test_component">{example}</h2>
}

View file

@ -1,5 +1,5 @@
---
import ListAsDefaultExport, {ListExport, RenamedListExport} from '../components/ListExportTest'
import ListAsDefaultExport, {ListExport, RenamedListExport, ListExportTestComponent} from '../components/ListExportTest'
import {ConstDeclarationExport, LetDeclarationExport, FunctionDeclarationExport} from '../components/DeclarationExportTest'
import AnonymousArrowDefaultExport from '../components/defaultExport/AnonymousArrowDefaultExport'
import AnonymousFunctionDefaultExport from '../components/defaultExport/AnonymousFunctionDefaultExport'
@ -12,6 +12,7 @@ import NamedFunctionDefaultExport from '../components/defaultExport/NamedFunctio
<ListAsDefaultExport />
<ListExport />
<RenamedListExport />
<ListExportTestComponent />
<ConstDeclarationExport />
<LetDeclarationExport />

View file

@ -17,6 +17,7 @@ describe('react-jsx-export', () => {
'default_list_export',
'renamed_list_export',
'list_as_default_export',
'list_export_test_component',
];
const reactInvalidHookWarning =