chore: fix snapshot + simplify fix
This commit is contained in:
parent
3b7b107120
commit
de7a879cda
@ -942,12 +942,11 @@ export function compileScript(
|
||||
// we need to move the block up so that `const __default__` is
|
||||
// declared before being used in the actual component definition
|
||||
if (scriptStartOffset! > startOffset) {
|
||||
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
||||
const content = s.slice(scriptStartOffset!, scriptEndOffset!)
|
||||
// when the script content not end with `\n` we add `\n` for the script content
|
||||
if(!/(\n *$)/.test(content)) {
|
||||
s.overwrite(scriptStartOffset!,scriptEndOffset!,`${content}\n`)
|
||||
// if content doesn't end with newline, add one
|
||||
if (!/\n$/.test(script.content.trim())) {
|
||||
s.appendLeft(scriptEndOffset!, `\n`)
|
||||
}
|
||||
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user