{"action":"created","issue":{"url":"https://api.github.com/repos/graingert/slimerjs/issues/18","labels_url":"https://api.github.com/repos/graingert/slimerjs/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/graingert/slimerjs/issues/18/comments","events_url":"https://api.github.com/repos/graingert/slimerjs/issues/18/events","html_url":"https://github.com/graingert/slimerjs/issues/18","id":81577893,"number":18,"title":"Issue with the module require implementation ","user":{"login":"B2F","id":3914065,"avatar_url":"https://avatars.githubusercontent.com/u/3914065?v=3","gravatar_id":"","url":"https://api.github.com/users/B2F","html_url":"https://github.com/B2F","followers_url":"https://api.github.com/users/B2F/followers","following_url":"https://api.github.com/users/B2F/following{/other_user}","gists_url":"https://api.github.com/users/B2F/gists{/gist_id}","starred_url":"https://api.github.com/users/B2F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/B2F/subscriptions","organizations_url":"https://api.github.com/users/B2F/orgs","repos_url":"https://api.github.com/users/B2F/repos","events_url":"https://api.github.com/users/B2F/events{/privacy}","received_events_url":"https://api.github.com/users/B2F/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-27T18:56:08Z","updated_at":"2015-06-04T14:59:27Z","closed_at":null,"body":"Currently, variables defined in the function scope can be accessed by modules, in both nodejs and phantom require implementation but in slimerjs modules seems to be completely isolated from the function scope.\r\n\r\nE.g.\r\n\r\nFrom file A (function scope root):\r\n\r\n    somFunc = function() {\r\n    ...\r\n      var data = { prop: ... };\r\n      require(fileB);\r\n    ...\r\n    }\r\n\r\nFrom file B (module file):\r\n\r\n    // Will throw a ReferenceError in slimerjs but not in nodejs nor phantom:\r\n    var whatever = data.prop;\r\n    exports.whatever;\r\n\r\nAnything can be done to fix this ?"},"comment":{"url":"https://api.github.com/repos/graingert/slimerjs/issues/comments/108924888","html_url":"https://github.com/graingert/slimerjs/issues/18#issuecomment-108924888","issue_url":"https://api.github.com/repos/graingert/slimerjs/issues/18","id":108924888,"user":{"login":"graingert","id":413772,"avatar_url":"https://avatars.githubusercontent.com/u/413772?v=3","gravatar_id":"","url":"https://api.github.com/users/graingert","html_url":"https://github.com/graingert","followers_url":"https://api.github.com/users/graingert/followers","following_url":"https://api.github.com/users/graingert/following{/other_user}","gists_url":"https://api.github.com/users/graingert/gists{/gist_id}","starred_url":"https://api.github.com/users/graingert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graingert/subscriptions","organizations_url":"https://api.github.com/users/graingert/orgs","repos_url":"https://api.github.com/users/graingert/repos","events_url":"https://api.github.com/users/graingert/events{/privacy}","received_events_url":"https://api.github.com/users/graingert/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T14:59:27Z","updated_at":"2015-06-04T14:59:27Z","body":"You should probably not depend on that behaviour\r\n\r\nuse:\r\n```javascript\r\n# a.js\r\nimport fileB from \"b\"\r\n\r\nfunction somFunc () {\r\n...\r\n  let data = { prop: ... };\r\n  fileB.mutateWhatever(data)\r\n...\r\n}\r\n```\r\n\r\n```javascript\r\n# b.js\r\n\r\nlet B = {\r\n    mutateWhatever(data){\r\n        this.whatever = data.prop\r\n    }\r\n}\r\n\r\nexport default B\r\n```\r\n        \r\nThis will then work on any platform with Babel+Browserify\r\n"}}