{"action":"opened","issue":{"url":"https://api.github.com/repos/babel/babel/issues/7600","repository_url":"https://api.github.com/repos/babel/babel","labels_url":"https://api.github.com/repos/babel/babel/issues/7600/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/7600/comments","events_url":"https://api.github.com/repos/babel/babel/issues/7600/events","html_url":"https://github.com/babel/babel/issues/7600","id":306740152,"number":7600,"title":"[transform-modules-umd] A value is exported to globals when the original script exports nothing","user":{"login":"FinesseRus","id":9006227,"avatar_url":"https://avatars3.githubusercontent.com/u/9006227?v=4","gravatar_id":"","url":"https://api.github.com/users/FinesseRus","html_url":"https://github.com/FinesseRus","followers_url":"https://api.github.com/users/FinesseRus/followers","following_url":"https://api.github.com/users/FinesseRus/following{/other_user}","gists_url":"https://api.github.com/users/FinesseRus/gists{/gist_id}","starred_url":"https://api.github.com/users/FinesseRus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FinesseRus/subscriptions","organizations_url":"https://api.github.com/users/FinesseRus/orgs","repos_url":"https://api.github.com/users/FinesseRus/repos","events_url":"https://api.github.com/users/FinesseRus/events{/privacy}","received_events_url":"https://api.github.com/users/FinesseRus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-20T06:08:32Z","updated_at":"2018-03-20T06:08:32Z","closed_at":null,"author_association":"NONE","body":"I'm not sure whether this is a bug.\r\n\r\nA make a library which doesn't export any value, it modifies the imported object. The original script is somewhat like this:\r\n\r\n```js\r\nimport $ from 'jquery';\r\n\r\n$.fn.superPlugin = () => alert('Hello');\r\n```\r\n\r\nI compile it this way:\r\n\r\n```js\r\nbabel.transformFile('input.js', {\r\n    presets: ['env'],\r\n    plugins: [\r\n        ['transform-es2015-modules-umd', {\r\n            globals: {\r\n                jquery: 'jQuery'\r\n            }\r\n        }]\r\n    ]\r\n});\r\n```\r\n\r\nAnd get the result script:\r\n\r\n```js\r\n(function (global, factory) {\r\n  if (typeof define === \"function\" && define.amd) {\r\n    define(['jquery'], factory);\r\n  } else if (typeof exports !== \"undefined\") {\r\n    factory(require('jquery'));\r\n  } else {\r\n    var mod = {\r\n      exports: {}\r\n    };\r\n    factory(global.jQuery);\r\n    global.repl = mod.exports;\r\n  }\r\n})(this, function (_jquery) {\r\n  'use strict';\r\n\r\n  var _jquery2 = _interopRequireDefault(_jquery);\r\n\r\n  function _interopRequireDefault(obj) {\r\n    return obj && obj.__esModule ? obj : {\r\n      default: obj\r\n    };\r\n  }\r\n\r\n  _jquery2.default.fn.superPlugin = function () {\r\n    return alert('Hello');\r\n  };\r\n});\r\n```\r\n\r\nAs you can see the global variable `repl` is exported in a browser not-AMD environment which is not desired because the original script exports nothing. The expected result:\r\n\r\n```js\r\n(function (global, factory) {\r\n  if (typeof define === \"function\" && define.amd) {\r\n    define(['jquery'], factory);\r\n  } else if (typeof exports !== \"undefined\") {\r\n    factory(require('jquery'));\r\n  } else {\r\n    factory(global.jQuery);\r\n  }\r\n})(this, function (_jquery) {\r\n  'use strict';\r\n\r\n  var _jquery2 = _interopRequireDefault(_jquery);\r\n\r\n  function _interopRequireDefault(obj) {\r\n    return obj && obj.__esModule ? obj : {\r\n      default: obj\r\n    };\r\n  }\r\n\r\n  _jquery2.default.fn.superPlugin = function () {\r\n    return alert('Hello');\r\n  };\r\n});\r\n```\r\n\r\n### My environment\r\n\r\n| software         | version(s)\r\n| ---------------- | -------\r\n| Babel            |  6.26.0\r\n| node             |  6.11.3\r\n| npm              | 3.10.10\r\n| Operating System | macOS 10.13.3\r\n"}}
{"actor":{"display_login":"FinesseRus"}}