{"action":"closed","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/4105","labels_url":"https://api.github.com/repos/meteor/meteor/issues/4105/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/4105/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/4105/events","html_url":"https://github.com/meteor/meteor/issues/4105","id":65898275,"number":4105,"title":"This vs global on package level","user":{"login":"Firfi","id":947595,"avatar_url":"https://avatars.githubusercontent.com/u/947595?v=3","gravatar_id":"","url":"https://api.github.com/users/Firfi","html_url":"https://github.com/Firfi","followers_url":"https://api.github.com/users/Firfi/followers","following_url":"https://api.github.com/users/Firfi/following{/other_user}","gists_url":"https://api.github.com/users/Firfi/gists{/gist_id}","starred_url":"https://api.github.com/users/Firfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Firfi/subscriptions","organizations_url":"https://api.github.com/users/Firfi/orgs","repos_url":"https://api.github.com/users/Firfi/repos","events_url":"https://api.github.com/users/Firfi/events{/privacy}","received_events_url":"https://api.github.com/users/Firfi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/meteor/meteor/labels/Project:Isobuild","name":"Project:Isobuild","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-02T10:19:29Z","updated_at":"2015-04-14T20:35:05Z","closed_at":"2015-04-14T20:35:05Z","body":"I have package 1 (reactjs:react@0.2.1 but it isn't important which package it is) which expose variable with `api.export(\"React\", \"server\");`.\r\n\r\nI have package 2 which use package 1: `api.use('reactjs:react@0.2.1', ['server']);`\r\n\r\nThen, package 2 imports dist.js file which is generated umd (https://github.com/umdjs/umd) bundle that uses `this` to assign necessary vars to it: `api.addFiles('dist.js', ['server']);`\r\n\r\nProblem is, this in dist.js doesn't have variable React in `this` variable. Instead, it can access it only with `var react = React;` style.\r\n\r\nExample dist.js:\r\n\r\n    var global = Function('return this')() || (42, eval)('this'); // http://stackoverflow.com/questions/3277182/how-to-get-the-global-object-in-javascript\r\n    console.warn('global: ', !!global.React);\r\n    console.warn('this: ', !!this.React);\r\n    console.warn('?: ', !!React);\r\n\r\nOutput:\r\n\r\n    global:  false\r\n    this:  false\r\n    ?:  true\r\n\r\nI'd like to know if it is bug and if it is not how I can get global object and what the difference between this and global environment on package level."}}