Hoist initial exports.foo = undefined and __esModule declarations above hoisted async functions
This commit is contained in:
parent
e759b5f835
commit
4142003bbd
@ -399,14 +399,21 @@ export default function () {
|
|||||||
hoistedExportsNode = buildExportsAssignment(t.identifier(name), hoistedExportsNode).expression;
|
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
|
// add __esModule declaration if this file has any exports
|
||||||
if (hasExports && !strict) {
|
if (hasExports && !strict) {
|
||||||
let buildTemplate = buildExportsModuleDeclaration;
|
let buildTemplate = buildExportsModuleDeclaration;
|
||||||
if (this.opts.loose) buildTemplate = buildLooseExportsModuleDeclaration;
|
if (this.opts.loose) buildTemplate = buildLooseExportsModuleDeclaration;
|
||||||
topNodes.unshift(buildTemplate());
|
|
||||||
|
const declar = buildTemplate();
|
||||||
|
declar._blockHoist = 3;
|
||||||
|
|
||||||
|
topNodes.unshift(declar);
|
||||||
}
|
}
|
||||||
|
|
||||||
path.unshiftContainer("body", topNodes);
|
path.unshiftContainer("body", topNodes);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user