Merge pull request #3136 from loganfsmyth/destructure-export-T6720
Move destructuring statements off export statements before processing - fixes T6720
This commit is contained in:
commit
ec1e975333
@ -325,6 +325,25 @@ export default function ({ types: t }) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
visitor: {
|
visitor: {
|
||||||
|
ExportNamedDeclaration(path){
|
||||||
|
let declaration = path.get("declaration");
|
||||||
|
if (!declaration.isVariableDeclaration()) return;
|
||||||
|
if (!variableDeclarationHasPattern(declaration.node)) return;
|
||||||
|
|
||||||
|
let specifiers = [];
|
||||||
|
|
||||||
|
for (let name in path.getOuterBindingIdentifiers(path)){
|
||||||
|
let id = t.identifier(name);
|
||||||
|
specifiers.push(t.exportSpecifier(id, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split the declaration and export list into two declarations so that the variable
|
||||||
|
// declaration can be split up later without needing to worry about not being a
|
||||||
|
// top-level statement.
|
||||||
|
path.replaceWith(declaration.node);
|
||||||
|
path.insertAfter(t.exportNamedDeclaration(null, specifiers));
|
||||||
|
},
|
||||||
|
|
||||||
ForXStatement(path, file) {
|
ForXStatement(path, file) {
|
||||||
let { node, scope } = path;
|
let { node, scope } = path;
|
||||||
let left = node.left;
|
let left = node.left;
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
export let {a, b, c: {d, e: {f = 4}}} = {};
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
var _ref = {};
|
||||||
|
var a = _ref.a;
|
||||||
|
var b = _ref.b;
|
||||||
|
var _ref$c = _ref.c;
|
||||||
|
var d = _ref$c.d;
|
||||||
|
var _ref$c$e$f = _ref$c.e.f;
|
||||||
|
var f = _ref$c$e$f === undefined ? 4 : _ref$c$e$f;
|
||||||
|
export { a, b, d, f };
|
||||||
Loading…
x
Reference in New Issue
Block a user