From e0d3e18865ea49208b052e0f916bcf0d4738ad69 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 10 Nov 2014 08:16:22 +1100 Subject: [PATCH] add allowReturnOutsideFunction to util.parse and make nodes optional in util.template --- lib/6to5/util.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/6to5/util.js b/lib/6to5/util.js index 39749b08cc..ae267180dd 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -111,6 +111,11 @@ exports.template = function (name, nodes, keepExpression) { var template = exports.templates[name]; if (!template) throw new ReferenceError("unknown template " + name); + if (nodes === true) { + keepExpression = true; + nodes = null; + } + template = _.cloneDeep(template); var inherits = false; @@ -192,13 +197,14 @@ exports.parse = function (opts, code, callback) { var tokens = []; var ast = acorn.parse(code, { - preserveParens: true, - ecmaVersion: Infinity, - strictMode: true, - onComment: comments, - locations: true, - onToken: tokens, - ranges: true + allowReturnOutsideFunction: true, + preserveParens: true, + ecmaVersion: Infinity, + strictMode: true, + onComment: comments, + locations: true, + onToken: tokens, + ranges: true }); estraverse.attachComments(ast, comments, tokens);