{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/node-haste/issues/46","repository_url":"https://api.github.com/repos/facebook/node-haste","labels_url":"https://api.github.com/repos/facebook/node-haste/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/facebook/node-haste/issues/46/comments","events_url":"https://api.github.com/repos/facebook/node-haste/issues/46/events","html_url":"https://github.com/facebook/node-haste/pull/46","id":137414203,"number":46,"title":"Better compatibility with browserify modules","user":{"login":"vespakoen","id":876117,"avatar_url":"https://avatars.githubusercontent.com/u/876117?v=3","gravatar_id":"","url":"https://api.github.com/users/vespakoen","html_url":"https://github.com/vespakoen","followers_url":"https://api.github.com/users/vespakoen/followers","following_url":"https://api.github.com/users/vespakoen/following{/other_user}","gists_url":"https://api.github.com/users/vespakoen/gists{/gist_id}","starred_url":"https://api.github.com/users/vespakoen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vespakoen/subscriptions","organizations_url":"https://api.github.com/users/vespakoen/orgs","repos_url":"https://api.github.com/users/vespakoen/repos","events_url":"https://api.github.com/users/vespakoen/events{/privacy}","received_events_url":"https://api.github.com/users/vespakoen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/node-haste/labels/CLA%20Signed","name":"CLA Signed","color":"009900"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-29T23:35:39Z","updated_at":"2016-03-02T22:42:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/node-haste/pulls/46","html_url":"https://github.com/facebook/node-haste/pull/46","diff_url":"https://github.com/facebook/node-haste/pull/46.diff","patch_url":"https://github.com/facebook/node-haste/pull/46.patch"},"body":"This pull request does a couple of things\r\n\r\n1) Checks for the browserify field (some old packages still depend on it)\r\nhttps://github.com/facebook/node-haste/pull/46/files#diff-9103f1ac13c3018f7108b3e6bbf20df4R125\r\n\r\n2) Handles `false` in replacements, shimming it with `_empty.js` as browserify does\r\nhttps://github.com/facebook/node-haste/pull/46/files#diff-9103f1ac13c3018f7108b3e6bbf20df4R99\r\n\r\n3) Add function to get a replacement for a file that is also used in `getMain` (with more path checks)\r\nhttps://github.com/facebook/node-haste/pull/46/files#diff-9103f1ac13c3018f7108b3e6bbf20df4R51\r\n\r\nIt checks for `name`, `'./' + name` and  `'./' + path.relative(this.root, name);`\r\nAnd we should probably add `path.relative(this.root, name);` to that as well?\r\n\r\n4) Cherry on the cake, shims browserify builtins\r\nhttps://github.com/facebook/node-haste/pull/46/files#diff-9103f1ac13c3018f7108b3e6bbf20df4R87\r\n\r\nI tested these changes by requiring some modules and inspecting the generated bundle while on the latest tag of react-native (0.20) and later copied them over to my node-haste fork.\r\n\r\nSimply said, It very likely contains bugs and is probably incompatible with the current master branch.\r\n\r\nTests will follow soon, but here it is anyways!\r\n\r\nThere is room for improvement and help is welcome.\r\n\r\n## Questions\r\n\r\n1) If the path starts with node_modules, it doesn't work anymore, see my \"hotfix\" here\r\nhttps://github.com/facebook/node-haste/pull/46/files#diff-9103f1ac13c3018f7108b3e6bbf20df4R91\r\n\r\n2) Not every module that is (removed /) shimmed with false is replaced.\r\nIt seems to work fine when the replacement is \"at the root\" but not when \"nested deeper\", see the examples of what I mean by that:\r\n\r\nroot:\r\n\r\n```json\r\n\"react-native\": {\r\n  \"./something.js\": false\r\n}\r\n```\r\n\r\nnested deeper:\r\n\r\n```json\r\n\"react-native\": {\r\n  \"./lib/something.js\": false\r\n}\r\n```\r\n\r\nhttps://github.com/facebook/node-haste/pull/46/files#diff-9103f1ac13c3018f7108b3e6bbf20df4R102"},"comment":{"url":"https://api.github.com/repos/facebook/node-haste/issues/comments/191474815","html_url":"https://github.com/facebook/node-haste/pull/46#issuecomment-191474815","issue_url":"https://api.github.com/repos/facebook/node-haste/issues/46","id":191474815,"user":{"login":"vespakoen","id":876117,"avatar_url":"https://avatars.githubusercontent.com/u/876117?v=3","gravatar_id":"","url":"https://api.github.com/users/vespakoen","html_url":"https://github.com/vespakoen","followers_url":"https://api.github.com/users/vespakoen/followers","following_url":"https://api.github.com/users/vespakoen/following{/other_user}","gists_url":"https://api.github.com/users/vespakoen/gists{/gist_id}","starred_url":"https://api.github.com/users/vespakoen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vespakoen/subscriptions","organizations_url":"https://api.github.com/users/vespakoen/orgs","repos_url":"https://api.github.com/users/vespakoen/repos","events_url":"https://api.github.com/users/vespakoen/events{/privacy}","received_events_url":"https://api.github.com/users/vespakoen/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T22:42:39Z","updated_at":"2016-03-02T22:42:39Z","body":"Ah, makes sense now, I didn't know there were other consumers of this package.\r\n\r\nWould you support supporting the browserify builtins behind some flag?\r\nOr make them configurable in the project's package.json?\r\n\r\n```json\r\n\"global-react-native\": {\r\n  \"stuff-that-needs-to-be-gone\": false,\r\n  \"fs\": \"react-native-fs\"\r\n}\r\n```\r\n\r\nI think this is a very important functionality since it's so hard to emulate in another way.\r\n\r\nWorking on the tests and syntax as we speak ;)"}}