detective-es6
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -40,2 +40,5 @@ 'use strict'; | ||
case 'CallExpression': | ||
if (options && options.skipAsyncImports) { | ||
break; | ||
} | ||
if (node.callee.type === 'Import' && node.arguments.length) { | ||
@@ -42,0 +45,0 @@ dependencies.push(node.arguments[0].value); |
{ | ||
"name": "detective-es6", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Get the dependencies of an es6 module", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,7 +18,12 @@ ### detective-es6 [![npm](http://img.shields.io/npm/v/detective-es6.svg)](https://npmjs.org/package/detective-es6) [![npm](http://img.shields.io/npm/dm/detective-es6.svg)](https://npmjs.org/package/detective-es6) | ||
``` | ||
* Supports JSX, Flow, and any other features that [node-source-walk](https://github.com/mrjoelkemp/node-source-walk) supports. | ||
You may also (optionally) configure the detective via a second object argument detective(src, options) that supports the following options: | ||
- skipTypeImports: (Boolean) whether or not to omit type imports (`import type {foo} from "mylib";`) in the list of extracted dependencies. | ||
- skipAsyncImports: (Boolean) whether or not to omit async imports (`import('foo')`) in the list of extracted dependencies. | ||
#### License | ||
MIT |
@@ -107,2 +107,16 @@ 'use strict'; | ||
}); | ||
it('respects settings for async imports', function() { | ||
const source = 'import("myLib")'; | ||
const depsWithAsync = detective(source); | ||
const depsWithoutAsync = detective(source, {skipAsyncImports: true}); | ||
assert.deepEqual(depsWithAsync, ['myLib']); | ||
assert.deepEqual(depsWithoutAsync, []); | ||
}); | ||
it('respects settings for async imports with multiple imports', function() { | ||
const source = 'import("myLib");\nimport foo from \'foo\''; | ||
const depsWithoutAsync = detective(source, {skipAsyncImports: true}); | ||
assert.deepEqual(depsWithoutAsync, ['foo']); | ||
}); | ||
}); |
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
6756
146
29