es6-module-transpiler-amd-formatter
Advanced tools
Comparing version 0.1.2 to 0.2.2
37
index.js
@@ -137,32 +137,19 @@ /* jshint node:true, undef:true, unused:true */ | ||
AMDFormatter.prototype.defaultExport = function(mod, declaration) { | ||
if (n.FunctionExpression.check(declaration)) { | ||
// export default function <name> () {} | ||
if (!declaration.id) { | ||
// anonymous functionDeclaration | ||
return [b.expressionStatement( | ||
b.callExpression(b.identifier('__es6_export__'), [b.literal("default"), b.functionExpression(null, declaration.params, declaration.body)]) | ||
)]; | ||
} else { | ||
// named functionDeclaration | ||
return [ | ||
b.functionDeclaration(declaration.id, declaration.params, declaration.body), | ||
b.expressionStatement( | ||
b.callExpression(b.identifier('__es6_export__'), [b.literal("default"), declaration.id]) | ||
) | ||
]; | ||
} | ||
} else if (n.VariableDeclaration.check(declaration)) { | ||
// export default var foo = 1, bar = 2; | ||
if (n.FunctionDeclaration.check(declaration) || | ||
n.ClassDeclaration.check(declaration)) { | ||
// export default function foo () {} | ||
// -> becomes: | ||
// function foo () {} | ||
// __es6_export__('default', foo); | ||
return [ | ||
b.variableDeclaration('var', declaration.declarations), | ||
declaration, | ||
b.expressionStatement( | ||
b.callExpression(b.identifier('__es6_export__'), [b.literal("default"), declaration.declarations[0].id]) | ||
b.callExpression(b.identifier('__es6_export__'), [b.literal("default"), declaration.id]) | ||
) | ||
]; | ||
} else { | ||
// export default {foo: 1}; | ||
return [b.expressionStatement( | ||
b.callExpression(b.identifier('__es6_export__'), [b.literal("default"), declaration]) | ||
)]; | ||
} | ||
// export default {foo: 1}; | ||
return [b.expressionStatement( | ||
b.callExpression(b.identifier('__es6_export__'), [b.literal("default"), declaration]) | ||
)]; | ||
}; | ||
@@ -169,0 +156,0 @@ |
{ | ||
"name": "es6-module-transpiler-amd-formatter", | ||
"version": "0.1.2", | ||
"version": "0.2.2", | ||
"description": "ES6 Module Transpiler Extension to Output AMD define() Format.", | ||
@@ -26,7 +26,7 @@ "author": "Caridy Patino <caridy@gmail.com>", | ||
"dependencies": { | ||
"recast": "^0.7.2" | ||
"recast": "~0.8.0" | ||
}, | ||
"devDependencies": { | ||
"requirejs": "^2.1.14", | ||
"es6-module-transpiler": "^0.8.0", | ||
"es6-module-transpiler": "~0.8.2", | ||
"chai": "~1.8.1", | ||
@@ -33,0 +33,0 @@ "mocha": "~1.15.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19090
417
+ Addedast-types@0.5.7(transitive)
+ Addedesprima-fb@7001.1.0-dev-harmony-fb(transitive)
+ Addedrecast@0.8.8(transitive)
- Removedast-types@0.4.13(transitive)
- Removedesprima-fb@6001.1001.0-dev-harmony-fb(transitive)
- Removedrecast@0.7.5(transitive)
Updatedrecast@~0.8.0