browserify / detective

Find all calls to require() no matter how deeply nested using a proper walk of the AST
Other
414 stars 60 forks source link

Add a note about requires with more than string literals #36

Closed adam-lynch closed 9 years ago

adam-lynch commented 10 years ago

Is it worth adding a note like https://github.com/substack/browserify-handbook/pull/21 here?

Or is return an array of all the require() calls with string arguments. enough? (From the readme)

adam-lynch commented 10 years ago

Actually, is there a reasonable use case for using require()s with a variable for example, despite knowing they won't be found? If not, then maybe an error could be thrown?

zertosh commented 9 years ago

I've thought about this, and kinda, but I'm not sure it's worth supporting. Consider this case:

var myLib = require(process.env.LIB_DIR + '/my-lib');

If you use envify and process.env.LIB_DIR === '/project/libs', then after the transform, you'd have:

var myLib = require('/project/libs' + '/my-lib');

That should be concatenated and returned as the require value. But that would open a giant can of worms.