Add support for AMD modules and globals

Allows configuration of the type of module to compile to: commonjs, amd, or globals.

Apologies about my CoffeeScript — not very familiar with it.