Browserify: Use module.exports if required, otherwise expose global
问题 I'm considering adopting browserify for some of my projects, but would like to make sure that others don't have to use browserify if they want to use the (bundled) code. The obvious way to do this is to both expose the modules exports through module.exports as well as through a window. global. However, I'd rather not pollute the global namespace for those who are require ing the script. Is it possible to detect if a script is being require d? If it is, then I could do something like: var