browserify / detective

Find all calls to require() no matter how deeply nested using a proper walk of the AST

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

if require is aliased, detective incorrectly returns uses of it as dependencies

fresheneesz opened this issue · comments

Eg:

var require = function() {
  console.log('test')   
}   
require("this isn't a dependency")

It should be pretty simple to detect scopes in which require is redefined and exclude requires there.

@fresheneesz No idea about it happening here (I'm guessing unlikely due to performance reasons), but in case you're interested I made an adapation of Detective that does that (taking a big performance hit).

Another variant:

function(require) {
    require("this isn't a dependency");
}

This is in fact the form that browserified modules take, and thus this issue is one of the reasons why a browserified module can't itself be browserified.

#79 implements a fast special case to ignore require calls inside browserified bundles, which I think is the most common situation.