naver/hammer.js

Change the priority of define and exports.

Closed this issue · 0 comments

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.

  1. Bundle the release js file with commonjs method via webpack.
  2. 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());
}