Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: arrow function export in rsc client component #34105

Merged
merged 2 commits into from Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -62,6 +62,7 @@ async function parseExportNamesInto(
switch (node.type) {
// TODO: support export * from module path
// case 'ExportAllDeclaration':
case 'ExportDefaultExpression':
case 'ExportDefaultDeclaration':
names.push('default')
continue
Expand Down
@@ -0,0 +1 @@
export default () => 'client-default-export-arrow'
@@ -1,6 +1,7 @@
import * as all from '../components/client-exports-all'
import * as allClient from '../components/client-exports-all.client'

// TODO: support export all declaration
export default function Page() {
const { a, b, c, d, e } = all
const { a: ac, b: bc, c: cc, d: dc, e: ec } = allClient
Expand Down
@@ -1,13 +1,19 @@
import { a, b, c, d, e } from '../components/client-exports'
import DefaultArrow from '../components/client-default-export-arrow.client'

export default function Page() {
return (
<div>
{a}
{b}
{c}
{d}
{e[0]}
<div id="named-exports">
{a}
{b}
{c}
{d}
{e[0]}
</div>
<div id="default-exports-arrow">
<DefaultArrow />
</div>
</div>
)
}
Expand Up @@ -66,10 +66,21 @@ export default function (context) {
'/client-exports'
)
const $clientExports = cheerio.load(clientExportsHTML)
expect($clientExports('div[hidden] > div').text()).toBe('abcde')
expect($clientExports('div[hidden] > div > #named-exports').text()).toBe(
'abcde'
)
expect(
$clientExports('div[hidden] > div > #default-exports-arrow').text()
).toBe('client-default-export-arrow')

const browser = await webdriver(context.appPort, '/client-exports')
const text = await browser.waitForElementByCss('#__next').text()
expect(text).toBe('abcde')
const textNamedExports = await browser
.waitForElementByCss('#named-exports')
.text()
const textDefaultExportsArrow = await browser
.waitForElementByCss('#default-exports-arrow')
.text()
expect(textNamedExports).toBe('abcde')
expect(textDefaultExportsArrow).toBe('client-default-export-arrow')
})
}