detective
detective copied to clipboard
ignore require() calls inside already browserified bundles
If a function expression declares a require parameter, its body is not
analyzed for require() calls. This is mostly helpful for bundles that
were already browserified, detective will ignore the calls to
browser-pack's require runtime.
Doing full scope analysis using scope-analyzer would slow things down by at least about 30%; this patch however has no measurable performance hit and addresses the most common case of how require might end up redefined.
Fixes https://github.com/browserify/browserify/issues/1773#event-1490701098
Will do this for browserify 17 if there are no complaints by then
What happens if someone has unbrowserified code that has a function argument named “require”?
calls to that argument would not be collected as dependencies of the file. I considered that but thought that it would be very rare. But the check could be tightened further to check for the full {id:[function(require){},{}]} pattern at fairly little cost.
I think making it as strict as possible is a good idea, just in case. People may have even copy pasted browserify preambles into their code, and it’d be good to maximize what works.
Did this ever land? Asking for https://github.com/browserify/browserify/issues/1817