{"action":"created","issue":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6958","repository_url":"https://api.github.com/repos/gatsbyjs/gatsby","labels_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6958/labels{/name}","comments_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6958/comments","events_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6958/events","html_url":"https://github.com/gatsbyjs/gatsby/issues/6958","id":346856648,"node_id":"MDU6SXNzdWUzNDY4NTY2NDg=","number":6958,"title":"[v2] ReferenceError: exports is not defined in gatsby-browser","user":{"login":"lightstrike","id":1368742,"node_id":"MDQ6VXNlcjEzNjg3NDI=","avatar_url":"https://avatars3.githubusercontent.com/u/1368742?v=4","gravatar_id":"","url":"https://api.github.com/users/lightstrike","html_url":"https://github.com/lightstrike","followers_url":"https://api.github.com/users/lightstrike/followers","following_url":"https://api.github.com/users/lightstrike/following{/other_user}","gists_url":"https://api.github.com/users/lightstrike/gists{/gist_id}","starred_url":"https://api.github.com/users/lightstrike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightstrike/subscriptions","organizations_url":"https://api.github.com/users/lightstrike/orgs","repos_url":"https://api.github.com/users/lightstrike/repos","events_url":"https://api.github.com/users/lightstrike/events{/privacy}","received_events_url":"https://api.github.com/users/lightstrike/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-02T04:39:04Z","updated_at":"2018-08-02T20:29:47Z","closed_at":"2018-08-02T20:22:21Z","author_association":"CONTRIBUTOR","body":"I hit a strange error in `gatsby-browser.js` when working on a v2 upgrade (running `2.0.0-beta.65`):\r\n\r\n```\r\nUncaught ReferenceError: exports is not defined\r\n    at eval (var/www/gatsby/gatsby-browser.js:14)\r\n    at Module../gatsby-browser.js (commons.js:1027)\r\n    at __webpack_require__ (commons.js:725)\r\n    at fn (commons.js:102)\r\n    at eval (var/www/gatsby/.cache/api-runner-browser-plugins.js:2)\r\n    at Object../.cache/api-runner-browser-plugins.js (commons.js:804)\r\n    at __webpack_require__ (commons.js:725)\r\n    at fn (commons.js:102)\r\n    at eval (var/www/gatsby/.cache/api-runner-browser.js:3)\r\n    at Object../.cache/api-runner-browser.js (commons.js:815)\r\n```\r\n\r\n`exports` is set up normally (I cross-checked with the [www file](https://github.com/gatsbyjs/gatsby/blob/master/www/gatsby-browser.js)):\r\n```js\r\n/**\r\n * Implement Gatsby's Browser APIs in this file.\r\n *\r\n * See: https://www.gatsbyjs.org/docs/browser-apis/\r\n */\r\nimport Cookies from 'universal-cookie';\r\n\r\n/*\r\n * Set `siteVersion` cookie that is used for release tracking and split testing.\r\n */\r\nexports.onClientEntry = () => {\r\n    const cookies = new Cookies()\r\n    cookies.set('siteVersion', process.env.BRANCH, { maxAge: 604800, path: '/' })\r\n}\r\n```\r\n\r\nI was able to refactor as follows and everything seems to work as intended.\r\n\r\n```js\r\nexport function onClientEntry() {\r\n    const cookies = new Cookies();\r\n    cookies.set('siteVersion', process.env.BRANCH, { maxAge: 604800, path: '/' });\r\n}\r\n```\r\n\r\nWorth noting this same project uses `exports` in `gatsby-node.js` with no issues, such as `exports.createPages`.\r\n\r\nAny ideas what might cause this?"},"comment":{"url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/comments/410058086","html_url":"https://github.com/gatsbyjs/gatsby/issues/6958#issuecomment-410058086","issue_url":"https://api.github.com/repos/gatsbyjs/gatsby/issues/6958","id":410058086,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDA1ODA4Ng==","user":{"login":"lightstrike","id":1368742,"node_id":"MDQ6VXNlcjEzNjg3NDI=","avatar_url":"https://avatars3.githubusercontent.com/u/1368742?v=4","gravatar_id":"","url":"https://api.github.com/users/lightstrike","html_url":"https://github.com/lightstrike","followers_url":"https://api.github.com/users/lightstrike/followers","following_url":"https://api.github.com/users/lightstrike/following{/other_user}","gists_url":"https://api.github.com/users/lightstrike/gists{/gist_id}","starred_url":"https://api.github.com/users/lightstrike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightstrike/subscriptions","organizations_url":"https://api.github.com/users/lightstrike/orgs","repos_url":"https://api.github.com/users/lightstrike/repos","events_url":"https://api.github.com/users/lightstrike/events{/privacy}","received_events_url":"https://api.github.com/users/lightstrike/received_events","type":"User","site_admin":false},"created_at":"2018-08-02T20:29:47Z","updated_at":"2018-08-02T20:29:47Z","author_association":"CONTRIBUTOR","body":"@Chuloo Thanks for clarifying! :confetti_ball: Would be great to add that to the Browser API docs."}}
{"actor":{"display_login":"lightstrike"}}