LearnBoost/socket.io-client — pull request #428 by jdahlq (2012-05-03 07:24:34+00:00)
Title: Enhance the dist files to work with CommonJS loaders

I edited bin/builder.js to include an anonymous function wrapper around the dist files (e.g. dist/socket.io.js and socket.io.min.js) *for non-node builds*. For most of the files that are included in the dists, "this" is passed into functions to refer to the global scope; with the addition of the anonymous wrapper, those occurrences of "this" will now refer to the DOM Window scope, no matter what is actually on the level that the dist file gets loaded into.

Additionally, one line is added to assign top-level var io to module.exports for CommonJS and {} for top-level browser. This has two effects:

1. It bypasses the module.parent.exports lines that are tripping up the non-node CommonJS loaders.
2. It explicitly assigns io to the top-level for browsers.

If it is a node build (settings.node=true), the wrapper isn't used.

When built, the dist file looks like this:

```javascript
var io = ('undefined' === typeof module ? {} : module.exports);
(function() {
//Contents of dist file
})();
```