如何在纯javascript插件中声明jQuery的可选依赖项?
我当前的插件以:
开头(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// if i put 'jQuery' in the array here that's a forced dependency
// and I want it optional
define([], factory);
}
else if (typeof exports === 'object') {
module.exports = factory();
}
else {
root.myPlugin = factory(root.$ || root.jQuery);
}
}(this, function (jQuery) {
"use-strict";
... plug-in code
}));