This repository was archived by the owner on Aug 13, 2022. It is now read-only.
Description Some ideas:
Possible starting point diff:
diff --git a/lib/debug.js b/lib/debug.js
new file mode 100644
index 0000000..b9d36e2
--- /dev/null
+++ b/lib/debug.js
@@ -0,0 +1,15 @@
+ "use strict";
+
+ /**
+ * Simple debugger using lazy http://npm.im/debug
+ */
+ const NOOP = () => {};
+
+ let debug;
+ try {
+ debug = require("debug")
+ } catch (err) {
+ debug = () => NOOP;
+ }
+
+ module.exports = debug;
diff --git a/lib/extract.js b/lib/extract.js
index 0a26c6b..0bc6c7b 100644
--- a/lib/extract.js
+++ b/lib/extract.js
@@ -3,8 +3,11 @@
/**
* Extract dependencies from code.
*/
-
const walk = require("acorn-node/walk");
+ const debug = require("debug");
+
+ // Track non-literal imports
+ const debugNonLiteral = debug("trace-deps:non-literal");
// Extract all dependency strings from require/import statements.
const getDeps = (ast) => {
@@ -183,10 +186,12 @@ const getDeps = (ast) => {
// value: four
// raw: '"four"'
// ```
- ExportNamedDeclaration({ source } = {}) {
- source = source || {};
+ ExportNamedDeclaration(node = {}) {
+ const source = node.source || {};
if (source.type === "Literal") {
deps.add(source.value);
+ } else {
+ debugNonLiteral(JSON.stringify(node));
}
},
@@ -207,6 +212,8 @@ const getDeps = (ast) => {
source = source || {};
if (source.type === "Literal") {
deps.add(source.value);
+ } else {
+ debugNonLiteral(JSON.stringify(source));
}
}
diff --git a/package.json b/package.json
index be11426..93bf173 100644
--- a/package.json
+++ b/package.json
@@ -33,6 +33,7 @@
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codecov": "^3.6.5",
+ "debug": "^4.1.1",
"eslint": "^6.8.0",
"eslint-config-formidable": "^4.0.0",
"eslint-plugin-filenames": "^1.3.2",Reactions are currently unavailable
Some ideas:
debugwithout it being a dependency.utilrequire(A_VAR)require.resolve(A_VAR)import(A_VAR)ignoresmatchesallowMissingmatchesPossible starting point diff: