Making more compatible with others loaders

by detecting an existing defined "module" in the environment and
exporting to that, instead of "window".
Merge remote-tracking branch 'origin/master'