-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels