Represent helpers as simple modules.

This commit is contained in:
Logan Smyth
2017-05-05 01:01:17 -07:00
parent 0c5fae2faa
commit 158e9fbfd7
26 changed files with 583 additions and 364 deletions

View File

@@ -104,12 +104,7 @@ function buildRuntimeRewritePlugin(relativePath, helperName) {
}
function buildHelper(helperName, modules, useBuiltIns) {
const helper = helpers.get(helperName);
// avoid an unneccessary TDZ in the easy case
if (helper.type === "FunctionExpression") {
helper.type = "FunctionDeclaration";
}
const tree = t.program([t.exportDefaultDeclaration(helper)]);
const tree = t.program(helpers.get(helperName).nodes);
const transformOpts = makeTransformOpts(modules, useBuiltIns);