fix(sfc-playground): Transform named default exports without altering scope (#4154)
Co-authored-by: webfansplz <>
This commit is contained in:
parent
457c9aed1f
commit
acb2a4d285
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user