rewrite of UMD snippet  based on https://github.com/umdjs/umd/blob/master/returnExportsGlobal.js