Script now defines an AMD module if possible

This PR allows the script to return an AMD module, if possible, making it more compatible with apps that use requirejs.