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
|
// we need to move the block up so that `const __default__` is
|
||||||
// declared before being used in the actual component definition
|
// declared before being used in the actual component definition
|
||||||
if (scriptStartOffset! > startOffset) {
|
if (scriptStartOffset! > startOffset) {
|
||||||
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
// if content doesn't end with newline, add one
|
||||||
const content = s.slice(scriptStartOffset!, scriptEndOffset!)
|
if (!/\n$/.test(script.content.trim())) {
|
||||||
// when the script content not end with `\n` we add `\n` for the script content
|
s.appendLeft(scriptEndOffset!, `\n`)
|
||||||
if(!/(\n *$)/.test(content)) {
|
|
||||||
s.overwrite(scriptStartOffset!,scriptEndOffset!,`${content}\n`)
|
|
||||||
}
|
}
|
||||||
|
s.move(scriptStartOffset!, scriptEndOffset!, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user