Change module definition style to also support AMD (RequireJS etc)

This pull request changes the module definition style to provide support for AMD (eg. RequireJS), in addition to the previously supported CommonJS and global scope patterns.