Skip to content

Instantly share code, notes, and snippets.

@weotch
Created February 10, 2014 19:29
Show Gist options
  • Save weotch/8922504 to your computer and use it in GitHub Desktop.
Save weotch/8922504 to your computer and use it in GitHub Desktop.
Example of implementing UMD spec
// Based on https://github.com/umdjs/umd/blob/master/returnExports.js
(function (root, factory) {
// AMD
if (typeof define === 'function' && define.amd) {
define([
'jquery'
, 'lodash'
], factory);
// CJS
} else if (typeof exports === 'object') {
module.exports = factory(
require('jquery')
, require('lodash')
);
// Window global
} else {
root.share = factory(
root.jquery
, root.lodash
);
}
}(this, function ($, _) {
// Return public API
return {};
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment