From c0d241d819c3086729890980ff47c363f71a0530 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 23 Apr 2018 08:14:26 -0400 Subject: [PATCH] fix helpers --- src/generators/nodes/shared/Expression.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/generators/nodes/shared/Expression.ts b/src/generators/nodes/shared/Expression.ts index b624a53cc7..010ae3c446 100644 --- a/src/generators/nodes/shared/Expression.ts +++ b/src/generators/nodes/shared/Expression.ts @@ -42,7 +42,17 @@ export default class Expression { if (isReference(node, parent)) { const { name } = flattenReference(node); - if (currentScope && currentScope.has(name) || helpers.has(name) || (name === 'event' && isEventHandler)) return; + + if (currentScope.has(name) || (name === 'event' && isEventHandler)) return; + + if (compiler.helpers.has(name)) { + let object = node; + while (object.type === 'MemberExpression') object = object.object; + + const alias = compiler.templateVars.get(`helpers-${name}`); + if (alias !== name) code.overwrite(object.start, object.end, alias); + return; + } code.prependRight(node.start, 'ctx.');