Skip to content

Commit

Permalink
Add support for export * statements in remark-mdx (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph authored and johno committed Jan 15, 2020
1 parent 02b10c5 commit da7b2cd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/remark-mdx/extract-imports-and-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class BabelPluginExtractImportsAndExports {
const {start} = path.node
nodes.push({type: 'export', start})
},
ExportAllDeclaration(path) {
const {start} = path.node
nodes.push({type: 'export', start})
},
ImportDeclaration(path) {
const {start} = path.node

Expand Down
11 changes: 11 additions & 0 deletions packages/remark-mdx/test/__snapshots__/import-export.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ Array [
]
`;

exports[`Handles export all 1`] = `
Array [
Object {
"type": "export",
"value": Array [
"export * from './foo'",
],
},
]
`;

exports[`Handles multiline default exports 1`] = `
Array [
Object {
Expand Down
4 changes: 4 additions & 0 deletions packages/remark-mdx/test/fixtures/import-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ module.exports = [
{
description: 'Handles multiline default exports',
mdx: ['export default props => (', ' <main {...props} />', ')'].join('\n')
},
{
description: 'Handles export all',
mdx: ["export * from './foo'"]
}
]

0 comments on commit da7b2cd

Please sign in to comment.