From: Evan You Date: Sat, 28 Nov 2020 18:51:32 +0000 (-0500) Subject: fix(compiler-sfc): should not remove import statements with no specifier when compili... X-Git-Tag: v3.0.4~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43eab923ea651079181490d191966ff28988e9c8;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): should not remove import statements with no specifier when compiling script setup --- diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index 662693d243..a68625d607 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -181,10 +181,13 @@ return { a, b } exports[`SFC compile `).content + compile(``).content ) }) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 921f5c177d..7dca8606e2 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -638,7 +638,7 @@ export function compileScript( ) } } - if (removed === node.specifiers.length) { + if (node.specifiers.length && removed === node.specifiers.length) { s.remove(node.start! + startOffset, node.end! + startOffset) } }