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

Add UMD definitions #89

Open
OSAGfar opened this issue Nov 29, 2018 · 1 comment
Open

Add UMD definitions #89

OSAGfar opened this issue Nov 29, 2018 · 1 comment

Comments

@OSAGfar
Copy link

OSAGfar commented Nov 29, 2018

The code assumes that module is always available, which is not true (e.g. browser with requireJS). With the following UMD boilerplate it can be much friendlier to use in different environments.

The changes would be straightforward:

  1. Remove the module.exports = punycode; line at the very end

  2. Wrap remaining code like this:

;(function (root, factory) {

  if (typeof define === 'function' && define.amd) {
    define(factory);
  } else if (typeof exports === 'object') {
    module.exports = factory();
  } else {
    root.punycode = factory();
  }

}(this, function () {

  <library code here>

  return punycode;
}));
@FranklinYu
Copy link

FranklinYu commented Jun 1, 2021

Any update? This would be very useful. I can make Pull Request to change scripts/prepublish.js with this template, if the maintainers are interested.

About what’s UMD, see the project homepage.

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

2 participants