Skip to content
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
3 changes: 2 additions & 1 deletion packages/mdx/mdx-hast-to-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function toJSX(node, parentNode = {}, options = {}) {

if (
/\bdefault\b/.test(childNode.value) &&
!/default\s+as/.test(childNode.value)
!/default\s+as/.test(childNode.value) &&
!/^export (const|let|var|function)/.test(childNode.value)
) {
let example

Expand Down
6 changes: 6 additions & 0 deletions packages/mdx/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ it('Should support semicolons in default export statement', async () => {
it('Should throw when exporting default via named export', async () => {
await expect(mdx(`export { default } from './Layout'`)).rejects.toThrow()
await expect(mdx(`export { Layout as default }`)).rejects.toThrow()

// Edge case where user has the text "default" as part of the export node
await mdx(`export const meta = {
description: 'better default behavior.'
}`)

await expect(
mdx(`export { default as MyComp } from './MyComp'`)
).resolves.toContain(`export { default as MyComp } from './MyComp'`)
Expand Down