D
D
Dron Krzh2017-09-04 19:40:09
RequireJS
Dron Krzh, 2017-09-04 19:40:09

Gulp babel how to specify umd/amd module name?

Good day, in general, I ran into a problem with the names of modules, or rather their absence. Previously, webpack was used and there were no problems with this, but it was necessary to change the collector to Gulp. With Gulp I use the `gulp-babel` plugin for es6 → es2015 but there is a problem babel generates unnamed modules:

(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define(["exports"], factory);
  } else if (typeof exports !== "undefined") {
    factory(exports);
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports);
    global.i18n = mod.exports;
  }
})(this, function (exports) {
  "use strict";

  Object.defineProperty(exports, "__esModule", {
    value: true
  });

  exports.default = function (key) {
    return chrome.i18n.getMessage(key);
  };
});

Here you can see how for the global scope the module has the name `i18n` but for `define` it does not. How to add titles?
define(["exports"], factory);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question