{"action":"created","issue":{"url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/850","labels_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/850/labels{/name}","comments_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/850/comments","events_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/850/events","html_url":"https://github.com/Reactive-Extensions/RxJS/issues/850","id":99594628,"number":850,"title":"An error when global `this` is undefined","user":{"login":"gchudnov","id":1832751,"avatar_url":"https://avatars.githubusercontent.com/u/1832751?v=3","gravatar_id":"","url":"https://api.github.com/users/gchudnov","html_url":"https://github.com/gchudnov","followers_url":"https://api.github.com/users/gchudnov/followers","following_url":"https://api.github.com/users/gchudnov/following{/other_user}","gists_url":"https://api.github.com/users/gchudnov/gists{/gist_id}","starred_url":"https://api.github.com/users/gchudnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gchudnov/subscriptions","organizations_url":"https://api.github.com/users/gchudnov/orgs","repos_url":"https://api.github.com/users/gchudnov/repos","events_url":"https://api.github.com/users/gchudnov/events{/privacy}","received_events_url":"https://api.github.com/users/gchudnov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-07T07:18:54Z","updated_at":"2015-08-16T20:49:23Z","closed_at":"2015-08-14T19:46:10Z","body":"Noticed this issue when using Rx with Babel + Browserify and imporing Rx: `import Rx from 'rx'`.\r\n\r\nThe problem is here:\r\n\r\n_/src/core/internal/util.js_:\r\n```javascript\r\n  var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {\r\n    function __() { this.constructor = child; }\r\n    __.prototype = parent.prototype;\r\n    child.prototype = new __();\r\n  };\r\n```\r\n`this.inherits`\r\n^^\r\n`this` might be undefined. It is set-up in _/src/core/headers/outro.js_ as:\r\n```javascript\r\n}.call(this));\r\n```\r\nAnd top-level `this` is [remapped](https://babeljs.io/docs/faq/#why-is-this-being-remapped-to-undefined-) to `undefined` in Babel.\r\n\r\nI fixed it locally by replacing  `}.call(this));` with `}.call(this || {}));`\r\n\r\nAnd now I'm wondering if it is necessary to add `inherits` to the global `this`, polluting it?\r\n"},"comment":{"url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/comments/131620534","html_url":"https://github.com/Reactive-Extensions/RxJS/issues/850#issuecomment-131620534","issue_url":"https://api.github.com/repos/Reactive-Extensions/RxJS/issues/850","id":131620534,"user":{"login":"gchudnov","id":1832751,"avatar_url":"https://avatars.githubusercontent.com/u/1832751?v=3","gravatar_id":"","url":"https://api.github.com/users/gchudnov","html_url":"https://github.com/gchudnov","followers_url":"https://api.github.com/users/gchudnov/followers","following_url":"https://api.github.com/users/gchudnov/following{/other_user}","gists_url":"https://api.github.com/users/gchudnov/gists{/gist_id}","starred_url":"https://api.github.com/users/gchudnov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gchudnov/subscriptions","organizations_url":"https://api.github.com/users/gchudnov/orgs","repos_url":"https://api.github.com/users/gchudnov/repos","events_url":"https://api.github.com/users/gchudnov/events{/privacy}","received_events_url":"https://api.github.com/users/gchudnov/received_events","type":"User","site_admin":false},"created_at":"2015-08-16T20:49:23Z","updated_at":"2015-08-16T20:49:23Z","body":"Thank you!"}}