From 3c2707b62e1a355f182c08f85cf7bc9bca1bb34e Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 16 Jun 2022 09:53:45 +0800 Subject: [PATCH] feat: defineExpose() support --- packages/compiler-sfc/src/compileScript.ts | 11 +- .../__snapshots__/compileScript.spec.ts.snap | 207 ++++++------------ .../compiler-sfc/test/compileScript.spec.ts | 6 +- src/core/config.ts | 4 +- src/core/util/debug.ts | 2 +- src/types/options.ts | 2 +- src/v3/apiSetup.ts | 30 ++- 7 files changed, 101 insertions(+), 161 deletions(-) diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index b1248682..354aa40b 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -1183,7 +1183,7 @@ export function compileScript( s.prependLeft(startOffset, `\nlet __temp${any}, __restore${any}\n`) } - const destructureElements = [`expose`] + const destructureElements = hasDefineExposeCall ? [`expose`] : [] if (emitIdentifier) { destructureElements.push( emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}` @@ -1256,9 +1256,6 @@ export function compileScript( runtimeOptions += genRuntimeEmits(typeDeclaredEmits) } - //