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

分析require时不分析为作为成员变量的require #20

Open
animabear opened this issue Aug 22, 2017 · 0 comments
Open

分析require时不分析为作为成员变量的require #20

animabear opened this issue Aug 22, 2017 · 0 comments

Comments

@animabear
Copy link

有些第三方库自定义了自己的 require,并作为成员对象调用,比如 select2 这类lib库。这种情况就不应该分析里面的 require 语句,否则会出现类似以下的警告:

[WARNI] Can't resolve `jquery.select2` in file [/node_modules/select2/dist/js/select2.js], did you miss `npm install jquery.select2`?

我现在修改了下正则,加了一个 (?:\.\s*require\b):

var rRequire = /"(?:[^\\"\r\n\f]|\\[\s\S])*"|'(?:[^\\'\n\r\f]|\\[\s\S])*'|(\/\/[^\r\n\f]+|\/\*[\s\S]+?(?:\*\/|$))|(?:\.\s*require\b)|\b(require\.async|require\.ensure|require)\s*\(\s*("(?:[^\\"\r\n\f]|\\[\s\S])*"|'(?:[^\\'\n\r\f]|\\[\s\S])*'|\[[\s\S]*?\])\s*/g;

从而排除对 xxx.require 的分析

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

1 participant