Issue 2 would still remain: this code only checked for `require()` when it loaded but never again, so it would never pick up on a later-defined `require()`.

You're correct that a smaller diff would solve issue 1, but since the other fix requires a function to be called to choose the correct version of `require()`, I formatted/named it more explicitly to be clear about its purpose.