jquery.fileDownload icon indicating copy to clipboard operation
jquery.fileDownload copied to clipboard

Make an AMD-Friendly build

Open togakangaroo opened this issue 11 years ago • 9 comments

This plugin is currently difficult to load with require.js. I could wrap it manually but that would break package management with volo. It would be nice to see it wrapped in a UMD https://github.com/umdjs/umd/blob/master/returnExports.js

togakangaroo avatar Jun 30 '13 17:06 togakangaroo

Any update on this?

johnmcase avatar Sep 03 '14 15:09 johnmcase

I haven't heard anything

togakangaroo avatar Sep 03 '14 20:09 togakangaroo

Hey folks,

While I agree using a UMD might make sense for some module types depending on your application, once you load jQueryFileDownload it exists on jQuery for the life of the page. (It is attached, namespaced, whatever you want to call on jQuery) Having it be a UMD would be a little strange since you couldn't actually inject the module in and use it as an injected module, you would just need to know that its part of jQuery after you've added reference to it or something. Am I missing something with that?

johnculviner avatar Sep 03 '14 22:09 johnculviner

The issue is less that and more that it doesn't declare it's dependency on jquery forcing people to use shims. As for your concern, typically what is done in scenarios like this is that you register it to jquery as before and just return the same jquery object.

togakangaroo avatar Sep 03 '14 22:09 togakangaroo

I'm not huge on AMDs but feel free to do a pull anyone that would like and I'll merge it stat

johnculviner avatar Sep 04 '14 22:09 johnculviner

Already in the PR attached to this issue from a year ago

togakangaroo avatar Sep 04 '14 22:09 togakangaroo

ahh sure, sorry I'm used to seeing it a different way. I'll get it added (probably copy+paste) style by this weekend and put your credit on it. Thanks!

johnculviner avatar Sep 05 '14 02:09 johnculviner

Problem still occurs on master bunch (version 1.4.4 This is relay simple fix just add a UMD factory to your namespace

(function (factory) {
    if (typeof define === 'function' && define.amd) {
        define(['jquery', window], factory);
    } else if (typeof exports === 'object') {
        module.exports = factory(require('jquery'), window);
    } else {
        factory(jQuery || Zepto, window);
    }
}(function($, window){
 ..... your code goes here ....
}));

akupiec avatar Jun 13 '16 14:06 akupiec

any news?

batyaro avatar Jul 17 '18 13:07 batyaro