Added a condition to make sure `require` is defined before using it

This is because sometimes exports is defined but that doesn't necessarily mean that require is also defined; Lumbar for example, also uses `exports`, but does not use `require`. In this case, it should use browser globals.