es6-module-crosspiler
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -32,3 +32,5 @@ | ||
// this function is called require() | ||
if (path.node.id.name === 'require') return true | ||
var id = path.node.id | ||
if (!id) return false // UNTESTED: skip anonymous functions | ||
if (id.name === 'require') return true | ||
return false | ||
@@ -35,0 +37,0 @@ } |
var esprima = require('esprima') | ||
var memo = require('memorizer') | ||
@@ -9,2 +10,20 @@ var recast = require('recast') | ||
Module.parse = function (string, options) { | ||
options = options || {} | ||
options.esprima = esprima | ||
return recast.parse(string, options) | ||
} | ||
Module.infer = function (string) { | ||
var ast = Module.parse(string) | ||
mod = new Module(ast) | ||
mod.type | ||
mod.default | ||
mod.imports | ||
mod.exports | ||
// we don't need to keep the AST in memory | ||
mod.ast = null | ||
return mod | ||
} | ||
function Module(ast, options) { | ||
@@ -99,3 +118,3 @@ if (!(this instanceof Module)) return new Module(ast, options) | ||
this.defaultifyRequires() | ||
if (!module) return | ||
if (!module) return this.ast | ||
// handle imports, which go below exports | ||
@@ -102,0 +121,0 @@ this.buildRequires() |
{ | ||
"name": "es6-module-crosspiler", | ||
"description": "An ES6 and CommonJS cross-compatible transpiler", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
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
20027
457