ast-module-types
Advanced tools
+9
-1
@@ -21,2 +21,10 @@ // Whether or not the node represents an AMD define() call | ||
| // Whether or not the node represents a require at the top of the module | ||
| // This occurs when the module is an initialization (driver) script | ||
| module.exports.isTopLevelRequire = function (node) { | ||
| // If there's a require, it's either the top-level or nested | ||
| // at which it still has at least 3 parents | ||
| return types.isRequire(node) && node.parent.parent.parent.type === 'Program'; | ||
| }; | ||
| // Whether or not the node represents the use of | ||
@@ -62,2 +70,2 @@ // assigning something to module.exports or exports | ||
| return args && args[0].type === 'ObjectExpression'; | ||
| }; | ||
| }; |
+1
-1
| { | ||
| "name": "ast-module-types", | ||
| "version": "1.0.0", | ||
| "version": "1.1.0", | ||
| "description": "Collection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+1
-0
@@ -15,2 +15,3 @@ Collection of useful helper functions when trying to determine | ||
| * `isRequire`: if node matches a `require` function all (declaring a dependency) | ||
| * `isTopLevelRequire`: if node matches a `require` at the top of the file. App initialization (aka driver) scripts have this. | ||
| * `isExports`: if the node matches CommonJS `module.exports` or `exports` (defining a module) | ||
@@ -17,0 +18,0 @@ |
4194
13.97%56
16.67%35
2.94%