Hoist initial exports.foo = undefined and __esModule declarations above hoisted async functions

This commit is contained in:
Erik Desjardins 2016-02-03 11:23:32 -05:00
parent e759b5f835
commit 4142003bbd

View File

@ -399,14 +399,21 @@ export default function () {
hoistedExportsNode = buildExportsAssignment(t.identifier(name), hoistedExportsNode).expression;
}
topNodes.unshift(t.expressionStatement(hoistedExportsNode));
const node = t.expressionStatement(hoistedExportsNode);
node._blockHoist = 3;
topNodes.unshift(node);
}
// add __esModule declaration if this file has any exports
if (hasExports && !strict) {
let buildTemplate = buildExportsModuleDeclaration;
if (this.opts.loose) buildTemplate = buildLooseExportsModuleDeclaration;
topNodes.unshift(buildTemplate());
const declar = buildTemplate();
declar._blockHoist = 3;
topNodes.unshift(declar);
}
path.unshiftContainer("body", topNodes);