Skip to content

Commit

Permalink
Fix #30
Browse files Browse the repository at this point in the history
- add spec "export default and named declarations (#30)"
  • Loading branch information
59naga committed Apr 25, 2016
1 parent af19297 commit 0303039
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export default {
}
if (path.isExportNamedDeclaration()) {
// HACK detect export-from statements for default
const name = _get(path.get('declaration'), 'container.specifiers[0].exported.name')
if (name === 'default') {
const specifiers = _get(path.get('declaration'), 'container.specifiers')
const isDefaultExportDeclaration = specifiers.length === 1 && specifiers[0].exported.name === 'default'
if (isDefaultExportDeclaration) {
hasExportDefault = true
} else {
hasExportNamed = true
Expand Down
15 changes: 14 additions & 1 deletion test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,26 @@ module.exports = [
}
}
},

{
name: 'export default using transform-export-extensions (#11)',
code: "export default from './fixtures/issue011.js'",
expected: {
module: 'this is file',
exports: 'this is file'
}
},
{
name: 'export default and named declarations (#30)',
code: 'const foo = 1;const BAR = 2;export { foo as default, BAR }',
expected: {
module: {
default: 1,
BAR: 2
},
exports: {
default: 1,
BAR: 2
}
}
}
]

0 comments on commit 0303039

Please sign in to comment.