{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/1141","labels_url":"https://api.github.com/repos/webpack/webpack/issues/1141/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/1141/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/1141/events","html_url":"https://github.com/webpack/webpack/issues/1141","id":84968145,"number":1141,"title":"Why are modules called with `module.exports` context?","user":{"login":"pgilad","id":4533329,"avatar_url":"https://avatars.githubusercontent.com/u/4533329?v=3","gravatar_id":"","url":"https://api.github.com/users/pgilad","html_url":"https://github.com/pgilad","followers_url":"https://api.github.com/users/pgilad/followers","following_url":"https://api.github.com/users/pgilad/following{/other_user}","gists_url":"https://api.github.com/users/pgilad/gists{/gist_id}","starred_url":"https://api.github.com/users/pgilad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgilad/subscriptions","organizations_url":"https://api.github.com/users/pgilad/orgs","repos_url":"https://api.github.com/users/pgilad/repos","events_url":"https://api.github.com/users/pgilad/events{/privacy}","received_events_url":"https://api.github.com/users/pgilad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-04T07:51:18Z","updated_at":"2015-06-15T08:06:40Z","closed_at":null,"body":"I notice the following line when calling a newly loaded module:\r\n```js\r\nmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\r\n```\r\n\r\nEvaluated at runtime, `module.exports` is an empty object, and this breaks plugins that are built with UMD and need access to the global this, which they assume is `window`.\r\nFor example:\r\nUsing [jquery-visibility](https://github.com/mathiasbynens/jquery-visibility) you notice that in this line: https://github.com/mathiasbynens/jquery-visibility/blob/master/jquery-visibility.js#L25 they expect this to be the global window.\r\n\r\nUsing Webpack - it evaluates to a blank object, forcing you to use `imports?this=>window` as a loader, which is redundant (and wasteful) IMO.\r\n\r\nAny explanations as to why modules are loaded this way?\r\nWhat is the correct solution in this case? I feel that calling modules with a specific context should be an opt-in and not default behavior."},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/111972998","html_url":"https://github.com/webpack/webpack/issues/1141#issuecomment-111972998","issue_url":"https://api.github.com/repos/webpack/webpack/issues/1141","id":111972998,"user":{"login":"sokra","id":1365881,"avatar_url":"https://avatars.githubusercontent.com/u/1365881?v=3","gravatar_id":"","url":"https://api.github.com/users/sokra","html_url":"https://github.com/sokra","followers_url":"https://api.github.com/users/sokra/followers","following_url":"https://api.github.com/users/sokra/following{/other_user}","gists_url":"https://api.github.com/users/sokra/gists{/gist_id}","starred_url":"https://api.github.com/users/sokra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sokra/subscriptions","organizations_url":"https://api.github.com/users/sokra/orgs","repos_url":"https://api.github.com/users/sokra/repos","events_url":"https://api.github.com/users/sokra/events{/privacy}","received_events_url":"https://api.github.com/users/sokra/received_events","type":"User","site_admin":false},"created_at":"2015-06-15T08:06:40Z","updated_at":"2015-06-15T08:06:40Z","body":"CommonJs spec say so."}}