Skip to content

Capitalize global module names in UMD builds #17265

Closed

Description

@skrivle

It seems that babel by default is lowercasing all module names, which is causing errors when trying to use the UMD builds in global environment.

Popover.js is requiring global.Tooltip

(function (global, factory) {
  if (typeof define === 'function' && define.amd) {
    define('Popover', ['exports', 'module', './tooltip'], factory);
  } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
    factory(exports, module, require('./tooltip'));
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports, mod, global.Tooltip);
    global.Popover = mod.exports;
  }
})(this, function (exports, module, _tooltip) { ... });

But tooltip.js is only defining global.tooltip ...

(function (global, factory) {
  if (typeof define === 'function' && define.amd) {
    define('Tooltip', ['exports', 'module', './util'], factory);
  } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
    factory(exports, module, require('./util'));
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports, mod, global.Util);
    global.tooltip = mod.exports;
  }
})(this, function (exports, module, _util) { ... });

This is fixable by leveraging the getModuleId option in the grunt babel:umd configuration as you can see here. If you want I can open a pull request ...

Activity

  1. added
    jsJavaScript or TypeScript sources and plugins
    v4v4, the frozen docs on gh-pages
    on Aug 24, 2015
  2. fat commented on Nov 15, 2015

    @fat
    Member

    oh interesting, yeah i like that - a pr would be dope

  3. skrivle commented on Nov 22, 2015

    @skrivle
    ContributorAuthor

    Done!

  4. added a commit that references this issue on Nov 22, 2015
    77a8b44
  5. bardiharborow commented on Oct 28, 2016

    @bardiharborow
    Contributor

    I believe this is no longer valid now that we have removed the UMD builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript or TypeScript sources and pluginsv4v4, the frozen docs on gh-pages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions