Here is a small snippet I learned from Pikaday to define a module working in different module loader.

(function(root, factory) {
    if (typeof exports === 'object') {
        // CommonJS
        module.exports = factory();
    } else if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define('MyModule',function ()
        {
            return factory();
        });
    } else {
        root.myModule = factory();
    }
}(this, function () {
    var myModule = {};
    return myModule;
}))