Change the priority of define and exports.
Closed this issue · 0 comments
daybrush commented
When using a UMD-supporting module, there is a possibility that the module does not operate normally depending on the object return order and global environment.
- Bundle the release js file with commonjs method via webpack.
- amd expressions take precedence in certain 'umd support modules'.
- Before
if (typeof define === 'function' && define.amd) {
define(function() {
return Hammer;
});
} else if (typeof module != 'undefined' && module.exports) {
module.exports = Hammer;
} else {
window[exportName] = Hammer;
}
- After
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Hammer = factory());
}