Skip JSX tagging for export statements with source (#5057)
This commit is contained in:
parent
8d2d0c3c03
commit
baf88ee9e5
6 changed files with 17 additions and 2 deletions
5
.changeset/serious-icons-dream.md
Normal file
5
.changeset/serious-icons-dream.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Skip JSX tagging for export statements with source
|
|
@ -104,7 +104,7 @@ export default function tagExportsWithRenderer({
|
||||||
addTag(property.key.name);
|
addTag(property.key.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (t.isExportNamedDeclaration(node)) {
|
} else if (t.isExportNamedDeclaration(node) && !node.source) {
|
||||||
node.specifiers.forEach((specifier) => {
|
node.specifiers.forEach((specifier) => {
|
||||||
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
|
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
|
||||||
addTag(specifier.local.name);
|
addTag(specifier.local.name);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
|
|
||||||
|
export { ListExportTestComponent } from './ListExportTestComponent'
|
||||||
|
|
||||||
const ListExport = () => {
|
const ListExport = () => {
|
||||||
const [example] = useState('Example')
|
const [example] = useState('Example')
|
||||||
return <h2 id="default_list_export">{example}</h2>
|
return <h2 id="default_list_export">{example}</h2>
|
||||||
|
|
6
packages/astro/test/fixtures/react-jsx-export/src/components/ListExportTestComponent.jsx
vendored
Normal file
6
packages/astro/test/fixtures/react-jsx-export/src/components/ListExportTestComponent.jsx
vendored
Normal 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>
|
||||||
|
}
|
|
@ -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 {ConstDeclarationExport, LetDeclarationExport, FunctionDeclarationExport} from '../components/DeclarationExportTest'
|
||||||
import AnonymousArrowDefaultExport from '../components/defaultExport/AnonymousArrowDefaultExport'
|
import AnonymousArrowDefaultExport from '../components/defaultExport/AnonymousArrowDefaultExport'
|
||||||
import AnonymousFunctionDefaultExport from '../components/defaultExport/AnonymousFunctionDefaultExport'
|
import AnonymousFunctionDefaultExport from '../components/defaultExport/AnonymousFunctionDefaultExport'
|
||||||
|
@ -12,6 +12,7 @@ import NamedFunctionDefaultExport from '../components/defaultExport/NamedFunctio
|
||||||
<ListAsDefaultExport />
|
<ListAsDefaultExport />
|
||||||
<ListExport />
|
<ListExport />
|
||||||
<RenamedListExport />
|
<RenamedListExport />
|
||||||
|
<ListExportTestComponent />
|
||||||
|
|
||||||
<ConstDeclarationExport />
|
<ConstDeclarationExport />
|
||||||
<LetDeclarationExport />
|
<LetDeclarationExport />
|
||||||
|
|
|
@ -17,6 +17,7 @@ describe('react-jsx-export', () => {
|
||||||
'default_list_export',
|
'default_list_export',
|
||||||
'renamed_list_export',
|
'renamed_list_export',
|
||||||
'list_as_default_export',
|
'list_as_default_export',
|
||||||
|
'list_export_test_component',
|
||||||
];
|
];
|
||||||
|
|
||||||
const reactInvalidHookWarning =
|
const reactInvalidHookWarning =
|
||||||
|
|
Loading…
Reference in a new issue