what should I do if I don't want to parse the module from node_module? for example, import * as api from 'util', 'util' is not a node_module, it is a file under the current path.
shawli123 opened this issue · 6 comments
Are you using Madge or this lib directly? Madge, specifically the dependency tree lib that it uses supports a filter argument to exclude node modules from being traversed.
Yes,i use the dependency-tree.I know the filter argument, but what I want to express, If my code "import util form "util"", "util" is a file under the current dir, not a node module. but the dependency-tree parses it as a node module.so, the "util" will be add to the "noExistent". so, if I don't want to edit the code, can the dependency-tree provide a argument to solve this problem? Thank you !
Thanks for the additional context. Would you be able to share your dependency-tree config? I'm curious as to the options being turned on (namely if you're setting es6's mixed imports).
function getAstTree (entry) {
const list = dependencyTree({
filename: entry,
directory: path.resolve('../'),
nodeModulesConfig: {
entry: 'module'
},
visited,
nonExistent,
isListForm: true,
filter: path => path.indexOf('node_modules') === -1
});
jsTreeList.push(...list);
return list;
}
This is my code. I hope the dependency-tree can look up the module "util" under the current dir first. it actually is a file "./util.js". And if it doesn't exist, look up the node_modules dir secondly. Thank you !
Thanks! I'll have to trace it to see what's happening in filing-cabinet. It could be a bug.
Thanks for reporting.
I think it is not a bug. because “import uitl from "./util.js" ” is a better code, " import util from "util" " is nonstandard. but I hope you can make it more compatible to solve this problem. Thank you !