|
|
@@ -140,7 +140,17 @@ function processFile(file: File, seen = new Set<File>()) {
|
|
|
|
|
|
// default export
|
|
|
if (node.type === 'ExportDefaultDeclaration') {
|
|
|
- s.overwrite(node.start!, node.start! + 14, `${moduleKey}.default =`)
|
|
|
+ if ('id' in node.declaration && node.declaration.id) {
|
|
|
+ // named hoistable/class exports
|
|
|
+ // export default function foo() {}
|
|
|
+ // export default class A {}
|
|
|
+ const { name } = node.declaration.id
|
|
|
+ s.remove(node.start!, node.start! + 15)
|
|
|
+ s.append(`\n${exportKey}(${moduleKey}, "default", () => ${name})`)
|
|
|
+ } else {
|
|
|
+ // anonymous default exports
|
|
|
+ s.overwrite(node.start!, node.start! + 14, `${moduleKey}.default =`)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// export * from './foo'
|