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 client reference proxies #57301

Merged
merged 2 commits into from
Oct 24, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ const __default__ = proxy.default;
let cnt = 0
for (const ref of clientRefs) {
if (ref === '') {
esmSource += `\nexports[''] = proxy[''];`
esmSource += `\nexports[''] = createProxy(String.raw\`${this.resourcePath}#\`);`
} else if (ref === 'default') {
esmSource += `
export { __esModule, $$typeof };
export default __default__;`
} else {
esmSource += `
const e${cnt} = proxy["${ref}"];
const e${cnt} = createProxy(String.raw\`${this.resourcePath}#${ref}\`);
export { e${cnt++} as ${ref} };`
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/app-dir/mdx/app/client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use client'

export function Client() {
return <h2>This is a client component</h2>
}
4 changes: 4 additions & 0 deletions test/e2e/app-dir/mdx/app/page.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Hello World

This is MDX!

import { Client } from './client'

<Client />
5 changes: 5 additions & 0 deletions test/e2e/app-dir/mdx/mdx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ for (const type of [
'rgb(255, 0, 0)'
)
})

it('should allow importing client components', async () => {
const $ = await next.render$('/')
expect($('h2').text()).toBe('This is a client component')
})
})

describe('pages directory', () => {
Expand Down
Loading