umd

(function (global, factory) {
     
    if (typeof define === 'function' && define.amd) {
        // 检测上下文环境是否为AMD
        define(['jquery', 'underscore'], factory);
    } else if (typeof module !== 'undefined' && typeof exports === 'object') {
        // 检查上下文环境是否为Node
        module.exports = factory(require('jquery'), require('underscore'));
    } else {
        // 浏览器全局变量
        global.returnExports = factory(global.jQuery, global._);
    }
}(this, function ($, _) {
     

}));

or

(function (global, factory) {
     
    typeof module !== 'undefined' && typeof exports === 'object' ? factory(require('jquery'), require('underscore')) :
    typeof define === 'function' && define.amd ? define(['jquery', 'underscore'], factory) :
    (factory(global.jQuery, global._));
}(this, function ($, _) {
     

}));

你可能感兴趣的:(web前端,amd,cmd,umd)