fis3-hook-commonjs icon indicating copy to clipboard operation
fis3-hook-commonjs copied to clipboard

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

Open animabear opened this issue 7 years ago • 0 comments

有些第三方库自定义了自己的 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 的分析

animabear avatar Aug 22 '17 13:08 animabear