Last active
August 29, 2015 14:05
-
-
Save alexbaulch/7421aa4a8abf302d9b5a to your computer and use it in GitHub Desktop.
AMDify and CommonJSify your jQuery plugin! After spending ages trying to get a decent way to use jQuery plugins with Broswerify or RequireJS I found the following in Addy Osmani's UMD repo (https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js), completely hijacked, none of my own thinking or doing here but needed a way of finding thi…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uses CommonJS, AMD or browser globals to create a jQuery plugin. | |
(function (factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['jquery'], factory); | |
} else if (typeof exports === 'object') { | |
// Node/CommonJS | |
factory(require('jquery')); | |
} else { | |
// Browser globals | |
factory(jQuery); | |
} | |
}(function ($) { | |
$.fn.jqueryPluginCommonJs = function () {}; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment