es6-module-crosspiler
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -29,2 +29,19 @@ | ||
// look for module.exports or exports.xxxx | ||
memo(Module.prototype, 'hasCommonExports', function () { | ||
var hasCommonExports = false | ||
types.visit(this.ast.program, { | ||
visitIdentifier: function (path) { | ||
var id = path.value.name | ||
if (id === 'module' && !path.scope.lookup('module') | ||
|| id === 'exports' && !path.scope.lookup('exports')) { | ||
hasCommonExports = true | ||
return false | ||
} | ||
this.traverse(path) | ||
} | ||
}) | ||
return hasCommonExports | ||
}) | ||
function skipFunctionTraversal(path) { | ||
@@ -31,0 +48,0 @@ // `require` is defined somewhere |
@@ -64,2 +64,3 @@ | ||
/* istanbul ignore next */ | ||
assert(false, 'an error occured. you are probably using a bad version of esprima') | ||
@@ -66,0 +67,0 @@ }, this) |
@@ -81,3 +81,6 @@ | ||
memo(Module.prototype, 'type', function () { | ||
return this.isModule() ? 'module' : 'commonjs' | ||
if (this.isModule()) return 'module' | ||
if (this.requires.length) return 'commonjs' | ||
if (this.hasCommonExports) return 'commonjs' | ||
return null | ||
}) | ||
@@ -93,2 +96,3 @@ | ||
Module.prototype.exportsDefault = function () { | ||
if (this.type !== 'module') return false | ||
return this.exports.filter(hasDefault).length === 1 | ||
@@ -95,0 +99,0 @@ } |
{ | ||
"name": "es6-module-crosspiler", | ||
"description": "An ES6 and CommonJS cross-compatible transpiler", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
22707
506