module export variable declaration initializer default - fixes #264
This commit is contained in:
parent
b688154aee
commit
e97e916b5c
@ -98,14 +98,12 @@ CommonJSFormatter.prototype.export = function (node, nodes) {
|
||||
if (t.isVariableDeclaration(declar)) {
|
||||
var decl = declar.declarations[0];
|
||||
|
||||
if (decl.init) {
|
||||
decl.init = util.template("exports-assign", {
|
||||
//inherits: node,
|
||||
decl.init = util.template("exports-assign", {
|
||||
//inherits: node,
|
||||
|
||||
VALUE: decl.init,
|
||||
KEY: decl.id
|
||||
});
|
||||
}
|
||||
VALUE: decl.init,
|
||||
KEY: decl.id
|
||||
});
|
||||
|
||||
nodes.push(declar);
|
||||
} else {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.ImportDeclaration = function (node, parent, file) {
|
||||
@ -18,6 +19,13 @@ exports.ExportDeclaration = function (node, parent, file) {
|
||||
var nodes = [];
|
||||
|
||||
if (node.declaration) {
|
||||
// make sure variable exports have an initialiser
|
||||
// this is done here to avoid duplicating it in the module formatters
|
||||
if (t.isVariableDeclaration(node.declaration)) {
|
||||
var declar = node.declaration.declarations[0];
|
||||
declar.init = declar.init || t.identifier("undefined");
|
||||
}
|
||||
|
||||
file.moduleFormatter.export(node, nodes, parent);
|
||||
} else {
|
||||
_.each(node.specifiers, function (specifier) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user