add util.ensureExpressionType which will change a node from a declaration to an expression
This commit is contained in:
parent
41ab47dde8
commit
aeac003dc8
@ -44,7 +44,7 @@ exports.VariableDeclaration = function (node, parent, file) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (node.type === "FunctionDeclaration") {
|
if (node.type === "FunctionDeclaration") {
|
||||||
node.type = "FunctionExpression";
|
util.ensureExpressionType(node);
|
||||||
var declar = b.variableDeclaration("var", [
|
var declar = b.variableDeclaration("var", [
|
||||||
b.variableDeclarator(node.id, callNode())
|
b.variableDeclarator(node.id, callNode())
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -72,11 +72,7 @@ var pushExportDeclaration = function (node, parent, nodes) {
|
|||||||
var declar = node.declaration;
|
var declar = node.declaration;
|
||||||
|
|
||||||
if (node.default) {
|
if (node.default) {
|
||||||
if (declar.type === "FunctionDeclaration") {
|
util.ensureExpressionType(declar);
|
||||||
declar.type = "FunctionExpression";
|
|
||||||
} else if (declar.type === "ClassDeclaration") {
|
|
||||||
declar.type = "ClassExpression";
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.push(util.template("exports-default", {
|
nodes.push(util.template("exports-default", {
|
||||||
VALUE: declar
|
VALUE: declar
|
||||||
|
|||||||
@ -24,6 +24,14 @@ exports.list = function (val) {
|
|||||||
return val ? val.split(",") : [];
|
return val ? val.split(",") : [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.ensureExpressionType = function (node) {
|
||||||
|
node.type = {
|
||||||
|
FunctionDeclaration: "FunctionExpression",
|
||||||
|
ClassDeclaration: "ClassExpression"
|
||||||
|
}[node.type] || node.type;
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
exports.getUid = function (parent, file) {
|
exports.getUid = function (parent, file) {
|
||||||
var node;
|
var node;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user