Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM Module: CommonJS support #450

Closed
antoniobrandao opened this issue Dec 26, 2014 · 2 comments
Closed

NPM Module: CommonJS support #450

antoniobrandao opened this issue Dec 26, 2014 · 2 comments

Comments

@antoniobrandao
Copy link

Hello,

I fetched jquery.form from NPM and noticed it isn't compatible with the CommonJS format.

I managed to make it work here by changing this:

// AMD support
(function (factory) {
    "use strict";
    if (typeof define === 'function' && define.amd) {
        // using AMD; register as anon module
        define(['jquery'], factory);
    } else {
        // no AMD; invoke directly
        factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );
    }
}

To this:

// AMD and CommonJS support
(function (factory) {
    "use strict";
    if (typeof module !== 'undefined' && module.exports) {
        module.exports = factory;
    } else if (typeof define === 'function' && define.amd) {
        // using AMD; register as anon module
        define(['jquery'], factory);
    } else {
        // no AMD; invoke directly
        factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );
    }
}

(Attempting to implement UMD format https://github.com/umdjs/umd)

This is unlikely to be sufficient but it is working for me. But I have to keep a separated copy of the file.

Would be great if this transition to the UMD format would exist, then it would fit perfectly into the NPM ecossystem, and allow us to use Browserify with it.

Thanks

@dmetzler1988
Copy link

👍

@kevindb
Copy link
Contributor

kevindb commented Feb 21, 2017

Resolved by #496

@kevindb kevindb closed this as completed Feb 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants