With dependency

;(function (root, factory) {

  if (typeof define === 'function' && define.amd) {
    define(['jquery'], factory);
  } else if (typeof exports === 'object') {
    module.exports = factory(require('jquery'));
  } else {
    root.YourModule = factory(root.jQuery);
  }

}(this, function (jquery) {
  return {};
}));
No dependencies ;(
function (root, factory) { if (typeof define === 'function' && define.amd) { define(factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.YourModule = factory(); } }(this, function () { return {}; }));
Supports circular references (
function (root, factory) { if (typeof define === 'function' && define.amd) { define(['exports', 'jquery'], factory); } else if (typeof exports === 'object') { factory(exports, require('jquery')); } else { factory((root.YourModule = {}), root.jQuery); } }(this, function (exports, jQuery) { exports.action = function () {}; }));
Reference https:
//github.com/umdjs/umd

 

相关文章:

  • 2021-04-18
  • 2022-01-18
  • 2022-02-09
  • 2021-05-30
  • 2021-10-30
  • 2021-12-22
  • 2021-12-13
  • 2021-06-25
猜你喜欢
  • 2021-08-26
  • 2021-09-01
  • 2021-07-24
  • 2021-10-02
  • 2021-05-13
  • 2021-08-13
  • 2022-01-06
相关资源
相似解决方案