{"action":"created","issue":{"url":"https://api.github.com/repos/asvd/jailed/issues/22","labels_url":"https://api.github.com/repos/asvd/jailed/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/asvd/jailed/issues/22/comments","events_url":"https://api.github.com/repos/asvd/jailed/issues/22/events","html_url":"https://github.com/asvd/jailed/issues/22","id":130179677,"number":22,"title":"Make it work in webpack","user":{"login":"janesconference","id":315834,"avatar_url":"https://avatars.githubusercontent.com/u/315834?v=3","gravatar_id":"","url":"https://api.github.com/users/janesconference","html_url":"https://github.com/janesconference","followers_url":"https://api.github.com/users/janesconference/followers","following_url":"https://api.github.com/users/janesconference/following{/other_user}","gists_url":"https://api.github.com/users/janesconference/gists{/gist_id}","starred_url":"https://api.github.com/users/janesconference/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janesconference/subscriptions","organizations_url":"https://api.github.com/users/janesconference/orgs","repos_url":"https://api.github.com/users/janesconference/repos","events_url":"https://api.github.com/users/janesconference/events{/privacy}","received_events_url":"https://api.github.com/users/janesconference/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-31T20:45:55Z","updated_at":"2016-02-01T10:42:11Z","closed_at":null,"body":"Webpack's static analysis breaks jailed: it's probably because `child_process` is required dynamically.\r\nAnyway, would it be possible to follow [this](https://github.com/webpack/webpack/issues/744) to make it work in the browser?\r\n\r\nJust adding:\r\n\r\n`browser: { fs: false, child_process: false }` to the `package.json` would do the trick"},"comment":{"url":"https://api.github.com/repos/asvd/jailed/issues/comments/177906590","html_url":"https://github.com/asvd/jailed/issues/22#issuecomment-177906590","issue_url":"https://api.github.com/repos/asvd/jailed/issues/22","id":177906590,"user":{"login":"janesconference","id":315834,"avatar_url":"https://avatars.githubusercontent.com/u/315834?v=3","gravatar_id":"","url":"https://api.github.com/users/janesconference","html_url":"https://github.com/janesconference","followers_url":"https://api.github.com/users/janesconference/followers","following_url":"https://api.github.com/users/janesconference/following{/other_user}","gists_url":"https://api.github.com/users/janesconference/gists{/gist_id}","starred_url":"https://api.github.com/users/janesconference/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janesconference/subscriptions","organizations_url":"https://api.github.com/users/janesconference/orgs","repos_url":"https://api.github.com/users/janesconference/repos","events_url":"https://api.github.com/users/janesconference/events{/privacy}","received_events_url":"https://api.github.com/users/janesconference/received_events","type":"User","site_admin":false},"created_at":"2016-02-01T10:42:11Z","updated_at":"2016-02-01T10:42:11Z","body":"Hello @asvd ,\r\nThis is not a runtime issue. At runtime, jailed recognizes the right environment and works just fine.\r\nThis is a Webpack \"compilation\" issue, which happens before runtime.\r\n\r\nWhen Webpack does a static analysis to substitute the require statements with real modules, it can't recognize dynamic requires, like here: https://github.com/asvd/jailed/blob/1682cdb58dea8d6f98554ccf34a433e8cc686da0/lib/jailed.js#L192. \r\n\r\nThis causes the compilation to fail.\r\n\r\nGenerally, with packages that run indifferently on the client and the server side, it's good to give an hint  that some modules your package requires are and will always be unavailable on the browser. There's a field in the `package.json` for that, as described here: https://github.com/defunctzombie/package-browser-field-spec\r\n\r\nThat's why I suggested to add the `browser: { fs: false, child_process: false }` line - it gives info to whoever is trying to compile your package to not bother with those dependencies in browser land."}}