fix(compiler-sfc): fix 'export default' rewrite with extra whitespaces (#4375)

This commit is contained in:
lidlanca
2021-08-23 18:40:16 -04:00
committed by GitHub
parent 9043d0dca7
commit 4792ebd687
3 changed files with 81 additions and 5 deletions

View File

@@ -605,11 +605,8 @@ export function compileScript(
// export default
defaultExport = node
const start = node.start! + scriptStartOffset!
s.overwrite(
start,
start + `export default`.length,
`const ${defaultTempVar} =`
)
const end = node.declaration.start! + scriptStartOffset!
s.overwrite(start, end, `const ${defaultTempVar} = `)
} else if (node.type === 'ExportNamedDeclaration' && node.specifiers) {
const defaultSpecifier = node.specifiers.find(
s => s.exported.type === 'Identifier' && s.exported.name === 'default'