Skip to content

Commit

Permalink
Fix rsc export component name detection (vercel#33608)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored and natew committed Feb 16, 2022
1 parent 30cde09 commit d388b4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function parseImportsInfo(

let transformedSource = ''
let lastIndex = 0
let defaultExportName = 'RSComponent'
let defaultExportName = 'RSCComponent'

for (let i = 0; i < body.length; i++) {
const node = body[i]
Expand Down Expand Up @@ -89,7 +89,12 @@ async function parseImportsInfo(
continue
}
case 'ExportDefaultDeclaration': {
defaultExportName = node.declaration.id.name
const def = node.declaration
if (def.type === 'Identifier') {
defaultExportName = def.name
} else if (def.type === 'FunctionDeclaration') {
defaultExportName = def.id.name
}
break
}
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import NextImage from 'next/image'
import src from '../../public/test.jpg'

export default function Image() {
// Keep arrow function to test rsc loaders
const Page = () => {
return <NextImage src={src} />
}

export default Page

0 comments on commit d388b4e

Please sign in to comment.