Prefer assigning to module.exports instead of window if both are defined

Otherwise defining window and also browserifying this causes bad things to happen.