fix require.extensions registration

Ref #3141, #3054, #2323.