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