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

ignore require() calls inside already browserified bundles #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Feb 13, 2018

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 browserify/browserify#1773 (comment)

@goto-bus-stop
Copy link
Member Author

Will do this for browserify 17 if there are no complaints by then

@ljharb
Copy link
Member

ljharb commented Apr 11, 2018

What happens if someone has unbrowserified code that has a function argument named “require”?

@goto-bus-stop
Copy link
Member Author

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.

@ljharb
Copy link
Member

ljharb commented Apr 11, 2018

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.

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.
@NHQ
Copy link

NHQ commented Mar 18, 2022

Did this ever land? Asking for browserify/browserify#1817

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

Successfully merging this pull request may close these issues.

How can I require a file that is built using browserify?
3 participants