combine export declaration assignments into variable declarations
This commit is contained in:
@@ -51,23 +51,32 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
|
||||
VALUE: ref
|
||||
}, true));
|
||||
} else {
|
||||
var id = declar.id;
|
||||
var assign;
|
||||
|
||||
if (t.isVariableDeclaration(declar)) {
|
||||
id = declar.declarations[0].id;
|
||||
var decl = declar.declarations[0]
|
||||
|
||||
if (decl.init) {
|
||||
decl.init = util.template("exports-assign", {
|
||||
VALUE: decl.init,
|
||||
KEY: decl.id
|
||||
});
|
||||
}
|
||||
|
||||
nodes.push(declar);
|
||||
} else {
|
||||
assign = util.template("exports-assign", {
|
||||
VALUE: declar.id,
|
||||
KEY: declar.id
|
||||
}, true);
|
||||
|
||||
nodes.push(declar);
|
||||
nodes.push(assign);
|
||||
|
||||
if (t.isFunctionDeclaration(declar)) {
|
||||
assign._blockHoist = true;
|
||||
}
|
||||
}
|
||||
|
||||
var assign = util.template("exports-assign", {
|
||||
VALUE: id,
|
||||
KEY: id
|
||||
}, true);
|
||||
|
||||
nodes.push(declar);
|
||||
|
||||
if (t.isFunctionDeclaration(declar)) {
|
||||
assign._blockHoist = true;
|
||||
}
|
||||
|
||||
nodes.push(assign);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user