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

Change the priority of define and exports. #11

Closed
daybrush opened this issue Nov 21, 2018 · 0 comments
Closed

Change the priority of define and exports. #11

daybrush opened this issue Nov 21, 2018 · 0 comments

Comments

@daybrush
Copy link
Member

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());
}
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

1 participant