From cd395559ce34bdcc77cf3cff6e5c062fc6d89d90 Mon Sep 17 00:00:00 2001 From: edison Date: Thu, 12 May 2022 08:40:05 +0800 Subject: [PATCH] chore(compiler-core): use aliasHelper (#3592) --- packages/compiler-core/src/codegen.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/compiler-core/src/codegen.ts b/packages/compiler-core/src/codegen.ts index 2b641e9a..9d715149 100644 --- a/packages/compiler-core/src/codegen.ts +++ b/packages/compiler-core/src/codegen.ts @@ -58,6 +58,8 @@ import { ImportItem } from './transform' const PURE_ANNOTATION = `/*#__PURE__*/` +const aliasHelper = (s: symbol) => `${helperNameMap[s]}: _${helperNameMap[s]}` + type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode export interface CodegenResult { @@ -247,11 +249,7 @@ export function generate( // function mode const declarations should be inside with block // also they should be renamed to avoid collision with user properties if (hasHelpers) { - push( - `const { ${ast.helpers - .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`) - .join(', ')} } = _Vue` - ) + push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`) push(`\n`) newline() } @@ -328,7 +326,6 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) { !__BROWSER__ && ssr ? `require(${JSON.stringify(runtimeModuleName)})` : runtimeGlobalName - const aliasHelper = (s: symbol) => `${helperNameMap[s]}: _${helperNameMap[s]}` // Generate const declaration for helpers // In prefix mode, we place the const declaration at top so it's done // only once; But if we not prefixing, we place the declaration inside the