simplify amd module formatter
This commit is contained in:
@@ -18,22 +18,18 @@ AMDFormatter.prototype.transform = function (ast) {
|
||||
|
||||
// build an array of module names
|
||||
|
||||
var names = [];
|
||||
var names = [b.literal("exports")];
|
||||
_.each(this.ids, function (id, name) {
|
||||
names.push(b.literal(name));
|
||||
});
|
||||
names = b.arrayExpression(names);
|
||||
|
||||
// add exports
|
||||
|
||||
body.unshift(b.variableDeclaration("var", [
|
||||
b.variableDeclarator(b.identifier("exports"), b.objectExpression([]))
|
||||
]));
|
||||
body.push(b.returnStatement(b.identifier("exports")));
|
||||
|
||||
// build up define container
|
||||
|
||||
var container = b.functionExpression(null, _.values(this.ids), b.blockStatement(body));
|
||||
var params = _.values(this.ids);
|
||||
params.unshift(b.identifier("exports"));
|
||||
|
||||
var container = b.functionExpression(null, params, b.blockStatement(body));
|
||||
var call = b.callExpression(b.identifier("define"), [names, container]);
|
||||
|
||||
program.body = [b.expressionStatement(call)];
|
||||
|
||||
Reference in New Issue
Block a user