Skip to content

Commit 0303039

Browse files
committed
Fix #30
- add spec "export default and named declarations (#30)"
1 parent af19297 commit 0303039

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export default {
1818
}
1919
if (path.isExportNamedDeclaration()) {
2020
// HACK detect export-from statements for default
21-
const name = _get(path.get('declaration'), 'container.specifiers[0].exported.name')
22-
if (name === 'default') {
21+
const specifiers = _get(path.get('declaration'), 'container.specifiers')
22+
const isDefaultExportDeclaration = specifiers.length === 1 && specifiers[0].exported.name === 'default'
23+
if (isDefaultExportDeclaration) {
2324
hasExportDefault = true
2425
} else {
2526
hasExportNamed = true

test/spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,26 @@ module.exports = [
9595
}
9696
}
9797
},
98-
9998
{
10099
name: 'export default using transform-export-extensions (#11)',
101100
code: "export default from './fixtures/issue011.js'",
102101
expected: {
103102
module: 'this is file',
104103
exports: 'this is file'
105104
}
105+
},
106+
{
107+
name: 'export default and named declarations (#30)',
108+
code: 'const foo = 1;const BAR = 2;export { foo as default, BAR }',
109+
expected: {
110+
module: {
111+
default: 1,
112+
BAR: 2
113+
},
114+
exports: {
115+
default: 1,
116+
BAR: 2
117+
}
118+
}
106119
}
107120
]

0 commit comments

Comments
 (0)