josephg / Chipmunk-js

Port of slembcke/Chipmunk-Physics to Javascript
http://dl.dropbox.com/u/2494815/demo/Joints.html
536 stars 59 forks source link

Don't set window.cp global if exports exists #1

Closed ryanwilliams closed 12 years ago

ryanwilliams commented 12 years ago

Hi,

In my opinion CP shouldn't set the window.cp global if module.exports exists. i.e. If someone is using commonJS module system, they probably don't want the global being there and will instead 'require' in the lib as needed.

So the top should look something like:

var cp;
if(typeof exports === 'undefined'){
    cp = {};
    if(typeof window === 'object'){
        window.cp = cp;
    }
} else {
    cp = exports;
}
josephg commented 12 years ago

Good point. Fixed.