Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #70

Open
shawli123 opened this issue Dec 17, 2018 · 6 comments

Comments

@shawli123
Copy link

No description provided.

@shawli123 shawli123 changed the title what should I do if I don't want to parse the module from node_module? 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. Dec 17, 2018
@mrjoelkemp
Copy link
Collaborator

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.

@shawli123
Copy link
Author

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 !

@mrjoelkemp
Copy link
Collaborator

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).

@shawli123
Copy link
Author

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 !

@mrjoelkemp
Copy link
Collaborator

Thanks! I'll have to trace it to see what's happening in filing-cabinet. It could be a bug.

Thanks for reporting.

@shawli123
Copy link
Author

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants